Multi Release Jars and reactors and 'test'

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Multi Release Jars and reactors and 'test'

Enrico Olivelli
Hi,
I have a problem with a multi-module project.
This is the setup (you can find it here [1]):
- I have a module which produces a multi-release jar when built using jdk10+ [2]

<profile>
<id>jdk10</id>
<activation>
<jdk>[10,)</jdk>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>jdk10</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>10</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java10</compileSourceRoot>
</compileSourceRoots>
<outputDirectory>${project.build.outputDirectory}/META-INF/versions/10</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<configuration>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>

- a second module depends on the first one

if I run "mvn test" from the root of the reactor it seems that
surefire is picking
ONLY the directory which the jdk10+ special classes

so in the example in herddb-net project surefire uses as classpath
only a part of classes of herddb-utils (the module with produces the
multi-release jar)

Running "mvn verify" works well, and herddb-net is picking up the JAR

Enrico

[1] https://github.com/diennea/herddb/
[2] https://github.com/diennea/herddb/blob/master/herddb-utils/pom.xml

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Multi Release Jars and reactors and 'test'

Robert Scholte-8
Please read  
https://maven.apache.org/plugins/maven-compiler-plugin/multirelease.html

The tricky thing about MultiRelease JARS is that it only works with JARS,  
so surefire won't help you here.
You need to use failsafe for testing with MRJARS.

The concept you-re using is "Single project (runtime)". [1]

I see I need to update the example, because pasts of the configuration can  
be removed.

<configuration>
   <release>10</release>
   <compileSourceRoots>
     <compileSourceRoot>${project.basedir}/src/main/java10</compileSourceRoot>
   </compileSourceRoots>
   <multiReleaseOutput>true</multiReleaseOutput>
</configuration>

Robert

[1]  
https://github.com/apache/maven-compiler-plugin/tree/master/src/it/multirelease-patterns

On Wed, 02 Jan 2019 22:54:40 +0100, Enrico Olivelli <[hidden email]>  
wrote:

> Hi,
> I have a problem with a multi-module project.
> This is the setup (you can find it here [1]):
> - I have a module which produces a multi-release jar when built using  
> jdk10+ [2]
>
> <profile>
> <id>jdk10</id>
> <activation>
> <jdk>[10,)</jdk>
> </activation>
> <build>
> <pluginManagement>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <executions>
> <execution>
> <id>jdk10</id>
> <goals>
> <goal>compile</goal>
> </goals>
> <configuration>
> <release>10</release>
> <compileSourceRoots>
> <compileSourceRoot>${project.basedir}/src/main/java10</compileSourceRoot>
> </compileSourceRoots>
> <outputDirectory>${project.build.outputDirectory}/META-INF/versions/10</outputDirectory>
> </configuration>
> </execution>
> </executions>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-jar-plugin</artifactId>
> <executions>
> <execution>
> <id>default-jar</id>
> <configuration>
> <archive>
> <manifestEntries>
> <Multi-Release>true</Multi-Release>
> </manifestEntries>
> </archive>
> </configuration>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </pluginManagement>
> </build>
>
> - a second module depends on the first one
>
> if I run "mvn test" from the root of the reactor it seems that
> surefire is picking
> ONLY the directory which the jdk10+ special classes
>
> so in the example in herddb-net project surefire uses as classpath
> only a part of classes of herddb-utils (the module with produces the
> multi-release jar)
>
> Running "mvn verify" works well, and herddb-net is picking up the JAR
>
> Enrico
>
> [1] https://github.com/diennea/herddb/
> [2] https://github.com/diennea/herddb/blob/master/herddb-utils/pom.xml
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]