Working with Ant for Java Generation

Ant is a build utility like Make that uses a script named 'build.xml', through standard or vendor specific tasks that allows you to compile, create JAR/WAR/EAR, deploy, etc. to build an entire project. The supported version of Ant is 1.4. Ant supports dependencies, and incremental build.

With an Ant script, you can change a generated Java file, and then have Ant execute the build script. Only the modified Java files will be compiled and only the modified JAR/WAR files will be rebuilt and deployed.

You can download the Ant package from the Apache Web site, at http://www.apache.org. After installation, you should verify that the following environment variables are set:

set ANT_HOME=<Ant home path>
set PATH=%PATH%;%ANT_HOME%\bin

You can import extended model definitions to work with Ant into your model. Each extended model definition delivered with PowerDesigner corresponds to a specific target server; among them are EA Server, WebLogic, and Tomcat. They are located in the Resource Files/Extended Model Definitions directory of your installation.

For more information on extended model definitions, see "Extended Model Definitions" in the Resource Files and the Public Metamodel chapter of the Customizing and Extending PowerDesigner manual.

For more information on how to import extended model definitions, see Choosing a target application server.

When you import the Tomcat extended model definition into your model (Tomcat.XEM), you can generate the Ant script by clicking the Options tab in the Generation dialog box (available from Language > Generate Java code ), and set the option to generate the build.xml file to 'True'. You can also set a value onto the following Tomcat options:

Option

Description

Username

Name used to connect to the Tomcat server manager application

Password

Password used to connect to the Tomcat server manager application

Host name

Tomcat server name. The default value is 'localhost'

Port number

Server port number. The default value is 8080

You can click the Tasks tab of the Generation dialog box, and check one or several check boxes corresponding to Tomcat tasks. You can also preview the entire Ant script from the Preview page of the model property sheet.

At the end of the generation, the build.xml file will be generated in the generation directory.


Created October 7, 2009. Send feedback on this help topic to Sybase Technical Publications: pubs@sybase.com