Hi,
I’m using the Oracle JDK 14 and Gradle 6.6. I have a java project consisting of the following three java modules that I want to build with gradle:
./db/src/main/java/mileage.db/module-info.java
./db/src/main/java/mileage.db/mileage/db/Db.java
./gui/src/main/java/mileage.gui/module-info.java
./gui/src/main/java/mileage.gui/mileage/gui/Gui.java
./app/src/main/java/mileage.app/module-info.java
./app/src/main/java/mileage.app/mileage/app/App.java
Both the mileage.db and the mileage.gui module export their (currently only) package to mileage.app, hence the module-info.java file reads:
module mileage.db {
exports mileage.db to mileage.app;
}
The GUI package has a similar module-info.java file.
I can build the project by hand, using the follwing commands:
javac -d build/classes/ --module-source-path app/src/main/java/:db/src/main/java:gui/src/main/java db/src/main/java/mileage.db/module-info.java db/src/main/java/mileage.db/mileage/db/Db.java
javac -d build/classes/ --module-source-path app/src/main/java/:db/src/main/java:gui/src/main/java gui/src/main/java/mileage.gui/module-info.java gui/src/main/java/mileage.gui/mileage/gui/Gui.java
javac -d build/classes/ --module-source-path app/src/main/java/:db/src/main/java:gui/src/main/java app/src/main/java/mileage.app/module-info.java app/src/main/java/mileage.app/mileage/app/App.java
But I can’t seem to write working gradle build files for this project. After much searching and trying, I can compile the source code into class files, but I keep getting the warning:
> Task :db:compileJava
/home/doppelfish/workspace/Mileage/db/src/main/java/mileage.db/module-info.java:2: warning: [module] module not found: mileage.app
exports mileage.db to mileage.app;
^
1 warning
and a similar warning for the GUI package.
I suspect that I need to tell gradle to give the java compiler the “–module-source-path” option followed by al three source paths when it compiles the source of one module. Is that the issue? And if so, how could I resolve it?
Also, comments on the directory structure would be welcome.
cheers,
doppelfish