Plugin for creating JRuby-based java archives
This plugin requires Gradle 2.0 or better.
To add the plugin to your project
buildscript {
repositories {
jcenter()
}
dependencies {
classpath group: 'com.github.jruby-gradle', name: 'jruby-gradle-jar-plugin', version: '0.1.1'
classpath group: 'com.github.jruby-gradle', name: 'jruby-gradle-plugin', version: '0.1.+'
}
}
apply plugin: 'com.github.jruby-gradle.jar'
This loads the following plugins if they are not already loaded:
com.github.jrubygradle.base
java-base
com.github.johnrengelman.shadow
This plugin does not add any new tasks or extensions, extends the Jar
task type with a jruby
closure. If the java
plugin
is loaded, then the jar
task can also be configured.
apply plugin: 'java'
jar {
jruby {
// Use the default GEM installation directory
defaultGems()
// Add this GEM installation directory to the JAR.
// Can be called more than once for additional directories
gemDir '/path/to/my/gemDir'
// Equivalent to calling defaultGems()
defaults 'gem'
}
// All other JAR methods and properties are still valid
}
task myJar (type :Jar) {
jruby {
// As above
}
// All other JAR methods and properties are still valid
}
If nothing is specified, then the bootstrap will look for a Ruby script META-INF/jar-bootstrap.rb
.
It is also possible to set the entry script. This must be specified relative to the root of the created JAR.
NOTE: There is currently a known
issue with
rebuilding a shadowJar
when using the initScript
setting. If you change the
setting, you will need to execute the clean
task and rebuild for it to take
effect.
jrubyJavaBootstrap {
jruby {
initScript = 'bin/asciidoctor'
}
}
It is the user's responsibility to ensure that entry point script is created and added to the JAR, be it META-INF/jar-bootstrap.rb
or another specified script.
Please note that executable JARs are still an incubating feature.
Executable JARs are indirectly supported via the Gradle Shadow Jar plugin.
Configuration is exactly the same as for a normal JAR class.
shadowJar {
jruby {
// Use the default bootstrap class
defaultMainClass()
// Make the JAR executable by supplying your own main class
mainClass 'my.own.main'
// Equivalent to calling defaultMainClass()
defaults 'gems', 'mainClass'
}
}
See Shadow JAR README for configuration specifics.
In a similar fashion to the jar
task, the shadowJar
task will make use of the jrubyJavaBootstrap
task to
create and compile a basic bootstrap class.