[
https://issues.apache.org/jira/browse/MCOMPILER-447?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17251316#comment-17251316
]
Claudio Corsi commented on MCOMPILER-447:
-----------------------------------------
To give you more context with this issue. I am creating a single module
project that creates a java agent. The java agent is supposed to be able to
work for jdk version 7 or newer. By default, the generated jar file is not a
java module jar but using the ability to create a multi-version jar. An
implementation version for jdk 9 was added that is a java module.
I created unit tests that test the different features of the java agent and
that works nicely. The issue is that as soon as I actually started to test the
java agent as a java agent. I started to get failures that I wanted to include
as part of my integration tests. I was able to add integrations tests when the
application is not a java module. It when I started to add integration tests
that is a java module.
All of these integration tests fork/spawn a java process that includes the java
agent as part of its command line. I then check the resulting run of the
integration test for failures.
The issue was when I was trying to create an integration test using a java
module test. Specifically trying to build that module test. It would generate
the unsupported operation exception because the main module is not a java
module but the test is a java module.
Hope this helps.
> Unable to compile modularized test for a multi-version jar that is not a java
> module by default
> -----------------------------------------------------------------------------------------------
>
> Key: MCOMPILER-447
> URL: https://issues.apache.org/jira/browse/MCOMPILER-447
> Project: Maven Compiler Plugin
> Issue Type: Bug
> Affects Versions: 3.8.1
> Reporter: Claudio Corsi
> Priority: Blocker
>
> I have a single module project that is creating a mult-version jar file. By
> default the multi-version jar is not a java module because it is being built
> for jdk 7 or newer. The multi-version jar does contain a java module
> definition within the /META-INF/versions/9 directory. I am trying to create
> a integration test that uses the java module of the code. When I tried
> building the module tests I got the UnsupportedOperationException with the
> message:
>
> Can't compile test sources when main sources are missing a module descriptor
>
> The issue was that the main module does not contain a module descriptor but
> the test does contain a module descriptor.
>
> I then forked a copy of the maven compiler plugin. I created an integration
> test and was able to fix this issue. The issue was that I needed to find the
> latest version of the java-module for the module generated multi-version jar
> file. This because the module descriptor and was added to the javac command.
>
> I then tried to build my test source again and this time it stated that it
> was not able to find a class because it is part of a jar file that does not
> contain any java module definition. I updated the integration test and was
> able to add another fix to the forked copy that resolved that issue. The
> issue was that all non-java-module jar files should be included as part of
> the class path. They were all being included as part of the module path.
>
> I then used the fixed jar file to build my project and it failed again
> because of it accessing a unnamed module. I had to finally update my pom to
> include a --add-reads command line option. I will not try to add a fix to
> this issue since this issue has a workaround unlike the other two that didn't.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)