Created
March 15, 2016 14:46
-
-
Save mkristian/ce79577ea7ca8f82e308 to your computer and use it in GitHub Desktop.
jruby library with embeded ruby and embedded gems and jar dependencies for the ruby application
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
# loads embedded jars | |
require 'jars/setup' | |
org.slf4j.LoggerFactory.getLogger('ROOT').info("require colorize: #{require 'colorize'}" ) |
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
buildscript { | |
repositories { | |
mavenLocal() | |
jcenter() | |
} | |
dependencies { | |
classpath "com.github.jruby-gradle:jruby-gradle-jar-plugin:1.2.+" | |
} | |
} | |
apply plugin: 'com.github.jruby-gradle.base' | |
apply plugin: 'com.github.jruby-gradle.jar' | |
apply plugin: 'java' | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
compile 'org.jruby:jruby:9.0.5.0' | |
jrubyJar 'rubygems:colorize:0.7.7' | |
jrubyJar 'org.slf4j:slf4j-simple:1.7.12' | |
} | |
jruby { | |
defaultVersion '9.0.5.0' | |
} | |
jrubyJar { | |
dependsOn 'compileJava' | |
from('build/classes/main') { include '**/*' } | |
from('.') { include 'app.rb' } | |
initScript library() | |
} |
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
$ ./gradlew jrubyJar | |
:compileJava | |
:prepareJRubyJar UP-TO-DATE | |
:jrubyJar | |
BUILD SUCCESSFUL | |
Total time: 4.613 secs | |
$ java -cp ~/.m2/repository/org/jruby/jruby-complete/9.0.5.0/jruby-complete-9.0.5.0.jar:build/libs/gradle-jruby.jar Main | |
[main] INFO ROOT - require colorize: true |
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
// file: src/main/App.java | |
import org.jruby.embed.IsolatedScriptingContainer; | |
class Main { | |
public static void main(String... args) throws Exception { | |
IsolatedScriptingContainer jruby = new IsolatedScriptingContainer(); | |
jruby.runScriptlet("require 'app'"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment