This project provides two Gradle plugins to run XML Calbash. Simply include the dependencies in the buildscript:
buildscript { repositories { mavenCentral() } dependencies { classpath group: 'com.xmlcalabash', name: 'gradle', version: '0.0.2' classpath group: 'com.xmlcalabash', name: 'xmlcalabash', version: '1.1.7-96' } }
And then create tasks of the appropriate type:
-
com.xmlcalabash.XMLCalabashExec
is modeled after the standardJavaExec
task. You can specify the classpath, heap size, and other VM parameters using the same properties as theJavaExec
task. The XML Calabash options and parameters are specified using explicit properties. You cannot set the main class name or call theargs()
method. -
com.xmlcalabash.XMLCalabashTask
runs XML Calabash in the same JVM that gradle is using. Consequently, you can’t change any of the JVM parameters.
The following properties are supported:
- pipeline
-
Filename of the pipeline to run (string, required).
- debugPipeline
-
Enable debug mode (boolean)
- safeMode
-
Enable safe mode (boolean)
- profilePipeline
-
Name of the file to use for writing profile information (string)
- saxonEdition
-
Saxon edition (string: “he”, “pe”, or “ee”; defaults to “he”)
- schemaAware
-
Schema aware processing (boolean, requires “he” or “pe” edition)
- entityResolver
-
Name of entity resolver class (string)
- uriResolver
-
Name of URI resolver class (string)
- configFile
-
Filename of the XML Calabash configuration file (string; defaults to
$HOME/.calabash
) - saxonConfigFile
-
Filename of the Saxon Configuration file (string)
- library
-
Library to load (string)
- step
-
Step to run (QName)
- calabashExtensions
-
Extenions to enable (list of strings: “general-values”, “xpointer-on-text”, “transparent-json”, “json-flavor-???”, “allow-text-results”, “use-xslt-1.0”, “html-serializer”)
In addition, the following methods may be called:
namespaceBinding(String prefix, String uri)
-
Establish the namespace binding between
prefix
anduri
for evaluating QNames specified in other properties and methods. input(String port, String filename)
-
Send the XML document identified by
filename
to the port namedport
. dataInput(String port, String filename)
-
Send the non-XML document identified by
filename
to the port namedport
. dataInput(String port, String filename, String contentType)
-
Send the non-XML document identified by
filename
to the port namedport
with the explicit content type specified incontentType
. output(String port, String filename)
-
Send the output from the port named
port
to the filename identified byfilename
. param(String qname, String value)
-
Send the
qname
parameter with the valuevalue
to the primary parameter input port on the pipeline. param(String qname, String value, String port)
-
Send the
qname
parameter with the valuevalue
to theport
parameter input port on the pipeline. option(String qname, String value)
-
Send the option
qname
to the pipeline with the valuevalue
.
Using the XMLCalabashExec
task type:
task doSomething(type: com.xmlcalabash.XMLCalabashExec) { classpath = configurations.runtime maxHeapSize = '1024m' pipeline = "pipe.xpl" safeMode = true parameter('styleParam', 'someValue') option('optName', 'optValue') input('source','filename.xml') input('alt','altname.xml') input('result','output.xml') }
Or running in the same VM:
dependencies { compile ( [group: 'com.xmlcalabash', name: 'xmlcalabash', version: '1.1.7-96'], ) } task doSomething(type: com.xmlcalabash.XMLCalabashTask) { pipeline = "pipe.xpl" safeMode = true parameter('styleParam', 'someValue') option('optName', 'optValue') input('source','filename.xml') input('alt','altname.xml') input('result','output.xml') }
Note that in the XMLCalabashTask
case, you must put the XML Calabash
dependencies in the compile configuration or they won’t be available
to the task (which runs in the same VM).
(I don’t know why you have to fully qualify the types, in theory
just XMLCalabashExec
or XMLCalabashTask
should work. But they don’t
at the moment.)