Running an Ant target programmaticly


/ Published in: Groovy
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.