Hi,
my project has a single module, but i have some dependencies with multiple artifacts for which i need to align the versions.
Some examples:
Here there are 3 different artifacts, for which i want to use the same version:
runtimeOnly("com.github.gotson.nightmonkeys:imageio-jxl:1.0.0")
runtimeOnly("com.github.gotson.nightmonkeys:imageio-heif:1.0.0")
runtimeOnly("com.github.gotson.nightmonkeys:imageio-webp:1.0.0")
Here i want to use the same version for different configurations:
implementation("org.xerial:sqlite-jdbc:3.50.2.0")
jooqGenerator("org.xerial:sqlite-jdbc:3.50.2.0")
I have read the documentation about the Version Catalog, however i don’t necessarily want to have to define aliases, this would add unnecessary complexity. I like to see the different artifacts used in my build.gradle
, but i want to centralize versions so i don’t write them multiple times.
I tried the following, but it doesn’t work:
in .gradle/libs.versions.toml
:
[versions]
sqlite-jdbc = "3.50.2.0"
nightmonkeys = "1.0.0"
In build.gradle
:
runtimeOnly("com.github.gotson.nightmonkeys:imageio-jxl:${libs.versions.nightmonkeys}")
runtimeOnly("com.github.gotson.nightmonkeys:imageio-heif:${libs.versions.nightmonkeys}")
runtimeOnly("com.github.gotson.nightmonkeys:imageio-webp:${libs.versions.nightmonkeys}")
implementation("org.xerial:sqlite-jdbc:${libs.versions.sqlite.jdbc}")
jooqGenerator("org.xerial:sqlite-jdbc:${libs.versions.sqlite.jdbc}")
Why can’t this work ?
And if it cannot work, is there another way to do that in Gradle ?
Currently i am doing this in Kotlin Script:
run {
val luceneVersion = "9.9.1"
implementation("org.apache.lucene:lucene-core:$luceneVersion")
implementation("org.apache.lucene:lucene-analysis-common:$luceneVersion")
implementation("org.apache.lucene:lucene-queryparser:$luceneVersion")
implementation("org.apache.lucene:lucene-backward-codecs:$luceneVersion")
}
But it is a bit limited, for instance i cannot align a plugin version with a dependency version.
In addition, i would like to use the centralized version inside some plugin configuration, for example the gradle-jooq-plugin can be configured with the desired jooq version, which i could centralize, but the version has to be used inside the plugin configuration:
jooq {
version = "3.19.24"
}
Is that something the Version Catalog can solve ?