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
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
}
}
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With