Wish I'd found your article yesterday - been battling this same change, and had already just about got there when I found it.
One thing I can't seem to get working is SNAPSHOT publishing to OSSRH - I get the following:
Failed to publish publication 'mavenJava' to repository 'maven'
Could not GET 'oss.sonatype.org/service/local/sta...
/com/ascert/open/openterm/1.6-SNAPSHOT/maven-metadata.xml'. Received status code
400 from server: Bad Request
Pretty sure Gradle is trying to list that location before publishing, and it's not a browsable URL.
Figured it out - nothing wrong in any of the above, but when using subprojects the 'version' gets evaluated for the root project not the subproject. Sorted it with the following:
ext {
...
// Make sure we have a default for initial configuration evaluation
isReleaseVersion = false
}
allprojects {
...
// When it comes to publishing we need to ensure we have the subproject version set
// rather than the root project version
afterEvaluate { project ->
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
}
}
...
repositories {
maven {
afterEvaluate { project ->
def releaseRepo = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotRepo = "https://oss.sonatype.org/content/repositories/snapshots/"
url = (isReleaseVersion) ? releaseRepo : snapshotRepo
credentials {
username = project.hasProperty('ossrhUsername') ? ossrhUsername : "Unknown user"
password = project.hasProperty('ossrhPassword') ? ossrhPassword : "Unknown password"
}
}
}
...
signing {
afterEvaluate { project ->
required { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
sign publishing.publications.mavenJava
}
}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Wish I'd found your article yesterday - been battling this same change, and had already just about got there when I found it.
One thing I can't seem to get working is SNAPSHOT publishing to OSSRH - I get the following:
Pretty sure Gradle is trying to list that location before publishing, and it's not a browsable URL.
Did you also hit this and/or figure a way around?
Figured it out - nothing wrong in any of the above, but when using subprojects the 'version' gets evaluated for the root project not the subproject. Sorted it with the following: