[
https://issues.apache.org/jira/browse/MCOMPILER-421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17147116#comment-17147116
]
John Patrick commented on MCOMPILER-421:
----------------------------------------
Okay so I got to a flaw / design but with module-info.java, that being a
module-info.java must exists in the root, so a multi release jar can never be
1.8 as the root java version.
If I compile with maven until the failure, then;
`cp target/classes/META-INF/versions/11/module-info.class target/classes`
Then the following commands work, otherwise I get;
{code}
src/test/java11/module-info.java:2: error: module not found:
example.service.interfaces
requires example.service.interfaces;
^
1 error
{code}
After copying the module-info.class and executing the following everything
works;
{code}
HOME=~
rm -rf target/test-classes ;
mkdir -p target/test-classes ;
JAVA_HOME=`/usr/libexec/java_home -v "1.8"` ;
javac -source 1.8 -target 1.8 \
-cp
./target/classes/:../service-interfaces/target/test-classes:${HOME}/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.6.2/junit-jupiter-api-5.6.2.jar:${HOME}/.m2/repository/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar
\
-d target/test-classes \
src/test/java/tld/example/interfaces/tests/ExampleServiceTest.java
JAVA_HOME=`/usr/libexec/java_home -v "11"` ;
javac --release 11 \
--module-path
./target/classes:${HOME}/.m2/repository/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar:${HOME}/.m2/repository/org/apache/commons/commons-lang3/3.10/commons-lang3-3.10.jar:${HOME}/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.6.2/junit-jupiter-api-5.6.2.jar:${HOME}/.m2/repository/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar:${HOME}/.m2/repository/org/junit/platform/junit-platform-commons/1.6.2/junit-platform-commons-1.6.2.jar:${HOME}/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar
\
--patch-module
expected.service.implementation.tests=./target/test-classes \
-d target/test-classes/META-INF/versions/11 \
src/test/java11/module-info.java
$ find target/classes ;
target/classes
target/classes/tld
target/classes/tld/example
target/classes/tld/example/interfaces
target/classes/tld/example/interfaces/ExampleService.class
target/classes/META-INF
target/classes/META-INF/versions
target/classes/META-INF/versions/11
target/classes/META-INF/versions/11/module-info.class
target/classes/module-info.class
$ find target/test-classes ;
target/test-classes
target/test-classes/tld
target/test-classes/tld/example
target/test-classes/tld/example/interfaces
target/test-classes/tld/example/interfaces/tests
target/test-classes/tld/example/interfaces/tests/ExampleServiceTest.class
target/test-classes/META-INF
target/test-classes/META-INF/versions
target/test-classes/META-INF/versions/11
target/test-classes/META-INF/versions/11/module-info.class
{code}
> multi release jar issue with module-info.java when using provides
> -----------------------------------------------------------------
>
> Key: MCOMPILER-421
> URL: https://issues.apache.org/jira/browse/MCOMPILER-421
> Project: Maven Compiler Plugin
> Issue Type: Improvement
> Affects Versions: 3.8.1
> Reporter: John Patrick
> Priority: Major
>
> If you have the following structure you have to recompile everything for each
> version supported.
> If you have the following code;
> {code}
> src/main/java/package/Service.java (1)
> src/main/java/package/Example.java (2)
> src/main/java/package/Java1dot8.java (3)
> src/main/java11/package/Example.java (4)
> src/main/java11/package/Java11.java (5)
> src/main/java11/module-info.java (6)
> src/main/java14/package/Example.java (7)
> src/main/java14/package/Java14.java (8)
> src/main/java14/module-info.java (9)
> {code}
> I expect the following jar structure;
> {code}
> package/Service.class (1)
> package/Example.class (2)
> package/Java1dot8.class (3)
> META-INF/versions/11/package/Example.java (4)
> META-INF/versions/11/package/Java11.java (5)
> META-INF/versions/11/module-info.java (6)
> META-INF/versions/14/package/Example.java (7)
> META-INF/versions/14/package/Java14.java (8)
> META-INF/versions/14/module-info.java (9)
> {code}
> Using the following maven configuration;
> {code}
> <executions>
> <execution>
> <id>java11-main</id>
> <phase>compile</phase>
> <goals>
>
> <goal>compile</goal>
> </goals>
> <configuration>
>
> <release>11</release>
> <jdkToolchain>
>
> <version>11</version>
> </jdkToolchain>
>
> <compileSourceRoots>
>
> <compileSourceRoot>${project.basedir}/src/main/java11</compileSourceRoot>
>
> </compileSourceRoots>
>
> <multiReleaseOutput>true</multiReleaseOutput>
> </configuration>
> </execution>
> <execution>
> <id>java14-main</id>
> <phase>compile</phase>
> <goals>
>
> <goal>compile</goal>
> </goals>
> <configuration>
>
> <release>14</release>
> <jdkToolchain>
>
> <version>14</version>
> </jdkToolchain>
>
> <compileSourceRoots>
>
> <compileSourceRoot>${project.basedir}/src/main/java14</compileSourceRoot>
>
> </compileSourceRoots>
>
> <multiReleaseOutput>true</multiReleaseOutput>
> </configuration>
> </execution>
> </executions>
> {code}
> But due to needing to use provides and uses in the module-info.java
> {code}
> module MODULE_A {
> exports PACKAGE_A;
> uses PACKAGE_B.Service;
> provides PACKAGE_B.Service
> with PACKAGE_A.ServiceImpl;
> }
> {code}
> I get compile errors with src/main/java11/module-info.java as that class is
> under src/main/java. So I need to change it to something like this so the
> compile see classes already compiled that are in target/classes;
> {code}
> <executions>
> <execution>
> <id>java11-main</id>
> <phase>compile</phase>
> <goals>
>
> <goal>compile</goal>
> </goals>
> <configuration>
>
> <release>11</release>
> <jdkToolchain>
>
> <version>11</version>
> </jdkToolchain>
>
> <compileSourceRoots>
>
> <compileSourceRoot>${project.basedir}/src/main/java</compileSourceRoot>
>
> <compileSourceRoot>${project.basedir}/src/main/java11</compileSourceRoot>
>
> </compileSourceRoots>
>
> <multiReleaseOutput>true</multiReleaseOutput>
> </configuration>
> </execution>
> <execution>
> <id>java14-main</id>
> <phase>compile</phase>
> <goals>
>
> <goal>compile</goal>
> </goals>
> <configuration>
>
> <release>14</release>
> <jdkToolchain>
>
> <version>14</version>
> </jdkToolchain>
>
> <compileSourceRoots>
>
> <compileSourceRoot>${project.basedir}/src/main/java</compileSourceRoot>
>
> <compileSourceRoot>${project.basedir}/src/main/java11</compileSourceRoot>
>
> <compileSourceRoot>${project.basedir}/src/main/java14</compileSourceRoot>
>
> </compileSourceRoots>
>
> <multiReleaseOutput>true</multiReleaseOutput>
> </configuration>
> </execution>
> </executions>
> {code}
> Which then produces a jar looking something like this;
> {code}
> package/Service.class (1)
> package/Example.class (2)
> package/Java1dot8.class (3)
> META-INF/versions/11/package/Java1dot8.class (3)
> META-INF/versions/11/package/Example.java (4)
> META-INF/versions/11/package/Java11.java (5)
> META-INF/versions/11/module-info.java (6)
> META-INF/versions/14/package/Java1dot8.class (3)
> META-INF/versions/14/package/Java11.java (5)
> META-INF/versions/14/package/Example.java (7)
> META-INF/versions/14/package/Java14.java (8)
> META-INF/versions/14/module-info.java (9)
> {code}
> One of the projects that needs this is
> https://github.com/nhojpatrick/nhojpatrick-cucumber/tree/feature/surefire-3.0.0-M5
> The actual module-info.java using provides is
> https://github.com/nhojpatrick/nhojpatrick-cucumber/blob/feature/surefire-3.0.0-M5/json-transformations/remove/src/main/java11/module-info.java
--
This message was sent by Atlassian Jira
(v8.3.4#803005)