Module dependences inside a Java multi-module build


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:


Both the mileage.db and the mileage.gui module export their (currently only) package to, hence the file reads:

module mileage.db {
        exports mileage.db to;

The GUI package has a similar 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/ db/src/main/java/mileage.db/mileage/db/
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/ gui/src/main/java/mileage.gui/mileage/gui/
javac -d build/classes/ --module-source-path app/src/main/java/:db/src/main/java:gui/src/main/java app/src/main/java/ app/src/main/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/ warning: [module] module not found:
        exports mileage.db to;
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.