Skip to content

Instantly share code, notes, and snippets.

@dkowis
Last active May 9, 2016 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkowis/ef35ac0744178ea64455c3744b795f21 to your computer and use it in GitHub Desktop.
Save dkowis/ef35ac0744178ea64455c3744b795f21 to your computer and use it in GitHub Desktop.
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