Skip to content

Instantly share code, notes, and snippets.

@mkristian
Created March 15, 2016 14:46
Show Gist options
  • Save mkristian/ce79577ea7ca8f82e308 to your computer and use it in GitHub Desktop.
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
# loads embedded jars
require 'jars/setup'
org.slf4j.LoggerFactory.getLogger('ROOT').info("require colorize: #{require 'colorize'}" )
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()
}
$ ./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
// 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