apache / apache/maven-compiler-plugin
[MCOMPILER-354] Module patching fails: case of simple single-module project
- Dominant language
- Java
- Stars
- 261
- Forks
- 191
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 8
Description
**[foo bar](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=vandekeizer)** opened **[MCOMPILER-354](https://issues.apache.org/jira/browse/MCOMPILER-354?redirect=false)** and commented
Sometimes it can be difficult to setup maven test-scoped dependencies in a Maven multi-module project. But I think I managed to find a simple 1-module case where module patching doesn't work.
I have a single-module Java 10 project where the testCompile goal complains that Test Class A doesn't read Test Class B, which is in the same project! (but in a different package)
Of course, a class shouldn't need to be exported to a class of the same module. So maybe there is a confusion somewhere between the unnamed module, automatic modules, and explicit modules.
I think that's because of a bug in the module-patching flags passed by testCompile to javac.
My project source tree, in its simplified branch to reproduce the issue, looks shown in the project.png attachment.
Full log is attached as well as a zip of the issue reproduction branch. It can also be cloned from:
```java
git clone https://github.com/vandekeiser/wires.git
git checkout REPORT-MCOMPILER-2
mvn clean install
```
The flags testCompile pass to javac.
```java
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ wires-support ---
[DEBUG] Command line options:
-d G:\projets\wires\wires\wires\wires-support\target\test-classes
-classpath G:\projets\wires\wires\wires\wires-support\target\test-classes;
--module-path G:\projets\wires\wires\wires\wires-support\target\classes;
-sourcepath G:\projets\wires\wires\wires\wires-support\src\test\java;
G:\projets\wires\wires\wires\wires-support\target\generated-test-sources\test-annotations;
-s G:\projets\wires\wires\wires\wires-support\target\generated-test-sources\test-annotations
-g -deprecation -target 10 -source 10 -encoding UTF-8 -Werror -Xlint:all,-serial
--patch-module fr.cla.wires.support=
G:\projets\wires\wires\wires\wires-support\target\classes;
G:\projets\wires\wires\wires\wires-support\src\test\java;
G:\projets\wires\wires\wires\wires-support\target\generated-test-sources\test-annotations;
--add-reads fr.cla.wires.support=ALL-UNNAMED
```
The warning I get (which for me is an error):
```java
[WARNING] /G:/projets/wires/wires/wires/wires-support/src/test/java/fr/cla/wires/support/DoesntCompile.java:[14,20]
class fr.cla.wires.support.javac_complains_this_is_not_exported.JavacComplainsThisIsNotExported
in module fr.cla.wires.support
is not exported
[ERROR] COMPILATION ERROR :
warnings found and -Werror specified
[INFO] 1 error
```
---
**Affects:** 3.7.0
**Attachments:**
- [mvn-X-clean-install-FAILURE.log](https://issues.apache.org/jira/secure/attachment/12933472/mvn-X-clean-install-FAILURE.log) (_98.14 kB_)
- [project.png](https://issues.apache.org/jira/secure/attachment/12933474/project.png) (_98.54 kB_)
- [wires.zip](https://issues.apache.org/jira/secure/attachment/12933473/wires.zip) (_1.40 MB_)
Contributor guide
No contributing guide indexed for this repository
Research direction
Clone the wires reproduction branch REPORT-MCOMPILER-2 and run `mvn clean install` to reproduce the testCompile failure. Inspect the Maven compiler plugin's testCompile handling and the javac flags shown in the issue, especially --patch-module and --add-reads. Done means the single-module Java 10 project compiles without the non-exported-class warning under -Werror.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100