I am trying to make BOM (Bill of materials POM) using Gradle’s java-platform
plugin and wish to use Gradle’s locking feature alongside with that plugin: I want to keep versions always up-to-date.
This is part of my build.gradle
file.
plugins {
id "java-platform"
id "maven-publish"
}
javaPlatform {
allowDependencies()
}
dependencyLocking {
lockAllConfigurations()
lockMode = LockMode.STRICT
}
... skipped ...
dependencies {
constraints {
api("com.graphql-java:graphql-java:${library_graphql_version}")
api("com.graphql-java:java-dataloader:${library_graphqlDataloader_version}")
// Redisson
api("org.redisson:redisson-hibernate-53:${library_redisson_version}")
api("org.redisson:redisson-spring-boot-starter:${library_redisson_version}")
api("org.redisson:redisson-spring-data-23:${library_redisson_version}")
}
}
publications {
some(MavenPublication) {
from components.javaPlatform
afterEvaluate {
pom {
name = 'BOM'
description = 'Bill of Materials (BOM)'
}
}
}
}
... skipped ...
gradle.properties
file
library_graphql_version=14.+
library_graphqlDataloader_version=2.+
library_redisson_version=3.+
And when I execute generatePomFileForSomePublication
task it is translated to the following POM fragment:
... skipped ...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>14.+</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>java-dataloader</artifactId>
<version>2.+</version>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-hibernate-53</artifactId>
<version>3.+</version>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.+</version>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-data-23</artifactId>
<version>3.+</version>
</dependency>
</dependencies>
</dependencyManagement>
... skipped ...
Obviously, there are plus
signs that shouldn’t be in resulting POM. It means, that dependency resolution doesn’t work for java-platform
constraints.
So the question is how can I make that dependency resolution work for these constraints
?