Created
November 2, 2013 17:55
-
-
Save grimrose/7281607 to your computer and use it in GitHub Desktop.
GradleからJRubyを使う為に挑戦した結果
This file contains hidden or 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
apply plugin: 'java' | |
repositories { | |
mavenCentral() | |
} | |
buildscript { | |
repositories { mavenCentral() } | |
dependencies { gradleApi() } | |
} | |
configurations { | |
jruby | |
} | |
dependencies { | |
jruby 'org.jruby:jruby-complete:1.7.5' | |
} | |
ext { | |
gemsDir = file('.jruby/gems') | |
} | |
import org.gradle.api.tasks.* | |
class JRubyTask extends DefaultTask { | |
def jRubyArgs = ["-S"] | |
@TaskAction | |
void process() { | |
List arguments = jRubyArgs.collect { it.toString() }.collect { it.contains('\'') ? it : it.tokenize() }.flatten() | |
project.logger.info "$arguments" | |
project.javaexec { | |
classpath = project.configurations.jruby | |
main = 'org.jruby.Main' | |
jvmArgs "-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Dfile.encoding=UTF-8".tokenize() | |
environment 'GEM_PATH', project.ext.gemsDir | |
environment 'PATH', "${project.ext.gemsDir}/bin" | |
args arguments | |
} | |
} | |
} | |
task installBundler(type: JRubyTask) { | |
outputs.dir gemsDir | |
jRubyArgs << "gem install" | |
jRubyArgs << "-i $gemsDir" | |
jRubyArgs << "--no-rdoc" | |
jRubyArgs << "--no-ri" | |
jRubyArgs << "bundler" | |
doFirst { | |
gemsDir.mkdirs() | |
} | |
} | |
def ruby = hasProperty('ruby') ? ruby : '' | |
task runRubyCommand(type: JRubyTask) { | |
jRubyArgs = ["${ruby ? "-S " + ruby : "-v"}"] | |
} | |
task bundleInstall(type: JRubyTask) { | |
jRubyArgs << "bundle install" | |
jRubyArgs << "--path" | |
jRubyArgs << "$gemsDir" | |
} | |
task bundleUpdate(type: JRubyTask) { | |
jRubyArgs << "bundle update" | |
} | |
task bundleList(type: JRubyTask) { | |
jRubyArgs << "bundle list" | |
} | |
task rakeTasks(type: JRubyTask) { | |
jRubyArgs << "rake -T" | |
} | |
task runRSpec(type: JRubyTask) { | |
jRubyArgs << "rspec" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ gradle rRC -Pruby='gem which rake'