tags:

views:

42

answers:

0

Hello,

i want to execute the following ant command but using java instead of the command line:

-Desb.netbeans.home=PATH_TO_YOUR_NETBEANS

My current java code:

Project p = new Project();
p.setUserProperty("ant.file", buildFile.getAbsolutePath());


 DefaultLogger consoleLogger = new DefaultLogger();
 consoleLogger.setErrorPrintStream(System.err);
 consoleLogger.setOutputPrintStream(System.out);
 consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
 p.addBuildListener(consoleLogger);

 try {
  p.fireBuildStarted();
  p.init();
  ProjectHelper helper = ProjectHelper.getProjectHelper();
  p.addReference("ant.projectHelper", helper);
  helper.parse(p, buildFile);
  p.executeTarget(p.getDefaultTarget());
  p.fireBuildFinished(null);
 } catch (BuildException e) {
  p.fireBuildFinished(e);
  throw new AssertionError(e);
 }

How do I handle this parameter? Should I simply add it to the project as a property?