Posted By

narkisr on 11/24/08


Tagged

java ant groovy target


Versions (?)

Running an Ant target programmaticly


 / Published in: Groovy
 

An example on how to invoke Ant targets which are defined in build.xml.

  1. import org.apache.tools.ant.ProjectHelper
  2. import org.apache.tools.ant.Project
  3. import org.apache.tools.ant.BuildException
  4.  
  5. public void invoke(){
  6. File antFile = new File("build.xml")
  7.  
  8. Project project = new Project()
  9. project.init()
  10. ProjectHelper.projectHelper.parse(project, antFile)
  11.  
  12. try{
  13. project.executeTarget('echo-1')
  14. } catch (BuildException e) {
  15. println e.location
  16. }
  17. }

Report this snippet  

You need to login to post a comment.