buildscript {
repositories {
flatDir(dirs:'lib')
}
dependencies {
classpath name: 'clj-gradle-1.0.0'
}
}
usePlugin(de.kotka.gradle.ClojurePlugin)
repositories {
flatDir(dirs:'lib')
}
configurations {
compileOnly {
setVisible(false)
setTransitive(false)
}
compile.extendsFrom(compileOnly)
}
repositories {
mavenCentral()
mavenRepo urls: "http://build.clojure.org/snapshots"
}
dependencies {
compileOnly name: 'clj-gradle-1.0.0'
compile 'org.clojure:clojure-lang:1.1.0-alpha-SNAPSHOT'
compile 'org.clojure:clojure-contrib:1.0-SNAPSHOT'
}
task initProject(description: 'Initialize project directory structure.') << {
['clojure'].each {
convention.sourceSets.all*."${it}".srcDirs*.each { it.mkdirs() }
}
}
task copyToLib(dependsOn: configurations.default.buildArtifacts, type: Copy) {
into('build/lib')
from configurations.default
from configurations.default.allArtifacts*.file
}
I'm using the shorthand syntax for dependencies. I also added mvn repo support. There is a separate entry to point to build.clojure.org. Two tasks were also added. One is initPrjoject. The initProject task was both inspired by Gradle cookbook as well as Hubert Klein Ikkink's blog post on mixed Groovy and Java using Gradle.
The copyToLib was from the Gradle cookbook also.
That's all there is to it. Gradle will now take care of all your build needs. If you want to use clojure 1.0 instead of the bleeding edge. Change the line "compile 'org.clojure:clojure-lang:1.1.0-alpha-SNAPSHOT'" to "compile 'org.clojure:clojure:1.0.0'". There isn't a mvn repo version of clojure-contrib though.
At some point, the artifact id is changing from clojure-lang to just clojure as per this ticket. When that happens, just change your build.gradle file accordingly.
Sunday, November 08, 2009
Bleeding Edge Clojure Development using clj-gradle
Clojure is evolving very rapidly. I find myself using clojure and clojure-contrib from github most of the time. It's rather annoying to have to keep git pull and build them often. A few days ago, a CI server was setup for clojure.org to build both clojure and clojure-contrib and made them available in mvn style repo.
Excellent, this means I can just use Gradle to handle it for me. For any new bleeding edge clojure project, all you need is the clj-gradle-1.0.0.jar and build.gradle file. If you don't have the clj-gradle-1.0.0.jar go here to see how to build it.
Here is the updated version of the build.gradle file.
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment