Last active
May 9, 2016 17:54
-
-
Save dkowis/ef35ac0744178ea64455c3744b795f21 to your computer and use it in GitHub Desktop.
Trying to produce a gems-in-a-jar for compass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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