<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <packaging>pom</packaging>

  <parent>
    <groupId>org.cache2k</groupId>
    <artifactId>cache2k-parent</artifactId>
    <version>2.6.1.Final</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <artifactId>cache2k-java11-parent</artifactId>
  <version>2.6.1.Final</version>
  <name>cache2k Java 11 parent pom</name>

  <description>
    Parent pom for all modules that support Java 11 with modularization and
    add modules-info.java
  </description>

  <build>
    <plugins>
      <!-- This is used for IDE -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <!-- we need to repeat source and target or override
               otherwise we inherit source and target from parent.
               This merges in the error prone setup from the parent.
          -->
          <source>11</source>
          <target>11</target>
          <release>8</release>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>

    <profile>
      <id>jdk11</id>
      <activation>
        <jdk>11</jdk>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <executions>
              <!-- disable default phase due to fixed id and position in lifecycle -->
              <execution>
                <id>default-compile</id>
                <phase>none</phase>
                <!-- specify source/target for IDE integration
                     Needs to be Java 11 and not 8 to also edit the java11 source dir.
                -->
                <configuration>
                  <release>11</release>
                </configuration>
              </execution>
              <!-- Compile sources with Java 8 first. -->
              <execution>
                <id>java-8-compile</id>
                <goals>
                  <goal>compile</goal>
                </goals>
                <configuration>
                  <release>8</release>
                </configuration>
              </execution>
              <!-- Java 11 sources to generate and validate module-info.java -->
              <execution>
                <id>java-11-compile</id>
                <goals>
                  <goal>compile</goal>
                </goals>
                <configuration>
                  <release>11</release>
                  <compileSourceRoots>${project.basedir}/src/main/java11</compileSourceRoots>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>jdk8</id>
      <activation>
        <jdk>1.8</jdk>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration combine.self="override">
              <source>8</source>
              <target>8</target>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>

</project>
