ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject Start ant from java,using log4j
Date Thu, 03 Jan 2008 10:38:38 GMT

Hi,

i need to start an ant script out of a java class
(using ant 1.6.5 / jdk 1.4.2_08)
for now i have =

...
java.io.File buildFile = new java.io.File(dircopyAntFile);
org.apache.tools.ant.Project p = new org.apache.tools.ant.Project();
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
// to be changed using log4j		
org.apache.tools.ant.DefaultLogger consoleLogger = new
org.apache.tools.ant.DefaultLogger();
consoleLogger.setErrorPrintStream(System.err);
consoleLogger.setOutputPrintStream(System.out);
consoleLogger.setMessageOutputLevel(org.apache.tools.ant.Project.MSG_INF
O);
p.addBuildListener(consoleLogger);
// to be changed using log4j

try {
p.fireBuildStarted();
p.init();
org.apache.tools.ant.ProjectHelper helper =
org.apache.tools.ant.ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
p.setProperty("quelle", quelle);
p.setProperty("ziel", ziel);
p.setProperty("recurse", recurse);
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
p.fireBuildFinished(null);

} catch (org.apache.tools.ant.BuildException e) {
p.fireBuildFinished(e);
}
...

Problem =
my application already uses log4j.
How to change the call of the ant script
to use the log4jlistener ?

Log4jListener log4jlogger = new Log4JListener();
?? How to combine the logger with my existing log4j.properties
log4jlogger.  doesn't give me anything ??
p.addBuildListener(log4jlogger);



Already googled but didn't find any example
Any hints ?

Regards, Gilbert

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message