tips:java:callant
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
| — | tips:java:callant [2009/06/08 11:53] (current) – created erik | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Executing Ant tasks programatically ====== | ||
| + | Taken from [[http:// | ||
| + | |||
| + | <code java> | ||
| + | /* | ||
| + | * AntRunner.java | ||
| + | */ | ||
| + | |||
| + | import java.io.File; | ||
| + | import org.apache.tools.ant.DefaultLogger; | ||
| + | import org.apache.tools.ant.Project; | ||
| + | import org.apache.tools.ant.ProjectHelper; | ||
| + | import org.apache.tools.ant.taskdefs.Ant; | ||
| + | |||
| + | |||
| + | public class AntRunner { | ||
| + | |||
| + | public AntRunner() { | ||
| + | } | ||
| + | |||
| + | public static void main(String args[]) throws Exception { | ||
| + | File buildFile = new File("/ | ||
| + | Project p = new Project(); | ||
| + | p.setUserProperty(" | ||
| + | p.init(); | ||
| + | ProjectHelper helper = ProjectHelper.getProjectHelper(); | ||
| + | p.addReference(" | ||
| + | helper.parse(p, | ||
| + | DefaultLogger consoleLogger = new DefaultLogger(); | ||
| + | consoleLogger.setErrorPrintStream(System.err); | ||
| + | consoleLogger.setOutputPrintStream(System.out); | ||
| + | consoleLogger.setMessageOutputLevel(Project.MSG_INFO); | ||
| + | p.addBuildListener(consoleLogger); | ||
| + | p.executeTarget(p.getDefaultTarget()); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
tips/java/callant.txt · Last modified: by erik
