I managed to get it to work with the maven-publish plugin, but it’s definitely a quirk in the plugin.
This does not work:
apply plugin: 'maven-publish'
apply plugin: 'application'
group = "com.mycompany"
version = project.properties.containsKey("releaseVersion") ? "${releaseVersion}" : "0.0.1-SNAPSHOT"
project.ext {
artifactoryRepo = project.properties.containsKey("releaseVersion") ? "libs-release-local" : "libs-snapshot-local"
}
publishing {
repositories {
maven {
credentials {
username "${artifactoryUser}"
password "${artifactoryPassword}"
}
url "${artifactoryUrl}/${artifactoryRepo}"
}
}
publications {
myPublication(MavenPublication) {
artifact source: distZip, extension: "zip"
artifact source: someOtherDistZip, classifier: "dumdeedum", extension: "zip"
}
}
}
But this if you change “publishing” with “publishing.repositories” and “publishing.publications”, then it does work:
apply plugin: 'maven-publish'
apply plugin: 'application'
group = "com.mycompany"
version = project.properties.containsKey("releaseVersion") ? "${releaseVersion}" : "0.0.1-SNAPSHOT"
project.ext {
artifactoryRepo = project.properties.containsKey("releaseVersion") ? "libs-release-local" : "libs-snapshot-local"
}
publishing.repositories {
maven {
credentials {
username "${artifactoryUser}"
password "${artifactoryPassword}"
}
url "${artifactoryUrl}/${artifactoryRepo}"
}
}
publishing.publications {
myPublication(MavenPublication) {
artifact source: distZip, extension: "zip"
artifact source: someOtherDistZip, classifier: "dumdeedum", extension: "zip"
}
}
There are some other posts about the same problem: