Making Your Build Files User Friendly

I’m working on a build file for the Model-Glue project and want to make it as user friendly as possible.  Turns out this is very easy in Ant!

First always include a description in your build file – you can be a bit more verbose, I kept this short for the example:


Ant script to create new Model-Glue 3.0 application.

Of course if anyone edits your build file they will see the description, but we can also display this when the build file is first run. First I make my default target ‘help’:


Then create a ‘help’ target:


This is simply running the exec task and running Ant with the ‘-p’ switch (which is short for ‘-projecthelp’ which simply prints a list of the build files targets as well as the description.  In all our other targets we’ll make sure to include a ‘description’:


Now if we run our build file we’ll see something like the following output (either at the command line or in the Eclipse console:

D:\>ant
Buildfile: build.xml

help:
 [exec] Buildfile: build.xml
 [exec]
 [exec] Ant script to create new Model-Glue 3.0 application
 [exec]
 [exec] Main targets:
 [exec]
 [exec]  build  Copy Model-Glue files to new project directory.
 [exec]  help   Displays a list of help to the user.
 [exec] Default target: help

Now the user can easily determine the purpose of the build file and see a list of possible targets to run.

Recent Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>