For future readers who stumble upon this question.
And magic phrase(s)
due to conflict in the snapshot release handling policy
IF you are publishing to the simple versions, most likely like this:
String repoKeyValue = version.endsWith('SNAPSHOT') ? 'libs-snapshot-local' : 'libs-release-local'
Then you probably will not get this error.
However, if you are trying to publish to a company wide full scale artifactory implementation, you might be publishing to something that looks more like this:
String repoKeyValue = version.contains('SNAPSHOT') ? 'MyCustomRepository-Snapshots/com/mycompany/mypackagename1/mypackagename2/' : 'MyCustomRepository-Releases/com/mycompany/mypackagename1/mypackagename2/'
So what is the issue?
When you publish with this (just below) configuration (full context of the configuration later in this question:
publishBuildInfo = true
publishPom = true
Artifactory is doing checking..to make sure what is the .pom's is consistent to your overall publish path name.
Hack fix: (immediately below code)
publishBuildInfo = false
publishPom = false
The real fix is to harmonize your com.mycompany.mypackage......blah.blah.blah names so that the artifactory naming consistency checks pass correctly.
The repository 'MyCustomRepository-Snapshots' rejected the resolution of an artifact 'MyCustomRepository-Snapshots:com/mycompany/mypackagenameNotQuiteRight999/myPackageNameNotQuiteRight888/my-thing-impl/1.0.60-SNAPSHOT-1601111703114/my-thing-impl-1.0.60-SNAPSHOT-1601111703114.jar'
due to conflict in the snapshot release handling policy. Status code: 409
So you'll get the above error, if you were trying publish to (see variable repoKeyValue above)
'MyCustomRepository-Snapshots/com/mycompany/mypackagename1/mypackagename2/'
BECAUSE (and this is the key thing to understand)... there is a disprepency between "com/mycompany/mypackagename1/mypackagename2/" and "com/mycompany/mypackagenameNotQuiteRight999/myPackageNameNotQuiteRight888/"
The above sentence is key-idea to understand to trouble shoot.
Artifactory (when you have publishPom and publishBuildInfo set to true) to checking for that consistency...(as far as I can tell)
Below is more fuller context of the magic attributes.
Note, I have a multi module gradle project and I do not want to publish the root project. #monolithsAreHorrible
(below is in my root build.gradle file)
artifactoryPublish.skip = true
artifactory {
contextUrl = "${artifactory_url}"
publish {
repository {
repoKey = "${repoKeyValue}"
username = "${artifactory_user}"
password = "${artifactory_password}"
}
defaults {
publications('myPublicationNameOne', 'myPublicationNameTwo', 'myPublicationNameThree')
publishArtifacts = true
publishBuildInfo = true
publishPom = true
}
}
}
Below is one of my module build.gradle files (they all look the same).
I have found the simpler I keep the publication (ex: "myPublicationNameOne"), the more sane I am when I get it all working in a harmonized way.
// the "name" variable inside the publications/myPublicationName block is getting overwritten. so create a variable here to capture the name (as the artifactid)
def artifactIdForPublicationBlockHolder = "${name}"
dependencies {
testImplementation group: 'junit', name: 'junit', version: junitVersion
}
println("hey.there.myPublicationNameOne")
println("group=${group}")
println("version=${version}")
println("artifactId=${name}")
publishing {
publications {
myPublicationNameOne(MavenPublication) {
// groupId, artifactId and version have defaults, so do not arbitrarily override : https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:publications
artifact "./build/libs/${artifactIdForPublicationBlockHolder}-${version}.jar"
}
}
}
Bonus Material:
See https://docs.gradle.org/current/dsl/org.gradle.api.publish.maven.MavenPublication.html about the publicationNames (if you are a first time learner, people using keywords for publicationName(s) threw me off for a while)
"gradle.settings" with artifactory:
https://www.jfrog.com/confluence/display/JFROG/Working+with+Gradle#WorkingwithGradle-ConfiguringGradle
timestamp on artifactId
How to add timestamp for artifacts in Jenkins
DEBUG TIP:
Purposely set your target artifactory to:
String repoKeyValue = version.endsWith('SNAPSHOT') ? 'doesnotexist-libs-snapshot-local' : 'doesnotexist-libs-release-local'
(it will fail, but that's ok temporarily)
and try to run the artifactory push locally:
in gradle it is (or could be based on your set up):
./gradlew clean build artifactoryPublish
This will at least show you what it is trying to "push".
You'll see a failure like this:
[pool-1-thread-1] Deploying artifact: https://somewhere.com/artifactory/MY-Snapshots/com/mycompany/mypackagenameNotQuiteRight999/myPackageNameNotQuiteRight888/1.0-SNAPSHOT/myPackageNameNotQuiteRight888-1.0-SNAPSHOT.jar
Failed to upload file
BUT it shows you what it is trying to "push" and you can harmonize from there.