javac, modular builds mixed with some gradle.

David Hill David.Hill at
Tue Aug 23 20:57:05 UTC 2016

I am trying to understand module compilation using a trivial set of classes. These comprise a "module" of two classes, a test class, and a "shim" test class. (The shim is an adapter used for 'white box' style tests).
On top of this, I am trying this with Gradle 3.

So far, I have made some interesting progress. For the "simple" case, Gradle 3 seems to be handling the required tasks nicely. A 'simple' module and set of public api test classes works without much effort.  Certainly Gradle has a few more fixes to go, for example its insistence on stuffing
     -sourcepath /some/empty/directory
in some compilations, which collides with my addition of --module-source-path
Mostly however, I have just be able to tack on additional JDK 9 arguments.

I am currently trying to understand how I can best compile my shim classes. In my current build, I perform a non-modular build of the module classes, and then the shim classes, and then combine the sum of them together and call it a module :-) This is a stopgap until we can rework to create a proper modular build.

The item that currently puzzles me is an invocation of javac (b132) with a list of a single file to be compiled that ends up compiling everything within the module-source-path. I would have expected that only the listed files would be compiled. Below is the extracted compile line (with -sourcepath removed).

Any thoughts or suggestions are welcome.

Anyone else interested in my Gradle module quickstart demo let me know off list and I will point you to a copy when I get past this hump.

/Users/ddhill/shared/jdk9/osx-x64/jdk-9.jdk/Contents/Home//bin/javac -verbose \
-d \
/Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/shims \
-g \
-release \
9 \
--module-path /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/main/dave \
--add-modules dave \
--module-source-path '/Users/ddhill/shared/gradle/module-quickstart/modules/*/src/{main,test}/{java,module-info}' \
-classpath \
/Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/test:/Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/resources/test:/Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/main:/Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/resources/main:/Users/ddhill/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar:/Users/ddhill/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar \
/Users/ddhill/shared/gradle/module-quickstart/modules/dave/src/test/java/org/dave/ \

and yet the result is more classes than the ListShim that was listed:
[ddhill module-quickstart]$ find /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/shims

David Hill<David.Hill at>
Java Embedded Development

"A man's feet should be planted in his country, but his eyes should survey the world."
-- George Santayana (1863 - 1952)

More information about the jigsaw-dev mailing list