Gradle rename artifactory jar before publishing latest one


(Arun) #1

I am new to gradle & artifactory.I am trying to rename a Jar in artifactory before publishing the latest one.

Can some one help me how we can achieve this using gradle.

Thanks.


(Chris Doré) #2

Typically you would be publishing a new jar under the same group and artifact IDs, but a new version.

What is your use case that requires the rename of the existing jar?


(Arun) #3

@Chris_Dore my project requirements is I need to maintain 3 version of jar [1.0, 2.0, 3.0 jar] 3.0 will be the latest each time.when the new 3.0 jar is published I need to replace 3.0 to 2.0 & 2.0 to 1.0 & this New publish will be 3.0 jar.so that I can have two version of jars in my backup.

Thanks.


(Arun) #4

@Chris_Dore please input your suggestions on this.how we can achieve it using gradle…

Thanks.


(Chris Doré) #5

You could use the Artifactory REST API to perform the required operations before publishing the new artifact. JFrog also has a Java library.

tasks.yourPublishTask.doFirst {
    // do necessary Artifactory API calls to copy previous versions
}

(Chris Doré) #6

Wouldn’t publishing new versions of the artifacts also leave you with the ability to go back in time to older versions, but without the extra hassle? I’m sure you have reasons for wanting to do what you are asking, I’m just curious and interested in why you’d like to change the content of past artifact versions. It’s intriguing because it’s the total opposite of what we do. If I changed an old version of one of our artifacts to be something different I’d have a large number of people crashing down my door with pitchforks in hand :slight_smile: