Oh, Gradle, You Made My Heart Skip a Beat - No Fluff Just Stuff

Oh, Gradle, You Made My Heart Skip a Beat

Posted by: Robert Fischer on November 27, 2009

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.


Comments


This post was by Robert Fischer, written on November 27, 2009.
Comment on this post: http://enfranchisedmind.com/blog/posts/gradle-maven-repo-snapshots/#respond
Public Permalink: http://enfranchisedmind.com/blog/posts/gradle-maven-repo-snapshots/
Creative Commons License
This article was a post on the EnfranchisedMind blog. EnfranchisedMind Blog by Robert Fischer, Brian Hurt, and Other Authors is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.

(Digital Fingerprint: bcecb67d74ab248f06f068724220e340 (87.250.252.241) )

Robert Fischer

About Robert Fischer

Robert Fischer is a multi-language open source developer currently specializing in Groovy in Grails. In the past, his specialties have been in Perl, Java, Ruby, and OCaml. In the future, his specialty will probably be F# or (preferably) a functional JVM language like Scala or Clojure.

Robert is the author of Grails Persistence in GORM and GSQL, a regular contributor to GroovyMag and JSMag, the founder of the JConch Java concurrency library, and the author/maintainer of Liquibase-DSL and the Autobase database migration plugin for Grails.

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »