ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From graste <gra...@gmail.com>
Subject Call Ant task from java file
Date Fri, 12 Aug 2005 13:21:26 GMT
Hi,

I'm new to ant tasks and their use outside of ant. I want to execute ent  
tasks outside of build.xml in a simple java class.

My sample source code (inside a public static method of a plugin):
----------
// project
Project project = new Project();
project.init();
// fileset
FileSet fs = new FileSet();
fs.setIncludes("**/CVS");
fs.setDir(new File(exportDirectory));
// delete task properties
Delete delTask = new Delete();
delTask.setProject(project);
delTask.addFileset(fs);
delTask.setIncludeEmptyDirs(true);
// execute task
delTask.execute();
----------

First question: What am I doing wrong? I want to delete all directories  
called "CVS" in the specified folder. So what's the common workflow to use  
ant tasks outside of ant?
Second question: How can I get the log messages of the task? I thought  
about getting them as a String.

BuildLogger log = new DefaultLogger();
log.setMessageOutputLevel(Project.MSG_VERBOSE);
log.setOutputPrintStream(System.out);
log.setErrorPrintStream(System.out);
project.addBuildListener(log);

How do I have to use the above methods to get the log messages as one  
single string? Or aren't these message the ones I'm looking for?

Thanks in advance for ANY help (or helpful URLs at least). :)

Regards,

Steffen Gransow

-- 
Using Opera8

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


Mime
View raw message