webAF uses Ant (http://ant.apache.org) to execute build tasks. The XML build file is automatically generated by webAF, with differing targets depending on your project type, and on any options that you have selected in the File Project Properties Build settings dialog box. When new source files are added to the project, rebuilding will automatically modify the build file to include the new files and make adjustments in the classpath as needed. Although the build file is generated and updated automatically, its design also allows certain types of direct user modifications, which are described later.
The Ant build file will be located in the Project directory, and will be named *_build.xml, where the asterisk (*) represents the project name.
The build target names can be displayed and run by selecting Build Project Tasks. For a Web application project, the following table lists standard targets:
Target | User Mod. |
Description |
---|---|---|
init | Yes | Initialization target. Most other targets have a dependency on this target. By default, it just executes the Ant tstamp (time stamp) task. |
precompile | Yes | User-defined pre-compilation target. The compile and releasecompile targets have a dependency on this target. You can modify these dependencies. By default, it does nothing. |
postcompile | Yes | User-defined post-compilation target. The compile and releasecompile targets have a dependency on this target. You can modify these dependencies. By default, it does nothing. |
compile | Yes | Debug compilation target. The all and package-war targets have a dependency on this target. You can modify these dependencies. By default, it runs the precompile, compileproject and postcompile targets. |
releasecompile | Yes | Release compilation target. The releaseall target has a dependency on this target. You can modify this dependency. By default, it runs the precompile, releasecompileproject and postcompile targets. |
all | Yes | Debug build all target. By default, it runs the clean and compile targets. |
releaseall | Yes | Release build all target. By default, it runs the clean and releasecompile targets. |
compileproject | No | Debug project compilation target. It runs the init target and compiles all project source files, normally with debug information generated. Select File Project Properties Build settings to modify how this target is auto-generated. |
releasecompileproject | No | Release project compilation target. It runs the init target and compiles all project source files, normally without generating debug information. Select File Project Properties Build settings to modify how this target is auto-generated. |
validate-webxml | No | Validates the deployment descriptor. It runs a custom Ant task to validate the project web.xml against the DTD. See Troubleshooting web.xml Errors. |
package-war | No | Generates the Web Application Archive. This target runs the validate-webxml target before generating the WAR file. It runs the JAR utility to create the .war file needed to deploy the Web application project, including a manifest.mf file. If a manifest.mf file exists in the project directory, it will be included; otherwise, a default manifest.mf will be auto-generated in the WAR file. |
clean-compiled-jsps | No | Removes .java and .class files compiled from JSP files. It does nothing if the Web server does not have a work directory (or does not have a Support class). If the Web server work directory is under the project directory, then the target directory is that work directory (removing files for all contexts). If the Web server work directory is not under the project, then the target directory will be the subdirectory of that work directory that matches the current context name. |
clean | No | Deletes .class files and .war file for the project. |
The "User Mod." Column in the table above indicates whether direct user edits to the *_build.xml file inside the given task will be retained when the project is rebuilt. Targets that do not allow user-modifications have a comment in the file immediately under the target name indicating the target is not user-modifiable.
The properties in the table below are predefined by webAF, and Ant will substitute the corresponding value for each wherever it occurs in the script.
Property | Meaning | Typical Example Value |
---|---|---|
${basedir} | Project directory | C:\AppDevStudio\webAF\Projects\MyProjName |
${webAppBaseDir} | Web application base directory | C:\AppDevStudio\webAF\Projects\MyProjName\webapp |
${packageSubDir} | Project package as sub-directory | com\mycompany\mypkg\ |
For example, ${webAppBaseDir}\WEB-INF\classes\${packageSubDir}MyBean.java
could be used in a user-added target to refer to a java source file in the
project's package. Note that ${packageSubDir} includes a trailing back slash.
Although the example value for ${webAppBaseDir} in the table above is located
under the project directory, it can be elsewhere.
<target name="my-target" depends="init"> <copy todir="${webAppBaseDir}/WEB-INF/"> <fileset dir="C:/MyFiles"> <include name="MyInfo.xml"/> </fileset> </copy> </target>
In the example above, ${webAppBaseDir}
will be replaced with the
full path to your webapp base directory when the target is run.
Note: In Version 3.0 of webAF, names of user-added targets, such as my-target in the example above, will not be displayed in the Build Project Tasks menu until the project is closed and re-opened.