throw new JellyException("Script file " + scriptFile + " not found");
}
try {
// extract the -o option for the output file to use
final XMLOutput output = cmdLine.hasOption("o") ?
XMLOutput.createXMLOutput(new FileWriter(cmdLine.getOptionValue("o"))) :
XMLOutput.createXMLOutput(System.out);
Jelly jelly = new Jelly();
jelly.setScript(scriptFile);
Script script = jelly.compileScript();
// add the system properties and the command line arguments
JellyContext context = jelly.getJellyContext();
context.setVariable("args", args);
context.setVariable("commandLine", cmdLine);
script.run(context, output);
// now lets wait for all threads to close
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
output.close();
}
catch (Exception e) {
// ignore errors
}
}