Chapter 3. Running Schmant

Table of Contents

Unix
Arguments
Environment variables
Which Java? (Unix)
Windows
Arguments
Environment variables
Which Java? (Windows)
Running Schmant from Java

Schmant is started with the startup script schmant.sh or schmant.bat, depending on the operating system on which it is run. The startup script searches for a java command using the algorithm described in the section called “Which Java? (Unix)” or the section called “Which Java? (Windows)”, then it uses that java command to launch the Launcher class. Launcher prepares the scripting environment (see the scripting language guides) and invokes the build script.

Most script languages require that the script language implementation JARs are on the classpath. Either put them on the classpath manually, or put them in the Schmant installation's libengine directory.

A large number of different arguments can be given to the startup script. However, except for the script file, none of them are mandatory. The default settings of the startup script should work fine in many cases.

On Unix (Linux, Solaris, Mac OS X, etc.), Schmant is run with the bin/schmant.sh command.

[ -a scripts | --prepare-scripts scripts ]

A list of custom environment preparation script files. The scripts are run in the order that they are listed. The default, script environment-specific preparation script can be included in the list by inserting a capital X in any position. If this argument is omitted, only the default environment preparation script is run.

See the scripting language guides for more information on the different environment preparation scripts.

Different path entries are separated by colons (:). Path entries are either absolute or relative to the directory of the build script.

[{ -c | --class-loader-strategy } { isolated | shared }]

Choose the class loading strategy for task packages. The default strategy is shared. See the section called “Class loaders”.

[ -cp path | --classpath path ]

Insert this classpath first in the script classpath. Different path entries are separated by colons (:). Path entries are either absolute or relative to the directory of the build script.

[ -h | --help ]

Print usage instructions and exit.

[ -i fqn | --argument-interpreter fqn ]

The fully qualified class name of the ArgumentInterpreter implementation to use.

[ -j arg | --jvmarg arg ...]

Give an argument to the JVM used to run Schmant (for instance -j -Xmx512m to set the maximum available memory size to 512MB). Use several times to give several arguments.

If the argument contains spaces, = characters or other characters that the shell interpreter has special treatment for, it has to be quoted in double (") or single (') quotes.

[ --java path ]

Use the specified Java installation to run Schmant. The path should be the path to the root directory of the Java installation, for instance --java /opt/jdk1.6.0_12.

[ -k | --keep ]

Keep all temporary files and directories created with TempFileUtil. If this flag is not given, all temporary files and directories that the build script has not explicitly told TempFileUtil to keep are deleted when Schmant exits.

[ -l | --list-executor-factories ]

List all available org.schmant.ScriptExecutorFactory implementations and exit.

[ -p key=value | --property key=value ...]

Set a script property. The property will be available for the build script in the props Properties variable. Give the argument several times to set several properties. See the section called “Properties and arguments”.

[ -q | --quiet ]

Decrease the level of verbosity. (Make Schmant print less information about what it is doing.) Use the flag several times to make Schmant even more quiet. See the section called “Reports and logging”.

[ -r fqn | --report-factory fqn ]

The fully qualified class name of the ReportFactory to be used for creating the build reports. Default is the StdoutReportFactory. See the section called “Reports and logging”.

[ -rlf fqn | --report-line-formatter fqn ]

The fully qualified class name of the ReportLineFormatter to be used for formatting text lines that are logged to a Report. Default is the SimpleReportLineFormatter. See the section called “Reports and logging”.

[ --script-executor-implementation fqn ]

The fully qualified class name for the ScriptExecutor implementation to use for running the build script. If this argument is not given, a ScriptExecutor is looked up using the script file extension.

[ -t path | --taskpath path ]

Set the path to additional task packages, in addition to the task packages bundled with Schmant. Task packages may be either task package Zip files, or the root directory of an unpacked Zip file, just like Jar files and class directories are used in the Java classpath.

Different path entries are separated by colons (:). Path entries are either absolute or relative to the directory of the build script.

Extra task package path entries are prepended to the task package path string, and thus take precedence over task directories in the standard task package path. (The $SCHMANT_HOME/task directory.) See Chapter 6, Task packages.

[ --trace ]

Enable trace mode from the start. Trace mode means that a task's configuration always is logged before it is run.

[ -v | --verbose ]

Increase the level of verbosity. (Make Schmant print more information about what it is doing.) Use the flag several times to make Schmant even more verbose. See the section called “Reports and logging”.

file

The path to the script file to run. To run a script stored in a Zip, Jar, War or Ear file, use the format path_to_archive#path_to_script_in_archive.

arg...

A list of script arguments. All arguments given here are bound to the List<String> args in the script.

JAVA_HOME

If set, the JDK installation referenced will be used to run Schmant.

JVM_ARGS

Can be used instead of or together with the -j argument to set JVM options.

PROG_ARGS

Arguments that are fed directly to the Launcher class, the class used to launch Schmant.

TASK_PACKAGE_PATH

Task package path that is prepended to the default task package path. The default task package path contains all task packages that are bundled with Schmant. This is ignored if the -t argument is used.

Some tasks use other environment variables in addition to those listed above.

On Windows, Schmant is run with the bin\schmant.bat command.

[ -a scripts | --prepare-scripts scripts ]

A list of custom environment preparation script files. The scripts are run in the order that they are listed. The default, script environment-specific preparation script can be included in the list by inserting a capital X in any position. If this argument is omitted, only the default environment preparation script is run.

See the scripting language guides for more information on environment preparation scripts.

Different path entries are separated by semi colons (;). Path entries are either absolute or relative to the directory of the build script.

[{ -c | --class-loader-strategy } { isolated | shared }]

Choose the class loading strategy for task packages. The default strategy is shared. See the section called “Class loaders”.

[ -cp path | --classpath path ]

Insert this classpath first in the script classpath. Different path entries are separated by semi colons (;). Path entries are either absolute or relative to the directory of the build script.

If there are several entries on the classpath, or if the entry on the classpath contains spaces, the classpath argument (only the path part) has to be quoted in ":s

[ -h | --help ]

Print usage instructions and exit.

[ -i fqn | --argument-interpreter fqn ]

The fully qualified class name of the ArgumentInterpreter implementation to use.

[ -j arg | --jvmarg arg ...]

Give an argument to the JVM used to run Schmant (for instance -j -Xmx512m to set the maximum available memory size to 512MB).

If the argument contains spaces or equals signs (for instance when assigning a Java system property), enclose the argument in quotes (").

Use several times to give several arguments.

[ --java path ]

Use the specified Java installation to run Schmant. The path should be the path to the root directory of the Java installation. If it contains spaces, it must be quoted in citation marks, for instance --java "c:\Program Files\Java\jdk1.6.0_12".

[ -k | --keep ]

Keep all temporary files and directories created with TempFileUtil. If this flag is not given, all temporary files and directories that the build script has not explicitly told TempFileUtil to keep are deleted when Schmant exits.

[ -l | --list-executor-factories ]

List all available org.schmant.ScriptExecutorFactory implementations and exit.

[ -p "key=value" | --property "key=value" ...]

Set a script property. The property will be available for the build script in the props Properties variable. The property assignment must be enclosed in quotes. Give the argument several times to set several properties. See the section called “Properties and arguments”.

[ -q | --quiet ]

Decrease the level of verbosity. (Make Schmant print less information about what it is doing.) Use the flag several times to make Schmant even more quiet. See the section called “Reports and logging”.

[ -r fqn | --report-factory fqn ]

The fully qualified class name of the ReportFactory to use for creating the build reports. Default is the StdoutReportFactory. See the section called “Reports and logging”.

[ -rlf fqn | --report-line-formatter fqn ]

The fully qualified class name of the ReportLineFormatter to be used for formatting text lines that are logged to a Report. Default is the SimpleReportLineFormatter. See the section called “Reports and logging”.

[ --script-executor-implementation fqn ]

The fully qualified class name for the ScriptExecutor implementation to use for running the build script. If this argument is not given, a ScriptExecutor is looked up using the script file extension.

[ -t path | --taskpath path ]

Set the path to additional task packages, in addition to the task packages bundled with Schmant. Task packages may be either task package Zip files, or the root directory of an unpacked Zip file, just like Jar files and class directories are used in the Java classpath.

Different path entries are separated by semicolons (;). Path entries are either absolute or relative to the directory of the build script.

Extra task package path entries are prepended to the task package path string, and thus take precedence over task directories in the standard task package path. (The $SCHMANT_HOME/task directory.) See Chapter 6, Task packages.

[ --trace ]

Enable trace mode from the start. Trace mode means that a task's configuration always is logged before it is run.

[ -v | --verbose ]

Increase the level of verbosity. (Make Schmant print more information about what it is doing.) Use the flag several times to make Schmant even more verbose. See the section called “Reports and logging”.

file

The path to the script file to run. To run a script stored in a Zip, Jar, War or Ear file, use the format path_to_archive#path_to_script_in_archive.

arg...

A list of script arguments. All arguments given here are bound to the List<String> args in the script.

JAVA_HOME

If set, the JDK installation referenced will be used to run Schmant.

JVM_ARGS

Can be used instead of or together with the -j argument to set JVM options.

PROG_ARGS

Arguments that are fed directly to the Launcher class, the class used to launch Schmant.

TASK_PACKAGE_PATH

Task package path that is prepended to the default task package path. The default task package path contains all task packages that are bundled with Schmant. This is ignored if the -t argument is used.

Some tasks use other environment variables in addition to those listed above.

Schmant can be embedded in a Java application. The application runs Schmant's by creating a Launcher object and running any of its launch methods. See Launcher's API documentation for details on how to do that.