I'm trying to use the java-platform
plugin to share dependency constraints in a multi-module project. What I would like to do is set up a module named platform
which I can import using platform(project(":platform"))
in other modules. Additionally I would like to import a BOM into my platform project using platform("group-id:of-the-bom:and-version")
.
An example is the following structure:
// settings.gradle
include("platform")
include("consumer")
// platform/build.gradle
apply plugin: 'java-platform'
repositories {
mavenCentral()
}
dependencies {
constraints {
api platform("org.wildfly.bom:wildfly-javaee8:15.0.1.Final")
}
}
// consumer/build.gradle
apply plugin: 'java-library'
repositories {
mavenCentral()
}
dependencies {
implementation platform(project(":platform"))
implementation "org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec"
}
When I run gradle consumer:dependencies
I get output containing the following:
compileClasspath - Compile classpath for source set 'main'.
+--- project :platform
\--- org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec FAILED
It seems as though the platform
module is not "re-exporting" constraints which were pulled in through the usage of platform()
.
I have found two "workarounds" which don't really solve my problem but seem to indicate that the issue is the usage of platform()
together with the java-platform
plugin:
- Replace
implementation platform(project(":platform"))
withimplementation platform("org.wildfly.bom:wildfly-javaee8:15.0.1.Final")
inconsumer/build.gradle
. - Put an explicit entry in
platform/build.gradle
such asapi org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec:1.0.1.Final
.
Is the java-platform
plugin not intended to be used in this way, or is there some configuration option I'm missing?