Gradle multiproject fails to find automatic-module-name with dependency on java-library.
See original GitHub issueI have a Gradle multi-project build. One subproject (bitcoinj-core
) is a Java 7 JAR with an Automatic-Module-Name manifest entry written in the jar
task. The other subproject (wallettemplate
) has a dependency on the Java 7 module declared as follows:
implementation project(':bitcoinj-core')
The build fails with the following error:
/path/bitcoinj/wallettemplate/src/main/java/module-info.java:19: error: module not found: org.bitcoinj.core
requires org.bitcoinj.core; // Automatic module
Because Gradle detects bitcoinj-core
is using the java-library
plugin, the wallettemplate
compile depends on the “class directory” output of bitcoinj-core
, not the jar with the needed manifest entry.
I would like to see one or more of the following solutions:
a. Java Modules Plugin to handle this case gracefully and automatically b. Java Modules Plugin to include documentation or example for how to avoid this problem c. Gradle itself to provide better documentation on this issue and its resolution.
For ©, I’m going to report the issue directly to Gradle.
For the failing build see: https://travis-ci.org/github/msgilligan/bitcoinj/jobs/679852675
This bitcoinj PR (see https://github.com/bitcoinj/bitcoinj/pull/1779) was building correctly until it was rebased on an updated master
branch where the bitcoinj-core
module had been updated from the Gradle, java
plugin to the java-library
plugin.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top GitHub Comments
I’m thinking of integrating the above solution in the Java Modules Plugin. It seems pretty safe and, as @jjohannes mentioned, Gradle 6.4 also performs this setting automatically.
I just noticed that @jjohannes also posted a solution, which is most likely the best one: