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 2018/06/02 12:19:00 UTC

[jira] [Commented] (MCOMPILER-330) Add java.* JPMS modules for testing only is hard

    [ https://issues.apache.org/jira/browse/MCOMPILER-330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16499037#comment-16499037 ] 

Robert Scholte commented on MCOMPILER-330:
------------------------------------------

I'm still looking for a proper solution. Fact is that you have to specify it somewhere, either in the pom or a separate file (to be interpreted by the plugin). I don't think there's a 100% reliable solution by scanning the sources and it would probably overcomplicate things for rare cases. 
With MCOMPILER-341 being merged you could solve it with a module descriptor in the test source directory, which must be an extended version of the one in the main sources directory.
One option I'd like to investigate is doing it with a {{META-INF/jpms.args}} which is already generated when there are additional arguments.

> Add java.* JPMS modules for testing only is hard
> ------------------------------------------------
>
>                 Key: MCOMPILER-330
>                 URL: https://issues.apache.org/jira/browse/MCOMPILER-330
>             Project: Maven Compiler Plugin
>          Issue Type: Improvement
>    Affects Versions: 3.7.0
>         Environment: Windows 10, Maven v3.5.2
>            Reporter: Stephen Colebourne
>            Priority: Major
>         Attachments: maven-issue3.zip
>
>
> Attached is a project demonstrating this issue (which affects both compiler and surefire). The basic problem here is where the project depends on a java.* module for testing but not at compile time. For example, the test code depends on `java.desktop` module, but the main code does not.
> While this has similarities with MCOMPILER-320 it is different because there is no way to refer to the `java.*` JPMS modules as dependencies.
> Right now the workaround is to add both --add-modules and --add-reads, as shown in the attachment. This is painful low-level stuff that Maven should be hiding the user from.
> NOTE: the attachment will succeed when run. Delete the compiler/surefire plugin config to see the issue.
> Rather than tackle this problem directly, my preference would be to have a module-patch.java file that allows users to declare additional dependencies/exports/services that only apply at testing time. This would be interpreted whenever --patch-module is being used. (As well as the example explained here, I've also run into the need to export packages that only exist in tests, and this currently also requires low-level argLine manipulation).
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)