Wednesday, August 17, 2011

Using Gradle with CloudBees' Maven Repository

CloudBees is one of the best current Platform as a Service providers. And it is one of the few (maybe only one) who provides tools such as Jenkins as a service too. Its Dev@cloud also provides 2GB free Maven repository which could be a perfect solutions for a lot of home-brewed libraries in your company. This article will show you how to use this free repository in Gradle builds.

Uploading to the repository
There are a lot of reasons why you should want to upload your library to the repository.  The most obvious one is managing the dependencies more easily. If you build your libraries with Gradle you can set up uploading to the CloudBees' Maven repository by adding a few more configuration to your build script.

Gradle to CloudBees

There is no magic about this configuration. You just have to use proper wagon library to support webdav protocol and use the right protocol in the URLs. If you write them manually you should check twice that you use "dav" not "webdav" as the protocol specification.
To upload your artifacts to the repository you just run gradle uploadArchives task.

Using the repository
Using the repository is little bit trickier because to make it work you must use the right server realm.
Using CloudBees repository in Gradle script

The only important part is setting the credentials. The resolver needs the same realm as the server which is "accountname repository".