I have a root Gradle project with group id of org.name
and multiple sub-projects named org.name.one
, org.name.two
, org.name.three
.
Currently .jars are generated as one-1.0.jar
, two-1.0.jar
, three-1.0.jar
however I want them to be named name-one-1.0.jar
, name-two-1.0.jar
, name-three-1.0.jar
.
How can I achieve it using Kotlin DSL (build.gradle.kts files)?
I assume that you use shadow
plugin to package a fat jar.
If you use gradle shadow plugin, you can do something like the following to control the jar name:
tasks {
withType<ShadowJar> {
archiveBaseName.set("foo-${project.name}")
}
}
In case you have sub projects, you can apply to allprojects/subprojects:
allprojects {
tasks {
withType<ShadowJar> {
archiveBaseName.set("foo-${project.name}")
}
}
}