Skip to content

Instantly share code, notes, and snippets.

@dkowis

dkowis/build.gradle

Last active May 9, 2016
Embed
What would you like to do?
Trying to produce a gems-in-a-jar for compass
//Build a jems in a jar for compass.
apply plugin: 'java'
version = "1.0.0"
def gemMap = [compass: "1.0.3"]
repositories {
mavenLocal()
mavenCentral()
}
configurations {
jruby
}
dependencies {
jruby 'org.jruby:jruby-complete:9.1.0.0'
}
task("extractJruby", type: Copy) {
def jrubyJar = configurations.jruby.singleFile
from zipTree(jrubyJar)
into "$buildDir/gemjar"
}
gemMap.each { entry ->
task("getGem_${entry.key}", type: JavaExec) {
dependsOn "extractJruby"
classpath = configurations.jruby
main = "org.jruby.Main"
args "-S", "gem", "install",
"--install-dir", "$buildDir/gemjar", entry.key, "--version", entry.value,
"--no-rdoc", "--no-ri"
}
}
task("installGems") {
def depends = gemMap.collect{ entry -> "getGem_${entry.key}"}
dependsOn depends
}
task("moveBins") {
dependsOn "installGems"
doLast {
file("$buildDir/gemjar/bin").listFiles().each { f ->
println("Moving ${f} to the right spot")
f.renameTo("$buildDir/gemjar/META-INF/jruby.home/bin/${f.name}")
}
}
}
task("buildGemJar", type: Jar) {
dependsOn "installGems", "moveBins"
baseName = "jruby-pip-gemjar"
encoding = "UTF-8"
from files("$buildDir/gemjar")
manifest {
attributes "Main-Class": "org.jruby.Main"
}
}
task("verifyGemJar", type: JavaExec) {
classpath = configurations.jruby
main = "org.jruby.Main"
args "-r${tasks.buildGemJar.archivePath}", "-S", "compass", "help"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.