Working with Ant
Ant support is provided as a built-in feature of the workbench. If you right-click any XML file and select Run Ant from the pop-up menu, the Execute Ant Script dialog shows the available Ant targets. You can check, in sequence, which ones are to be executed, and the execution sequence will be shown beside each target. You can also select Display execution log to Ant console, which will cause any Ant messages to be displayed in the Ant Console view (PerspectiveShow ViewOtherAntAnt Console).
In addition, an Arguments field lets you pass arguments, such as -verbose, to the Ant program. If the Ant script invokes the Ant javac task, then a special -Dbuild.compiler=org.eclipse.pde.internal.core.JDTCompilerAdapter argument must be passed or you will get a Cannot use classic compiler error.
If you use the the deprecation="on" option for the javac Ant task, WebSphere Studio will crash. You should either specify nothing or use deprecation="off".
More information about Ant and how to use it with WebSphere Studio can be found in the following series of articles:
- Using Ant with WebSphere Studio Application Developer: Part 1 of 3
- Using Ant with WebSphere Studio Application Developer: Part 2 of 3
- Using Ant with WebSphere Studio Application Developer: Part 3 of 3
- Create the following echo.xml file inside any project in your workspace:
<?xml version="1.0"?> <project name="Echo" default="echo" basedir="."> <target name="echo"> <echo message="HELLO from echo"/> </target> <target name="dir"> <echo message="dir of ${basedir}:"/> <exec dir="${basedir}" executable="cmd.exe"> <arg line="/c dir"/> </exec> </target> </project>- Right-click echo.xml and select Run Ant.
- The Run Ant dialog shows that you have two targets, echo and dir, and that echo[1] is the default target that will be executed. If you also select dir, it will change to dir[2] and it will be run as the second target. Ensure that Display execution log to Ant console is checked and click Finish. The script will then be run. The results are displayed in the Ant Console.
- Right-click echo.xml and select Run Ant to run it again. This time enter -verbose in the arguments entry field, then click Finish.
Try editing your echo.xml file to include the following bad target with a nonexistent task propertyBad:
<target name="bad"> <propertyBAD name="MyName" value="MyValue"/> </target>Right-click echo.xml and select Run Ant to run it again. Select bad as your target and click Finish. You will receive the following error message, listed twice: "Could not create task of type: propertyBad" in the Problems view. You can partly fix this by changing propertyBad to property, and then saving echo.xml. The errors in the Task view will remain, because the errors are Ant runtime errors. If you run Ant again, the error messages will disappear.
Ant support
This topic provides an overview of the Ant support provided in the workbench.Extended Ant Support - overview
You can use the Run ANT option to check your build environment or use the command line batch file provided for repetitive builds.Running Ant in a headless workspace
You can use Ant to run a workbench with no interface and run specified Ant scripts.Upgrading Ant
Ant 1.6.1 is provided with this product. If you need functionality from a different version of Ant, you can download and install an updated version.Example: Automated Ant build
This example program shows a typical automated build using the workbench Ant tasks.Example: Automated Ant deploy
This example program shows a typical automated deployment using the WebSphere Application Server Ant tasks.