Reputation: 4573
I have a project that has to build about 10 different dummy jars for unit testing. I have a gradle project setup like this
project(':CodeTools_dummydriver-true') {
ext.dummyDriver = true
archivesBaseName = "dummydriver-true"
}
But the problem is the jarfile is still named dummydriver-true-0.0.1.jar. Is there any way I can tell gradle to ignore the standard pattern and please name the output file what I want it to be named? Meaning, without the version number?
Upvotes: 16
Views: 16765
Reputation: 2725
Edit: For older Gradle versions.
The Java plugin defines the jar task to follow the following template for archiveName
:
${baseName}-${appendix}-${version}-${classifier}.${extension}
I don't think there's a way to apply a new "naming template", but what you can do is to explicitly set your jar task's archive name, like this. (Also, isn't it a good idea to use the dummyDriver
property directly, instead of hardcoding "true" into the archive name?)
archivesBaseName = "dummydriver"
jar.archiveName = "${jar.baseName}-${dummyDriver}.${jar.extension}"
Alternately, set the version
property to null or an empty string, like suggested in Circadian's answer, but if you ever want to use the version
property for anything, you don't want to destroy it.
Upvotes: 8
Reputation: 2983
For newer gradle you should use:
build.gradle.kts
:
tasks.jar {
archiveFileName.set("${project.name}-new-name.jar")
}
build.gradle
:
jar.archiveFileName = "new-name.jar"
Because archiveName
is deprecated. (You have to specify .jar
as well).
Upvotes: 11
Reputation: 579
Adding a version property and setting its value to an empty string worked for me.
Here is an example:
project(':CodeTools_dummydriver-true') {
ext.dummyDriver = true
archivesBaseName = "dummydriver-true"
version= ""
}
Hope that helps.
Upvotes: 3