Maven-publish doesn't pick up correct name for jar or zip artifacts

(Scott Palmer) #1

I am using the newer maven-publish plugin and the ‘townsfolk’ gradle-release plugin.

I noticed that when the release plugin removes -SNAPSHOT from my project version that it didn’t update the names used for Jar files. So I added a step to change the name used by the jar files:

confirmReleaseVersion << {

println “Setting artifact versions to ${project.version}”

jar.version = project.version

javadocJar.version = project.version

schemaZip.version = project.version


That works to create the jars and zips with the correct version, but it makes the publish step fail because it tries to read from the file path with the old version number instead of the file that the jar/zip tasks actually created.

(Scott Palmer) #2

I’ve tried working around this various ways. E.g. letting the local jars be created with the wrong -snapshot name but using a closure to set the version of the artifact so it will be uploaded correctly, but I can’t get anything to work. A closure can’t be used to configure the artifact version - the publish task starts looking for a filename with a name ending in


The idea of stripping off -snapshot and deploying to a repo as part of a release is pretty basic. How do you do it?

(Scott Palmer) #3

So it turns out I don’t need to re-write the version number for the jars with my doLast on confirmReleaseVersion… that part seems to be working without my hack… but maven-publish still fails to see the correct name of the jar because the version is changed after it decides what the name must be.