I’m trying to set up two projects with Gradle to perform releases and publish the results to a Nexus repository server. Both are failing with a similar problem - the release step is working, and the “SNAPSHOT” version is replaced by the released version, and committed and pushed to git, but the publish step is not doing anything / not running.
The setup I’m trying to achieve is:
- Local (snapshot) builds should be published to local Maven cache.
- Release (CI) builds should be published to our Nexus repository server.
My build.gradle:
plugins {
id 'java'
id 'net.researchgate.release' version '2.8.1'
id 'maven-publish'
}
group 'com.something'
repositories {
mavenLocal()
mavenCentral()
maven {
url = uri('http://nexus:8080/repository/myrepo/')
allowInsecureProtocol = true
}
}
java {
withSourcesJar()
}
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
}
// publish every build to local maven, to enable local testing
publishToMavenLocal.dependsOn(check)
build.dependsOn(publishToMavenLocal)
// publish release builds to Nexus
afterReleaseBuild.dependsOn publish
Sample log output:
Task :release
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:check
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:generateMetadataFileForMavenPublication
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:generatePomFileForMavenPublication
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:publishMavenPublicationToMavenLocal
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:publishToMavenLocal
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:build
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:publish UP-TO-DATE
Task :CPA-GJAP-JOB1:CPA-GJAP-JOB1:afterReleaseBuild UP-TO-DATE
Task :CPA-GJAP-JOB1:runBuildTasks
Task :CPA-GJAP-JOB1:preTagCommit
Task :CPA-GJAP-JOB1:createReleaseTag
Task :CPA-GJAP-JOB1:checkoutMergeFromReleaseBranch SKIPPED
Task :CPA-GJAP-JOB1:updateVersion
Task :CPA-GJAP-JOB1:commitNewVersion
Task :compileJava UP-TO-DATE
Task :processResources NO-SOURCE
Task :classes UP-TO-DATE
Task :jar
Task :sourcesJar
Task :assemble
Task :compileTestJava UP-TO-DATE
Task :processTestResources UP-TO-DATE
Task :testClasses UP-TO-DATE
Task :test UP-TO-DATE
Task :check UP-TO-DATE
Task :generateMetadataFileForMavenPublication
Task :generatePomFileForMavenPublication
Task :publishMavenPublicationToMavenLocal
Task :publishToMavenLocal
Task :build
The publish task appears to show as UP-TO-DATE. What am I missing?
Gradle version: 7.4