Skip to content
Permalink
Browse files
Use dynamic profiles when testing the assembled JAR
This prevents unsupported runtime flags being used in Java8
during test execution using the Maven surefire plugin.
  • Loading branch information
davecromberge committed Jun 17, 2021
1 parent 14156da commit 4379db0d50a333c26e46d7b776ec72f5428e822c
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 30 deletions.
@@ -67,9 +67,6 @@
--add-opens java.base/jdk.internal.misc=org.apache.datasketches.memory
--add-exports org.apache.datasketches.memory.tests/org.apache.datasketches.memory.test=org.testng
</argLine>
<jdkToolchain>
<version>9</version>
</jdkToolchain>
</configuration>
</plugin>

@@ -48,35 +48,97 @@
<artifactId>datasketches-memory-tests</artifactId>
<name>${project.artifactId}</name>

<properties>
<maven.install.skip>true</maven.install.skip>
<maven.javadoc.skip>true</maven.javadoc.skip>
<jdk-toolchain.version>11</jdk-toolchain.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>

<!-- The tests in the following profiles run against the assembled MR-JAR. Hence, they
only run during the Maven package phase.
Tests are scanned from dependency JARs using `dependenciesToScan`. -->
<build>
<plugins>
only run during the Maven package phase. Different profiles are selected based on
the environment-specific version of Java that was used to run `mvn package`. This
is because the new JPMS runtime arguments result in a catastrophic system error whilst
using Java 8. Tests are scanned from dependency JARs using `dependenciesToScan`. -->
<profiles>
<profile>
<id>java8</id>
<activation>
<jdk>11</jdk>
</activation>

<build>
<pluginManagement>
<plugins>

<plugin>
<!-- Apache Parent pom, pluginManagement-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<executions>
<execution>
<id>package-test</id>
<phase>package</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<dependenciesToScan>
<dependency>org.apache.datasketches:datasketches-memory-java8-tests</dependency>
</dependenciesToScan>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>

<profile>
<id>java9to14</id>
<activation>
<jdk>[9,14)</jdk>
</activation>

<plugin>
<!-- Apache Parent pom, pluginManagement-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<executions>
<execution>
<id>package-test</id>
<phase>package</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<dependenciesToScan>
<dependency>org.apache.datasketches:datasketches-memory-java8-tests</dependency>
</dependenciesToScan>
</configuration>
</execution>
</executions>
</plugin>
<build>
<pluginManagement>
<plugins>

</plugins>
</build>
<plugin>
<!-- Apache Parent pom, pluginManagement-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<executions>
<execution>
<id>package-test</id>
<phase>package</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<argLine>
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED
--add-opens java.base/jdk.internal.ref=ALL-UNNAMED
--add-opens org.apache.datasketches.memory/org.apache.datasketches.memory.internal=ALL-UNNAMED
</argLine>
<dependenciesToScan>
<dependency>org.apache.datasketches:datasketches-memory-java8-tests</dependency>
</dependenciesToScan>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>

</project>
@@ -123,6 +123,12 @@
<descriptors>
<descriptor>src/assembly/assemble-mr-jar.xml</descriptor>
</descriptors>
<!-- The class loader requires this to be set in a multi-release JAR's manifest -->
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
</execution>

0 comments on commit 4379db0

Please sign in to comment.