Oh, Gradle, You Made My Heart Skip a Beat November 27, 2009 | 10:28 am

As I just mentioned, I’ve been working on some Gradle plugins. I’ve been using Gradle in my polyglot programming book, and there’s a stunt (namely, running Cucumber in a Java/Groovy/Scala build) that I’d like the user to be able to do without too much hassle. The easiest way is to say, “Hey, use this plugin and let the magic fly”.

In doing development, I’m spending some time pushing through integration tests, and in so doing, I wanted to deploy various versions to a Maven repository and pull them back down.

Creating a Maven repository for SmokejumperIT was pretty simple.

  1. Create a space on the internet for the repository which is accessible via public-key-authenticated SCP. In my case, it’s http://repo.smokejumperit.com.
  2. Create a configuration in the Gradle build file for the JARs needed to deploy:
    configurations {
    repositories {
      mavenRepo urls: "file://${System.properties['user.home']}/.m2/repository/"
    dependencies {
      deployerJars 'org.apache.maven.wagon:wagon-ssh:1.0-beta-2'

    Note: The part in the repositories block is in every build file that I have, so I’m working on a plugin (working title PreconfigPlugin) that will automatically add that in.

  3. Configure the uploadArchives task. I had it delegate to various System properties that I set when I run the build script.
    uploadArchives {
      repositories.mavenDeployer {
        def repoUser = System.properties['sjit.repo.user']
        configuration = configurations.deployerJars
        repository(url: "scp://repo.smokejumperit.com/home/$repoUser/repo.smokejumperit.com/") {
            userName: repoUser,
            privateKey: new File(System.properties['sjit.repo.keyFile']).absolutePath,
            passphrase: System.properties['sjit.repo.passphrase']
          pom {
  4. Run gradle upload.

That’s all it took. Even better, it does all the funky snapshot management on its own: see http://repo.smokejumperit.com/com/smokejumperit/gradle-plugins/0.2-SNAPSHOT/ for the beautiful timestamped results!

This is how builds should be: stupid-simple to do the right thing.

  • http://hamletdarcy.blogspot.com Hamlet D’Arcy

    I’d like to hear what you think about Gradle being the result of applying Evans-style Domain Driven Design to build systems. Is a strong domain model for enterprise projects really a great benefit?

  • Pingback: Blog bookmarks 03/24/2010 « My Diigo bookmarks