modulepath and classpath mixture
Robert Scholte
rfscholte at apache.org
Tue Feb 23 21:12:27 UTC 2016
On Tue, 23 Feb 2016 01:30:16 +0100, Alex Buckley <alex.buckley at oracle.com>
wrote:
> Hi Robert,
>
> On 2/22/2016 12:44 PM, Robert Scholte wrote:
>> Here's my use case: I noticed that if I add a module-info to
>> src/main/java and put all compile-scoped dependencies to the module
>> path, all compiles fines.
>
> Sounds good.
>
>> I assume that developers are less interested in adding a
>> module-info.java file to src/test/java, so that's what I'm doing right
>> now too.
>
> To clarify: you are NOT putting module-info.java in src/test/java.
>
>> Now it seems that I *must* add compile + test scoped to the *classpath*
>> to be able to compile the test classes.
>> My first approach was to leave the compile-scoped dependencies on the
>> modulepath and all test-scoped dependencies on the classpath, so the
>> modules keeps their inner related structure, but it seems that the
>> classpath classes cannot access the modulepath classes.
>
> Your first approach sounds preferable. Can you copy-paste a minimized
> invocation of javac that works, and that doesn't work?
>
> Alex
Here's the debug output when calling 'mvn test'.
This doesn't work:
[DEBUG] Classpath:
[DEBUG]
E:\java-workspace\apache-maven-maven\maven\maven-builder-support\target\test-classes
[DEBUG] C:\Users\Robert
Scholte\.m2\repository\junit\junit\4.12\junit-4.12.jar
[DEBUG] C:\Users\Robert
Scholte\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar
[DEBUG] Modulepath:
[DEBUG]
E:\java-workspace\apache-maven-maven\maven\maven-builder-support\target\classes
[DEBUG] C:\Users\Robert
Scholte\.m2\repository\org\codehaus\plexus\plexus-utils\3.0.22\plexus-utils-3.0.22.jar
[DEBUG] C:\Users\Robert
Scholte\.m2\repository\org\apache\commons\commons-lang3\3.4\commons-lang3-3.4.jar
[DEBUG] Source roots:
[DEBUG]
E:\java-workspace\apache-maven-maven\maven\maven-builder-support\src\test\java
[DEBUG]
E:\java-workspace\apache-maven-maven\maven\maven-builder-support\target\generated-test-sources\test-annotations
[DEBUG] Command line options:
[DEBUG] -d
E:\java-workspace\apache-maven-maven\maven\maven-builder-support\target\test-classes
-classpath
E:\java-workspace\apache-maven-maven\maven\maven-builder-support\target\test-classes;C:\Users\Robert
Scholte\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\Robert
Scholte\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;
-modulepath
E:\java-workspace\apache-maven-maven\maven\maven-builder-support\target\classes;C:\Users\Robert
Scholte\.m2\repository\org\codehaus\plexus\plexus-utils\3.0.22\plexus-utils-3.0.22.jar;C:\Users\Robert
Scholte\.m2\repository\org\apache\commons\commons-lang3\3.4\commons-lang3-3.4.jar;
-sourcepath
E:\java-workspace\apache-maven-maven\maven\maven-builder-support\src\test\java;E:\java-workspace\apache-maven-maven\maven\maven-builder-support\target\generated-test-sources\test-annotations;
-s
E:\java-workspace\apache-maven-maven\maven\maven-builder-support\target\generated-test-sources\test-annotations
-g -nowarn -target 1.9 -source 1.9 -encoding UTF-8
Result:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR]
/E:/java-workspace/apache-maven-maven/maven/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java:[25,41]
package org.apache.maven.building.Problem does not exist
[ERROR]
/E:/java-workspace/apache-maven-maven/maven/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java:[24,41]
package org.apache.maven.building.Problem does not exist
followed by a lot of 'cannot find symbol'.
If all modulepath entries were added to the classpath instead, then it
compiles fine.
thanks,
Robert
More information about the jigsaw-dev
mailing list