I have a problem with logs from ant command. When I run command in CMD i see step by step progress of deployment or validation but when I execute the same target in my java app I do not see mentioned logs - I see final logs when deployment is finished.
Code in button:
if (orgSelectName.getSelectedIndex() == 0) {
JOptionPane.showMessageDialog(null, "Choose org !");
buttonGroup2.clearSelection();
} else {
String selectedOrg = orgSelectName.getSelectedItem().toString();
String pathDesktopBuildOrg = System.getProperty("user.home") + "/Desktop/Deployment/" + selectedOrg + "/build.xml";
MyLogger myLogger = new MyLogger();
File buildFile = new File(pathDesktopBuildOrg);
Project antProject = new Project();
myLogger.setErrorPrintStream(System.err);
myLogger.setOutputPrintStream(System.out);
myLogger.setMessageOutputLevel(Project.MSG_INFO);
antProject.addBuildListener(myLogger);
antProject.setUserProperty("ant.file", buildFile.getAbsolutePath());
antProject.fireBuildStarted();
antProject.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
antProject.addReference("ant.projectHelper", helper);
helper.parse(antProject, buildFile);
String target = "deployCodeCheckOnly";
buttonGroup2.clearSelection();
antProject.executeTarget(target);
antProject.fireBuildFinished(null);
}
What should I do to get these logs and see step by step progress in my java app?
When I run in CMD I see this and I would like to have the same result in java app.
I've added additional class class MyLogger extends DefaultLogger {
@Override
public void buildFinished(BuildEvent be) {
actionResult.append("[BUILD FINISHED]\n");
}
@Override
public void buildStarted(BuildEvent be) {
actionResult.append("[BUILD STARTED]\n");
}
@Override
public void messageLogged(BuildEvent be) {
actionResult.append(be.getMessage() + "\n");
}