I recently had a request from a customer for some guidance on how to automate Staging in Nexus Professional from Gradle. Here was his core problem: he had a series of builds that needed to deploy to a staging URL and he was wondering if it was possible to automate the closing of a repository from Gradle. It is. While we’ve made it easy to do this in Maven with the Nexus Maven Plugin we didn’t have the equivalent example in Groovy. This post gives some guidance to anyone who needs to call out to our REST services from Groovy.
As Nexus Professional exposes every feature as a REST endpoint it is very easy to automate these interactions in just about any language. This sample demonstrates who to incorporate calls to Nexus REST APIs directly from your build. It also provides a model for parsing JSON responses from Nexus and posting JSON requests. If you are interested in more of these examples, please let us know in the comments of this post. (One thing is sure, this particular example could use some improvement, please be harsh.)
Last week when we published a Gradle-specific evaluation guide for Nexus Professional I failed to mention that Gradle also works well with Nexus OSS. Here are some simple Knowledge Base entries from our Support portal that put the details into how to publish and consume artifacts using Gradle and Nexus:
In support of this week’s release of Gradle 1.0, here’s an evaluation guide for Nexus Professional using two, very simple Gradle projects. If you are evaluating Nexus Professional, or if you are just looking for some sample projects that configure a Gradle build to use a repository take a look at this guide. Take a look at this evaluation guide and download the associated sample projects. These two projects have build.gradle files that demonstrate the simplest case of configuring a Gradle build to:
- Download dependencies from a Nexus Repository Group with Gradle
- Deploy an Artifact to a Nexus Snapshot Repository from Gradle
- Staging an Artifact to a Nexus Staging Repository from Gradle
Update 2013-05: The evaluation guide has been updated and is now available in HTML and PDF format.
Sonatype makes it easy to add your projects to the Central Repository with a free, public hosting service called OSSRH, that we recently wrote about here. Many developers have found this a very useful service and easy to use with Apache Maven. However, if you’ve started using Gradle, you may have wondered if you could continue using the service. The answer is absolutely YES.
We were talking about creating a guide for this, but someone in the community beat us to it. Yennick Trevels published an excellent guide in his blog that you can find here. We highly recommend checking out his post if you want to use Gradle to deploy artifacts to the Central Repository.