Oh, Gradle, You Made My Heart Skip a Beat

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 {
        deployerJars
    }
     
    repositories {
      mavenRepo urls: "file://${System.properties['user.home']}/.m2/repository/"
      mavenCentral()
    }
    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/") {
          authentication(
            userName: repoUser,
            privateKey: new File(System.properties['sjit.repo.keyFile']).absolutePath,
            passphrase: System.properties['sjit.repo.passphrase']
          )
          pom {
            groupId='com.smokejumperit'
            artifactId='gradle-plugins'
            version='0.2-SNAPSHOT'
          }
        }
      }
    }
  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.

This entry was posted in Groovy, Open Source. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Posted November 27, 2009 at 11:23 AM | Permalink

    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?

One Trackback

  1. By Blog bookmarks 03/24/2010 « My Diigo bookmarks on March 23, 2010 at 11:30 PM

    [...] Oh, Gradle, You Made My Heart Skip a Beat [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">