alexgorbatchev

Tuesday, November 8, 2016

Publishing Grails 3 applications to Nexus Repository OSS using Gradle

To publish a Grails 3 application to Nexus Repository OSS you just need to make a few tweaks to the build.gradle file.  Just add the Gradle maven-publish plugin and a publishing closure to the build.gradle file and you are ready to push to your private Nexus Repository OSS server.

apply plugin:"maven-publish"
// Other closure blocks
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
repositories {
maven {
credentials {
username NEXUS_USERNAME
password NEXUS_PASSWORD
}
url "https://[my.nexus.repo]/repository/releases/"
}
}
}
view raw build.gradle hosted with ❤ by GitHub

Above, the NEXUS_USERNAME and NEXUS_PASSWORD are parameters that you store in gradle.properties and can overwrite with command line parameters, such as

./gradlew -PNEXUS_USERNAME=[your_username] -PNEXUS_PASSWORD=[your_password] publish
view raw command line hosted with ❤ by GitHub

No comments:

Post a Comment