Hi,
I would like to call ant (1.6.5) from java (1.5.0_04-b05), but I am a
little puzzled with all createXYZ, addXYZ, init, and execute methods and
in which order they should be called. I wrote it the following way:
Project project = new Project();
XmlLogger xlog = new XmlLogger();
project.addBuildListener(xlog);
project.init();
Target target = new Target();
target.setLocation(new Location("somewhere"));
target.setName("blubb");
Mkdir mkdir = new Mkdir();
mkdir.setProject(project);
mkdir.setTaskName("init");
mkdir.init();
String destDir = "build/classes";
mkdir.setDir(new File(destDir));
target.addTask(mkdir);
Javac javac = new Javac();
javac.setProject(project);
javac.setTaskName("compile");
javac.init();
String srcDir = "src";
javac.setDestdir(new File(destDir));
javac.setSrcdir(new Path(project, srcDir));
javac.setDebug(true);
javac.setDeprecation(false);
javac.setOptimize(false);
Path classPath = new Path(project);
String classesDir = destDir;
Path classesPath = classPath.createPath();
classesPath.setPath(classesDir);
classPath.add(classesPath);
ArrayList<String> libs = new ArrayList<String>();
libs.add("junit3.8.1/junit.jar");
Iterator it = libs.iterator();
while(it.hasNext()) {
String lib = (String) it.next();
FileSet libFile = new FileSet();
libFile.setFile(new File(lib));
classPath.addFileset(libFile);
}
javac.setClasspath(classPath);
//Javac.ImplementationSpecificArgument compilerArgs =
javac.createCompilerArg();
//compilerArgs.setLine("-Xlint:deprecation -Xlint:unchecked");
target.addTask(javac);
project.addTarget("bla", target);
project.executeTarget("bla");
This more or less works fine, but I am not sure if it is correct,
because the XmlLogger gets a NullPointerException that is caused by the
fact that never buildStarted() is called...
I hope someone is able to help me. Thanks in advance!
-Didi
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]