You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Robert Scholte (Jira)" <ji...@apache.org> on 2021/09/05 18:57:00 UTC

[jira] [Closed] (MCOMPILER-447) Unable to compile modularized test for a multi-version jar that is not a java module by default

     [ https://issues.apache.org/jira/browse/MCOMPILER-447?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Scholte closed MCOMPILER-447.
------------------------------------
      Assignee: Robert Scholte
    Resolution: Won't Fix

How do you test this? With 3 execution blocks in maven-surefire-plugin? 
Multi release jars can only be tested correctly as a jar using different versions of the JDK. 
https://maven.apache.org/plugins/maven-compiler-plugin/multirelease.html describes the known patterns and how to test them.
Trying to do it with different test output directories can lead to incorrect results.

> 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
>            Assignee: Robert Scholte
>            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)