What are AntForm / AntMenu? Usage, Installation Process and Examples



AntForm is a java tool designed to add interaction to Ant scripts through graphical forms. If you’re new to Ant, start at the Ant site (see website: http://ant.apache.org/). Ant is used extensively used in the java world to automate system-level tasks, mostly (but not exclusively) as a software build system.

Why use AntForm?
Because automation can only be pushed so far until user input is required, the Ant developper will resort to prompting the user for certain property values at runtime. When the number of these properties increases and certain property values become dependant on others, it makes sense to divide the input into a flow of forms. AntForm enables you to do this.
In short, in keeping with the natural evolution of console-to-gui at the language level, AntForm ushers in the present-form paradigm where a read value view existed before.
The goal of the AntForm project is to provide a simple GUI that provides the following:
•    Input forms for modifying properties
•    Button-based menus that launch ant targets

What AntForm does
AntForm provides an Ant task (see usage) for setting property values through a Swing-based form. Properties are presented with a label on the left column and a widget field in the right column, one property per line. Each field component modifies an appointed Ant property when the form is submitted (i.e. the ok button clicked). Properties thus modified can be saved to a specified properties file and/or reused in other tasks. See screenshot

What AntMenu does
AntMenu provides an Ant task (see usage) that sets up a menu in a single vertical column for launching other ant targets. Each link to an Ant target is enabled by a button. See screenshot

After downloading the package, unzip it into a specific folder on your hard disk. Let’s call this folder AntForm_home for what follows.
In your Ant build file, create taskdef (task definitions) with a classpath referring to your ${antForm_home}/lib/AntForm.jar file, unless this file is copied into the base ${ant_home}/lib folder of your Ant distribution, in which case it doesn’t need to be referenced through the taskdef classpath attribute. The task definitions should look like this:
<taskdef name=”antform” classname=”com.sardak.antform.AntForm”
<taskdef name=”antmenu” classname=”com.sardak.antform.AntMenu”
You can also use the provided taskdefs.properties:
<taskdef resource=”com/sardak/antform/taskdefs.properties”

You’re ready to use the freshly-defined tasks in other ant targets. See AntForm and AntMenu for more information on the specificities if the antform and antmenu tasks.

There’s a sample and build file named test.xml in the root folder. If your ant_home and path environment variables are correctly set, you should be able to test the samples with the following command:
ant -f test.xml test testmenu testne spinners password wizard1
Use ant -f test.xml -p to see a list of other tests. These tests use other properties or behavioural characteristics and will show you more of what AntForm/AntMenu can do.

The following example generates properties for sending a mail.
<antform title=”Send Mail”
<label>To send a mail, use the following form. Pick a recipient,
type a subject and a body…the script will do the rest.</label>
<selectionProperty label=”Recipient: ”
values=”address1@somewhere.com; address2@somewhere.com; address4@somewhere.com”
<textProperty label=”Subject : ” property=”subject” />
<multilineTextProperty label=”Message body: ”
<booleanProperty label=”Send immediately: ” property=”send”/>

The following example generates a simple menu.
<antmenu image=”doc/images/logo-small.jpg”
title=”AntForm & AntMenu tests”>
<AntMenuItem name=”AntMenu Tests”>
<AntMenuItem name=”Mail-type form” target=”test”/>
<AntMenuItem name=”Spinners & dateProperty test” target=”spinners”/>
<AntMenuItem name=”Test non-editable properties” target=”testne”/>
<AntMenuItem name=”Login & password test” target=”password”/>
<AntMenuItem name=”AntForm with inner menu test” target=”afm”/>
<AntMenuItem name=”Wizards test” target=”wizard1″/>
<AntMenuItem name=”AntMenu tests”>
<AntMenuItem name=”This test” target=”testmenu”/>
<label>A short label with a few explanatory words concerning the menu at hand.</label>
<link label=”Echo 1 target” target=”echo1″/>
<link label=”Echo 2 target” target=”echo2″/>
<link label=”Echo 3 target” target=”echo3″/>
<link label=”End” target=”end”/>

More Info…

Rajesh Kumar
Follow me
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x