I have to call an ant target from java class, currently it is being called from sh script where it sets -logger logger.class
I have written the java code to do so...
Project p = new Project();
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(TARGET);
Can some one tell me how to set the logger using same code sequence.
error:
Class not found:util.logger.CustomLogger
java.lang.RuntimeException
at org.apache.tools.ant.Main.createLogger(Main.java:850)
at org.apache.tools.ant.Main.addBuildListeners(Main.java:795)
You have to add your Logger to the Project with addBuildListener, ant provides a few implementations which also implement BuildLogger
so
project.addBuildListener(new DefaultLogger());
or whatever your logger jave to be (as long as it implements BuildListener
) should do the trick
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With