Methods Summary |
---|
private void | addCommandsToList(java.util.ListIterator listIterator)Add all the commands to a list identified by the iterator passed in.
//create the command to run Java, including user specified options
getActualVMCommand().addCommandToList(listIterator);
// properties are part of the vm options...
sysProperties.addDefinitionsToList(listIterator);
if (isCloneVm()) {
SysProperties clonedSysProperties = new SysProperties();
PropertySet ps = new PropertySet();
PropertySet.BuiltinPropertySetName sys =
new PropertySet.BuiltinPropertySetName();
sys.setValue("system");
ps.appendBuiltin(sys);
clonedSysProperties.addSyspropertyset(ps);
clonedSysProperties.addDefinitionsToList(listIterator);
}
//boot classpath
Path bcp = calculateBootclasspath(true);
if (bcp.size() > 0) {
listIterator.add("-Xbootclasspath:" + bcp.toString());
}
//main classpath
if (haveClasspath()) {
listIterator.add("-classpath");
listIterator.add(
classpath.concatSystemClasspath("ignore").toString());
}
//now any assertions are added
if (getAssertions() != null) {
getAssertions().applyAssertions(listIterator);
}
// JDK usage command line says that -jar must be the first option, as there is
// a bug in JDK < 1.4 that forces the jvm type to be specified as the first
// option, it is appended here as specified in the docs even though there is
// in fact no order.
if (executeJar) {
listIterator.add("-jar");
}
// this is the classname to run as well as its arguments.
// in case of 'executeJar', the executable is a jar file.
javaCommand.addCommandToList(listIterator);
|
public void | addSysproperties(org.apache.tools.ant.types.CommandlineJava$SysProperties sysp)Add a set of system properties.
sysProperties.addSysproperties(sysp);
|
public void | addSysproperty(Environment.Variable sysp)Add a system property.
sysProperties.addVariable(sysp);
|
public void | addSyspropertyset(PropertySet sysp)Add a set of system properties.
sysProperties.addSyspropertyset(sysp);
|
private Path | calculateBootclasspath(boolean log)Calculate the bootclasspath based on the bootclasspath
specified, the build.sysclasspath and ant.build.clonevm magic
properties as well as the cloneVm attribute.
if (vmVersion.startsWith("1.1")) {
if (bootclasspath != null && log) {
bootclasspath.log("Ignoring bootclasspath as "
+ "the target VM doesn't support it.");
}
} else {
if (bootclasspath != null) {
return bootclasspath.concatSystemBootClasspath(isCloneVm()
? "last"
: "ignore");
} else if (isCloneVm()) {
return Path.systemBootClasspath;
}
}
return new Path(null);
|
public void | clearJavaArgs()Clear out the java arguments.
javaCommand.clearArgs();
|
public java.lang.Object | clone()Deep clone the object.
try {
CommandlineJava c = (CommandlineJava) super.clone();
c.vmCommand = (Commandline) vmCommand.clone();
c.javaCommand = (Commandline) javaCommand.clone();
c.sysProperties = (SysProperties) sysProperties.clone();
if (classpath != null) {
c.classpath = (Path) classpath.clone();
}
if (bootclasspath != null) {
c.bootclasspath = (Path) bootclasspath.clone();
}
if (assertions != null) {
c.assertions = (Assertions) assertions.clone();
}
return c;
} catch (CloneNotSupportedException e) {
throw new BuildException(e);
}
|
public Commandline.Argument | createArgument()Create a new argument to the java program.
return javaCommand.createArgument();
|
public Path | createBootclasspath(org.apache.tools.ant.Project p)Create a boot classpath.
if (bootclasspath == null) {
bootclasspath = new Path(p);
}
return bootclasspath;
|
public Path | createClasspath(org.apache.tools.ant.Project p)Create a classpath.
if (classpath == null) {
classpath = new Path(p);
}
return classpath;
|
public Commandline.Argument | createVmArgument()Create a new JVM argument.
return vmCommand.createArgument();
|
public java.lang.String | describeCommand()Return a String that describes the command and arguments suitable for
verbose output before a call to Runtime.exec(String[]).
return Commandline.describeCommand(getCommandline());
|
public java.lang.String | describeJavaCommand()Return a String that describes the java command and arguments
for in-VM executions.
The class name is the executable in this context.
return Commandline.describeCommand(getJavaCommand());
|
protected Commandline | getActualVMCommand()Get the VM command parameters, including memory settings.
Commandline actualVMCommand = (Commandline) vmCommand.clone();
if (maxMemory != null) {
if (vmVersion.startsWith("1.1")) {
actualVMCommand.createArgument().setValue("-mx" + maxMemory);
} else {
actualVMCommand.createArgument().setValue("-Xmx" + maxMemory);
}
}
return actualVMCommand;
|
public Assertions | getAssertions()Get the current assertions.
return assertions;
|
public Path | getBootclasspath()Get the boot classpath.
return bootclasspath;
|
public java.lang.String | getClassname()Get the name of the class to be run.
if (!executeJar) {
return javaCommand.getExecutable();
}
return null;
|
public Path | getClasspath()Get the classpath for the command.
return classpath;
|
public java.lang.String[] | getCommandline()Get the command line to run a Java vm.
//create the list
List commands = new LinkedList();
final ListIterator listIterator = commands.listIterator();
//fill it
addCommandsToList(listIterator);
//convert to an array
return (String[]) commands.toArray(new String[commands.size()]);
|
public java.lang.String | getJar()Get the name of the jar to be run.
if (executeJar) {
return javaCommand.getExecutable();
}
return null;
|
public Commandline | getJavaCommand()Get the Java command to be used.
return javaCommand;
|
public org.apache.tools.ant.types.CommandlineJava$SysProperties | getSystemProperties()Get the system properties object.
return sysProperties;
|
public Commandline | getVmCommand()Get the VM command, including memory.
return getActualVMCommand();
|
public java.lang.String | getVmversion()Get the vm version.
return vmVersion;
|
protected boolean | haveBootclasspath(boolean log)Determine whether the bootclasspath has been specified, and whether it
shall really be used (build.sysclasspath could be set or the VM may not
support it).
return calculateBootclasspath(log).size() > 0;
|
protected boolean | haveClasspath()Determine whether the classpath has been specified, and whether it shall
really be used or be nulled by build.sysclasspath.
Path fullClasspath = classpath != null
? classpath.concatSystemClasspath("ignore") : null;
return fullClasspath != null
&& fullClasspath.toString().trim().length() > 0;
|
private boolean | isCloneVm()Find out whether either of the cloneVm attribute or the magic property
ant.build.clonevm has been set.
return cloneVm
|| "true".equals(System.getProperty("ant.build.clonevm"));
|
public void | restoreSystemProperties()Restore the cached system properties.
sysProperties.restoreSystem();
|
public void | setAssertions(Assertions assertions)Add an assertion set to the command.
this.assertions = assertions;
|
public void | setClassname(java.lang.String classname)Set the classname to execute.
javaCommand.setExecutable(classname);
executeJar = false;
|
public void | setCloneVm(boolean cloneVm)Set whether system properties will be copied to the cloned VM--as
well as the bootclasspath unless you have explicitly specified
a bootclasspath.
this.cloneVm = cloneVm;
|
public void | setJar(java.lang.String jarpathname)Set a jar file to execute via the -jar option.
javaCommand.setExecutable(jarpathname);
executeJar = true;
|
public void | setMaxmemory(java.lang.String max)Specify max memory of the JVM.
-mx or -Xmx depending on VM version.
this.maxMemory = max;
|
public void | setSystemProperties()Cache current system properties and set them to those in this
Java command.
sysProperties.setSystem();
|
public void | setVm(java.lang.String vm)Set the executable used to start the new JVM.
vmCommand.setExecutable(vm);
|
public void | setVmversion(java.lang.String value)Set the JVM version required.
vmVersion = value;
|
public int | size()Get the size of the java command line. This is a fairly intensive
operation, as it has to evaluate the size of many components.
int size = getActualVMCommand().size() + javaCommand.size()
+ sysProperties.size();
// cloned system properties
if (isCloneVm()) {
size += System.getProperties().size();
}
// classpath is "-classpath <classpath>" -> 2 args
if (haveClasspath()) {
size += 2;
}
// bootclasspath is "-Xbootclasspath:<classpath>" -> 1 arg
if (calculateBootclasspath(true).size() > 0) {
size++;
}
// jar execution requires an additional -jar option
if (executeJar) {
size++;
}
//assertions take up space too
if (getAssertions() != null) {
size += getAssertions().size();
}
return size;
|
public java.lang.String | toString()Get a string description.
return Commandline.toString(getCommandline());
|