Chapter 14 Working with Java


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 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 chapter Extended Model Definitions Reference Guide, in the Advanced User Documentation .

For more information on how to import extended model definitions, see section 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.

 


Copyright (C) 2005. Sybase Inc. All rights reserved.