AntForm and AntMenu are Java-based extensions for Apache Ant that add interactive GUI screens to command-driven build workflows. If you maintain legacy Ant build files, this guide will help you understand the two tasks, define them correctly, and run working examples with minimal trial and error.
Originally published on 2009-10-06; fully revised and updated.

What AntForm and AntMenu do
Apache Ant is widely used in Java build and automation pipelines. AntForm and AntMenu extend Ant with GUI-driven interaction for cases where runtime user input is required.
- AntForm: Shows a Swing form so users can enter or select values that are written into Ant properties.
- AntMenu: Shows a button-style menu that launches selected Ant targets.
In short, AntForm focuses on collecting properties, while AntMenu focuses on navigating and launching targets.
AntForm vs AntMenu at a glance
| Task | Primary purpose | User interaction | Typical output | Best use case |
|---|---|---|---|---|
| antform | Capture property values | Form fields (text, selection, boolean, multiline) | Ant properties set at runtime, optionally saved to a properties file | Build or deploy flows where user input drives later targets |
| antmenu | Launch targets from a menu | Buttons and links mapped to targets | Execution of selected Ant targets | Operator-facing entry points for multi-target build scripts |
Typical execution flow in an Ant build
flowchart TD
A[Run ant target] --> B[Load task definitions]
B --> C{Which task runs}
C -- antform --> D[Show Swing form]
D --> E[User submits values]
E --> F[Set Ant properties]
C -- antmenu --> G[Show button menu]
G --> H[User chooses target]
H --> I[Run selected target]
F --> I
This flow is useful when a script cannot be fully non-interactive and needs guided, structured user input.
Installation and task definition
After downloading the package, extract it to a directory such as antform.home. Then define tasks in your Ant build file so Ant can load classes from antform.jar.
<taskdef name="antform" classname="com.sardak.antform.AntForm"
classpath="${antform.home}/lib/antform.jar"/>
<taskdef name="antmenu" classname="com.sardak.antform.AntMenu"
classpath="${antform.home}/lib/antform.jar"/>Code language: HTML, XML (xml)
You can also load the provided task definitions resource instead of defining each task explicitly:
<taskdef resource="com/sardak/antform/taskdefs.properties"
classpath="${antform.home}/lib/antform.jar"/>Code language: HTML, XML (xml)
If antform.jar is copied into ${ant_home}/lib, explicit classpath references may not be required for each task definition.
Running the provided sample targets
The original package includes a sample build file named test.xml. With Ant and PATH configured, run:
ant -f test.xml test testmenu testne spinners password wizard1Code language: CSS (css)
To list available sample targets:
ant -f test.xml -pCode language: CSS (css)
Example: AntForm task for mail-style input
This sample form collects recipient, subject, message body, and a send flag, then stores values as Ant properties.
<antform title="Send Mail"
save="properties.txt"
image="doc/images/testlogo.jpg">
<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: "
property="recipient"
values="address1@somewhere.com; address2@somewhere.com; address4@somewhere.com"
separator=";"/>
<textProperty label="Subject : " property="subject"/>
<multilineTextProperty label="Message body: "
property="body"/>
<booleanProperty label="Send immediately: " property="send"/>
</antform>Code language: HTML, XML (xml)
Example: AntMenu task for target navigation
This sample defines a vertical menu that launches specific test targets.
<antmenu image="doc/images/logo-small.jpg"
title="AntForm and AntMenu tests">
<AntMenuItem name="AntMenu Tests">
<AntMenuItem name="Mail-type form" target="test"/>
<AntMenuItem name="Spinners and dateProperty test" target="spinners"/>
<AntMenuItem name="Test non-editable properties" target="testne"/>
<AntMenuItem name="Login and password test" target="password"/>
<AntMenuItem name="AntForm with inner menu test" target="afm"/>
<AntMenuItem name="Wizards test" target="wizard1"/>
</AntMenuItem>
<AntMenuItem name="AntMenu tests">
<AntMenuItem name="This test" target="testmenu"/>
</AntMenuItem>
<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"/>
</antmenu>Code language: HTML, XML (xml)
Best practices for legacy Ant GUI tasks
- Keep AntForm and AntMenu usage limited to workflows that genuinely need operator input.
- Store reusable defaults in properties files, then override only what users must change.
- Use clear labels and predictable target names to reduce operator mistakes.
- Test in an environment with desktop UI support, since AntForm uses Swing components.
- Document a non-GUI fallback target when possible for automation and CI jobs.
More information: http://antforms.sourceforge.net/
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals