Table of Contents
To enable JRuby support, put the JRuby JARs on the classpath when running the build script. JRuby can be downloaded from the JRuby site.
Before running a JRuby script, Schmant prepares the scripting
environment by running the prepare.rb
script. It defines the Schmant
module that
includes a list of packages (see below) and defines the following functions:
debug(s)
Write a debug message to the current Report.
info(s)
Write an information message to the current Report.
warn(s)
Write a warning message to the current Report.
error(s)
Write an error message to the current Report.
fail(s)
Write an error message to the current Report and abort the build script execution.
importClasses(name)
Import all Java classes from the Java package
name
.
enableTaskPackage(name)
Enable the task package name
.
Packages included in the Schmant
module
can be accessed by prefixing them with Schmant::
instead of Java::package_name::
.
For example, these two lines reference the same class:
For more information on how to call Java classes from JRuby scripts, see
the document on
calling Java from JRuby in the JRuby Wiki.
These packages are included in the Schmant
module by the environment preparation script:
org.entityfs
org.entityfs.el
org.entityfs.entityattrs.unix
org.entityfs.fs
org.entityfs.lock
org.entityfs.ostrat
org.entityfs.support.util
org.entityfs.support.util.regexp
org.entityfs.util
org.entityfs.util.cap.entity
org.entityfs.util.filter
org.entityfs.util.filter.entity
org.entityfs.util.filter.entity.regexp
org.entityfs.util.itr
org.entityfs.util.properties
org.entityfs.util.zip
org.schmant
org.schmant.arg
org.schmant.lang
org.schmant.project
org.schmant.project.eclipse
org.schmant.project.filter
org.schmant.project.intellij
org.schmant.project.java
org.schmant.report
org.schmant.run
org.schmant.support
org.schmant.support.entityfs
org.schmant.support.io
org.schmant.support.text
org.schmant.support.xml
org.schmant.task
org.schmant.task.template.jdk.javadoc
org.schmant.tpm
Enabling a task package includes the packages suggested by the task
package in the Schmant
module.
Global variables are prefixed with
$
Global variables such as $props
have to be prefixed with a $
sign.
Calling varargs methods
When calling a varargs method in Java, use a JRuby array for the arguments.
String concatenation
JRuby does not call toString()
automatically on an object when concatenating it with a string. That has to be
done manually.
If you want to give a closure access to a global variable, bind it to a local variable in the scope where the closure is defined.