i have a java Swing code in that i need to call an Ant build at run time, here i give my code is it correct way for execution else i will do any changes, i also write my ant build here.While i executing this code there is no output my console still blank, why this problem arise if any solution is there kindly send me..thanks in advance
Build.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
File buildFile = new File("child_build.xml");
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 e1) {
//p.fireBuildFinished(e);
}
}
}
});
}
My ant build is..:
<project basedir="." default="child_build" name="JavaSamp">
<target name="child_build">
<mkdir dir="classes" />
<exec executable="C:\Program Files\Inno Setup 5\ISCC.exe">
<arg value="${basedir}\Child_Script.iss" />
</exec>
<echo message="Child_Script is executed" />
</target>
</project>
I would have just commented this, but I dont have enough rep to do it. Are you sure you aren’t getting an exception at runtime?
This would swallow BuildExceptions that are being thrown.