I'm creating gradle builds as a new gradle user, but I have worked with maven in the past.
I'm trying to reproduce actions of the maven release plugin:
As you can see, I'm using:
I'm trying to achieve my objectives with these two plugins:
Gradle-release Plugin:
Command line: gradle release
Maven Publish Plugin to deploy to Nexus:
Command line: gradle publish
Any ideas how I could generate a release and automatically deploy it to Nexus in one shot?
Below is my build.gradle:
plugins {
id 'net.researchgate.release' version '2.3.4'
}
apply plugin: 'maven-publish'
/*------------------------
----- PUBLISH PLUGIN -----
--------------------------
https://docs.gradle.org/current/userguide/publishing_maven.html
--------------------------*/
publishing {
publications {
maven(MavenPublication) {
groupId mavenGroup
artifactId mavenArtifact
version version
from components.java
}
}
repositories {
maven {
if(project.version.endsWith('-SNAPSHOT')) {
url "${nexusUrl}/content/repositories/repo-snapshots"
} else {
url "${nexusUrl}/content/repositories/repo-releases"
}
credentials {
username nexusUsername
password nexusPassword
}
}
}
}
/*------------------------
----- RELEASE PLUGIN -----
--------------------------
https://github.com/researchgate/gradle-release
--------------------------*/
release {
failOnCommitNeeded = false
failOnUnversionedFiles = false
scmAdapters = [
net.researchgate.release.SvnAdapter
]
}
You need to setup a dependency between the two tasks. This can be done by adding this line in your build.gradle
:
afterReleaseBuild.dependsOn publish
The release-plugin has two tasks which are exactly for the usecase of hooking other tasks in the release process, namely beforeReleaseBuild
and afterReleaseBuild
. This tasks (and the dependencies you set) are executed before or respectively after the build
task.
https://github.com/researchgate/gradle-release#custom-release-steps
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