jruby-gradle-plugin/docs/index.adoc

2.1 KiB
Raw Permalink Blame History

<html lang="en"> <head> </head>

JRuby/Gradle

jruby gradle

JRuby/Gradle is a collection of Gradle plugins which make it easy to build, test, manage and package Ruby applications. By combining the portability of JRuby with Gradles excellent task and dependency management, JRuby/Gradle provides high quality build tooling for Ruby and Java developers alike.

Note
As from version 2.0.0 you will need at least Gradle 4.2.

Plugins available:

Quick Start

Running some Ruby

The simplest example is a hello-world from Gradle, using JRuby/Gradle we can execute a Ruby script, which has Ruby-based dependencies:

build.gradle (full source)
Unresolved directive in gitea_input1588793756 - include::../examples/run-simple-ruby-script/build.gradle[lines=6..30]
print-script.rb (full source)
Unresolved directive in gitea_input1588793756 - include::../examples/run-simple-ruby-script/print-script.rb[]

Executing ./gradlew printSomePrettyOutputPlease results in the following:

print script output

Packaging some Ruby

build.gradle (full source)
Unresolved directive in gitea_input1588793756 - include::../examples/self-executing-jar/build.gradle[lines=6..40]
entrypoint.rb (full source)
Unresolved directive in gitea_input1588793756 - include::../examples/self-executing-jar/entrypoint.rb[]

Executing ./gradlew jrubyJar will build a .jar file inside of the build/libs directory which can then be invoked:

% java -jar build/libs/self-executing-jar-jruby.jar

self executing jar output
</html>