apache / apache/maven-compiler-plugin

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

Open
#549 4 comments 0 reactions 0 assignees View on GitHub
enhancement priority:major
Dominant language
Java
Stars
261
Forks
191
Avg merge
1d 5h
Merged PRs (30d)
8

Description

**[Stephen Colebourne](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=scolebourne@joda.org)** opened **[MCOMPILER-330](https://issues.apache.org/jira/browse/MCOMPILER-330?redirect=false)** and commented

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).

 

---

**Affects:** 3.7.0

**Attachments:**
- [maven-issue3.zip](https://issues.apache.org/jira/secure/attachment/12914731/maven-issue3.zip) (_4.12 kB_)

2 votes, 5 watchers

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.