Message about archiveVersion seems misleading or incomplete...?

In my gradle.build, I have

 jar {
   manifest {     
     attributes 'Implementation-Title': 'JavaFBP', 'Implementation-Version':version,      
     "Class-Path": configurations.compileClasspath.collect { it.getName() }.join(' '),       
      'Main-Class' : mainClassName
    }          

and got this message:

The AbstractArchiveTask.version property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveVersion property instead. See AbstractArchiveTask - Gradle DSL Version 6.2 for more details.

However, when I changed ‘version’ to ‘archiveVersion’, the manifest in my jar file showed the wrong version number (using ‘version’ gives the correct version number). What am I missing?!

PS I am using Gradle 6.2.1 on a Win10 machine

Thanks!

1 Like

Just occurred to me: maybe I have to set archiveVersion explicitly - if so, does this mean that version and archiveVersion can have different values? If so, why?

Apparently archiveVersion only applies to the ‘jar’ task, not ‘publishing’… Anybody have an explanation? Also, the error message could have been a bit more explicit…!

I’ve been confused about this too. My understanding is that the top level version property is not deprecated, only the version property in the archive tasks. I believe the archiveVersion is automatically populated from the project.version (at least in a java project) but it sounds like you’re not seeing that?

You’re right, I didn’t see that. I am now using archiveVersion for jar file creation, and version for everything else. This seems to suggest that the Gradle designers want to allow these to be different… but why would they want to?

So what’s the fix? It isn’t clear how severe the error is.

"The AbstractArchiveTask.version property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveVersion property instead. See https://docs.gradle.org/6.2.2/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchi
veTask:version for more details."

It is refering to this version correct?
group = “com.blah.blah”
version = "1.0-SNAPSHOT"
buildDir = file(“out”)

How do you set the archiveVersion, AbstractArchiveTask().archiveVersion = doesn’t work.

This still seems confusing: in the jar section of my build.gradle I have
archiveVersion = '2.20.10'
manifest {
attributes 'Implementation-Title': ...', 'Implementation-Version': archiveVersion,'etc.

which seems pretty explicit, but I still have to fill in the manifest version no. by hand! Any idea why?!

I’ve been having the same issue, you only need to change “version” to “archiveVersion” inside the “jar{}” block.

Thanks, @exeba ! However, a few months ago I discovered that I could say project.version in my jar section, which simplifies things! Not sure if I can do that in my publishing section…?

You should be able to put the version outside the “jar” section, something like:

version = '0.0.1'
group = 'org.foo'

jar {
    manifest {
        attributes 'Implementation-Title': 'Foo', 'Implementation-Version': archiveVersion
    }
}

The jar task by default sets archiveVersion = project.version (‘0.0.1’)
The publishing section should do the same, i.e. taking the version from project.version unless you override it.

Thanks, @exeba, I’ll give that a try - it will have to wait until the next time I publish to Maven!

Season’s greetings!