How to upgrade this commands to gradle 5.x

Hello, I have this code:

`
jar { manifest { attributes(

            'Implementation-Title': 'IpDiff', 
            'Implementation-Version': project.version, 
            'Application-Name': 'IpDiff',
            'Built-Date': LocalDateTime.now(),
            'Main-Class': mainClassName,
            'Permissions': 'all-permissions',
            'Built-Java': System.getProperty('java.version'),
            'Class-Path': configurations.compile.collect { it.getName() }.join(' ')
    )
    baseName = project.name
    archiveName = 'program.jar'
}

}
`

But since gradle 5.x, baseName and archiveName are deprecated. How can I upgrade that to the new standard? I need to set the jar name without a version number attached.

Have you considered looking at the documentation?

https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Jar.html

https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/bundling/Jar.html

Yes, already try using that documentation, without success, thatā€™s why I asked over here.
I already tried: archivesBaseName, archiveFileName, but it always add the version at the end. I want the same as before.

The docs for archiveFileName state

The archive name. If the name has not been explicitly set, the pattern for the name is: [archiveBaseName]-[archiveAppendix]-[archiveVersion]-[archiveClassifier].[archiveExtension]

So you should be able to set archiveFileName if you donā€™t want to use the conventions

1 Like

I donā€™t know why, but I already tried that without success, but today it work just fineā€¦ maybe intelliJ ignore my gradle updatesā€¦ Thanks

I upgrade to gradle 5.3. Now it says:

Could not set unknown property ā€˜archiveFileNameā€™ for task ā€˜:finalFatJarā€™ of type org.gradle.api.tasks.bundling.Jar.

But the documentation does not state ā€œdeprecatedā€. It works using 5.2.x

1 Like

Sorry for reviving an old discussion, but the question does not seem to be resolved.

It is not possible to set the archiveFileName - I get the error Val cannot be reassigned (gradle 6.0.1). And the documentation does not indicate how to modify the value otherwise.

I find that this works:

val jar: Jar by tasks
jar.apply {
    project.setProperty("archivesBaseName", "blabla")
    manifest {
        attributes["Implementation-Title"] = "Jar File -all Example"
        attributes["Implementation-Version"] = version
        attributes["Main-Class"] = "com.example.App"
    }
    from(configurations["runtimeClasspath"].map({file -> project.zipTree(file) }))
}