Want to specify jar name and version both in build.gradle

For Gradle 5+

build.gradle groovy DSL

archiveBaseName = 'foo'

build.gradle.kts kotlin DSL

archivesBaseName.set("foo") // Notice the double quotes

archiveName 'abc.jar' in your jar configuration is forcing the name to be 'abc.jar'. The default format for the jar name is ${baseName}-${appendix}-${version}-${classifier}.${extension}, where baseName is the name of your project and version is the version of the project. If you remove the archiveName line in your configuration you'll have the format you're after. If you want the name of the archive to be different from the project name set the baseName instead, e.g.

jar {
    manifest{
        attributes ("Fw-Version" : "2.50.00", "${parent.manifestSectionName}")
    }
    baseName 'abc'
}

See https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Jar.html#org.gradle.api.tasks.bundling.Jar:archiveName for more info on configuring the jar task.

Tags:

Java

Gradle