I am using shadowJar plugin to build/create my fatJar . Inside my build.gradle I have this
shadowJar{
mergeServiceFiles('META-INF/spring.*')
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
exclude "META-INF/LICENSE"
}
Using gradle shadowJar creates my fat jar . However the name of the fat jar created is something sample-SNAPSHOT-ns.r100-all.jar . I want to change it to sample-SNAPSHOT-ns.r100-deploy.jar . How do u overwrite jar Name using ShadowJar.
The ShadowJar plugin provides a Jar task extension. Configure it using the archiveFileName property, such as:
shadowJar{
mergeServiceFiles('META-INF/spring.*')
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
exclude "META-INF/LICENSE"
archiveFileName = "sample-${classifier}-ns.r100-deploy.${extension}"
}
You can use placeholders like ${baseName}
, ${appendix}
, ${version}
, ${classifier}
and ${extension}
.
Note that archiveName
is now archiveFileName
, as of ShadowJar version 4.
For people looking how to do this with the Kotlin DSL it this:
tasks.withType<ShadowJar> {
archiveFileName.set("${archiveBaseName}-${archiveVersion}-${archiveClassifier}.${archiveExtension}")
}
combining the answers of @richard and @christian-dräger
tasks.withType<ShadowJar> {
archiveFileName.set("${project.name}-${project.version}.jar")
}
this outputs the format myProject-0.0.1.jar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With