Nick's Tech Blog: ANT > default 'help' target

Pages

Friday, August 31, 2012

ANT > default 'help' target

Problem

I want the default target for ant™, to display the project help.

Solution

Add the following default target:
<?xml version="1.0" encoding="UTF-8"?>
<project default="help" name="test" xmlns="antlib:org.apache.tools.ant">
         
  <target name="help" description="print the help">
    <exec executable="${ant.home}/bin/ant">
      <arg value="-projecthelp"/>
      <arg value="-buildfile"/>
      <arg value="${ant.file}"/>
    </exec>
  </target>
  
</project> 

This allows us to display the help using the following commands.
ant
ant help
ant -buildfile somefile.xml

Improved from the following website:
http://amazing-development.com/archives/2005/01/28/ant-help-target/

No comments:

Post a Comment