Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gradle maven-publish plugin adds timestamp, how to avoid putting it into suffix

I'm using the 'maven-publish' plugin by gGradle and it putting a suffix after actual version, which I want to avoid. because in the next step of my CI it trying to download the .jar and the curl command is downloading nothing.

I can connect to my nexus and upload via ./gradlew publish Optional<VERSION=0.0.1> but the plugin (I think) is added a timestamp, is looking like this:

a/b/c/ARTIFACT-NAME/0.0.1-SNAPSHOT/ARTIFACT-NAME-0.0.1-20190114.134142-8.jar

How can I disable the feature of timestamp in the plugin?

That's my publishing task:

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
    repositories {
        maven {
            if (project.version.endsWith('-SNAPSHOT')) {
                url deployNexusSnapshotUrl
            } else {
                url deployNexusReleaseUrl
            }
            credentials {
                username = deployNexusUsername
                password = deployNexusPassword
            }
        }
    }
}
like image 842
imalik8088 Avatar asked Jan 14 '19 13:01

imalik8088


1 Answers

That's because you are publishing a SNAPSHOT version. This timestamp is a feature that allows to distinguish between different snapshot builds e.g. to use them for limited period of time and purge them later. It won't happen when you release a proper artifact version that doesn't use -SNAPSHOT suffix.

For the sake of CI build reproducibility you should never use SNAPSHOT dependencies when you are building software on CI. SNAPSHOT versions can be overridden especially if you disable the timestamp in the version.

What if there were no code changes in your project, the CI build was green but on the next day someone overwrites a SNAPSHOT dependency in repository and the build is now red? What if on the next day you have to release a hotfix to resolve urgent production issue but instead you have to focus on a problem introduced by new SNAPSHOT dependency.

You are trying to solve the wrong problem. SNAPSHOT is intended for local development only.

like image 180
Karol Dowbecki Avatar answered Sep 19 '22 13:09

Karol Dowbecki