How to execute JRuby script from Gradle task?

I am trying to execute JRuby scripts in a Gradle task using the Java ScriptEngine.

The Gradle build script at https://gist.github.com/anonymous/5736377 displays all detected script engines (on my machine these are a JavaScript engine, which is available in the JDK by default, and a JRuby engine which is included in the classpath dependency “jruby-complete”).

However, when running the task “testScriptEngineViaImportedTask” that is implemented in the class “ScriptEngineTask” in the buildSrc directory (https://gist.github.com/anonymous/5736380), only the JavaScript engine is displayed. In consequence, in this task I cannot execute JRuby scripts.

What am I doing wrong here?

Have you declared JRuby as a runtime dependency in ‘buildSrc/build.gradle’?

Thank you, Peter! Declaring JRuby as a runtime dependency in buildSrc/build.gradle did the trick.

Peter/Henning, can you provide an example on how to declare JRuby as a runtime dependency in build.gradle? Thank you.