Running RSpec
+/* Add the JRuby Gradle "base" plugin as a dependency of our build script */
+buildscript {
+ repositories { jcenter() }
+ dependencies {
+ classpath 'com.github.jruby-gradle:jruby-gradle-plugin:0.1.9'
+ }
+}
+
+/*
+ * Importing the JRubyExec type class so we can create our own JRubyExec-based
+ * task below
+ */
+import com.github.jrubygradle.JRubyExec
+
+dependencies {
+ /* We need RSpec gems from rubygems.org to run RSpec */
+ jrubyExec group: 'rubygems', name: 'rspec', version: '3.1.+'
+}
+
+task spec(type: JRubyExec) {
+ group 'JRuby'
+ description 'Execute the RSpecs in JRuby'
+ jrubyArgs '-S'
+ script 'rspec'
+}
+Building an executable .jar file
+buildscript {
+ repositories { mavenLocal() }
+ dependencies {
+ classpath 'com.github.jruby-gradle:jruby-gradle-plugin:0.1.9'
+ }
+}
+plugins {
+ id "com.github.jruby-gradle.jar" version "0.1.2"
+ id "com.github.johnrengelman.shadow" version "1.1.2"
+}
+
+apply plugin: 'java'
+
+dependencies {
+ gems group: 'rubygems', name: 'protobuf', version: '3.0.+'
+ gems group: 'rubygems', name: 'rake', version: '10.3.+'
+}
+
+
+jrubyJavaBootstrap {
+ jruby {
+ initScript = 'bin/rake'
+ }
+}
+
+// Pull the contents of lib and bin into the root of the created jar file
+sourceSets {
+ main {
+ resources.srcDirs = ['lib', 'bin']
+ }
+}
+
+shadowJar {
+ baseName 'blick-agent'
+ exclude '*.sw*', '*.gitkeep', '*.md'
+
+ jruby {
+ // Use the default GEM installation directory
+ defaultGems()
+ defaultMainClass()
+ }
+}
+Creating a .war file
+/* Add the JRuby Gradle "war" plugin as a dependency of our build script */
+buildscript {
+ repositories { jcenter() }
+
+ dependencies {
+ classpath 'com.github.jruby-gradle:jruby-gradle-war-plugin:0.1.5'
+ }
+}
+
+apply plugin: 'com.github.jruby-gradle.war'
+
+dependencies {
+ /* Enumerate some dependencies that will get pulled into the .war */
+ gems 'rubygems:colorize:0.7.3'
+ gems 'rubygems:sinatra:1.4.5'
+}
+
+jrubyWar {
+ webInf {
+ /* Include our app inside of `my.war/WEB-INF` */
+ from 'app.rb'
+ /* Include the config.ru to boot the app properly */
+ from 'config.ru'
+ }
+}
+