I didn't mention that I am trying to run an ant task in a build.xml
file. Does this change it? I can't figure out exactly how to
implement the code you offered. Say I am trying to run an ant target
from C:\test\build.xml, and the target is as follows:
<target name="test1">
<echo> ${arg1}</echo>
</target>
How would I make a call to this target (including specifying "arg1")?
Again, thank you very much for the help, I appreciate it.
hust6
Use the Properties parameter of the start method:
String[] args = {"test1"};
Properties userProps = new Properties();
userProps.setProperty("arg1", "WhatEver");
userProps.setProperty("arg2", "Something");
ClassLoader loader = null; // or a specific classloader
org.apache.tools.ant.Main.start(args, userProps, loader);
And if you need to specify a specific build file, you can use the following:
File buildFile = new File("path/to/some/build.xml");
String[] args = {"-buildfile", buildFile.toString(), "test1"};
I.e. the args passed to start method are like those you would pass on
the commandline:
ant -buildfile path/to/some/build.xml test1
--
Regards,
Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \