Resources

SAS® AppDev Studio 3.0 Developer's Site

Standard and Custom Build Tasks

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 [arrow] Project Properties [arrow] 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.

Standard Build Targets for Web Applications

The build target names can be displayed and run by selecting Build [arrow] Project Tasks. For a Web application project, the following table lists standard targets:

TargetUser
Mod. 
Description
initYes Initialization target. Most other targets have a dependency on this target. By default, it just executes the Ant tstamp (time stamp) task.
precompileYes 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.
postcompileYes 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.
compileYes 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.
releasecompileYes 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.
allYes Debug build all target. By default, it runs the clean and compile targets.
releaseallYes Release build all target. By default, it runs the clean and releasecompile targets.
compileprojectNo 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.
releasecompileprojectNo 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-webxmlNo 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-warNo 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-jspsNo 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.
cleanNo 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.

Adding New Build Targets

There are three ways to modify the *_build.xml file: New targets can be added at any position in the file that is a child of the "project" element. Targets having a name attribute that starts with an underscore (_) will not be displayed in the list menu under Build [arrow] Project Tasks, so this is a handy way to hide sub-tasks.

Pre-defined properties for Web applications

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.

PropertyMeaningTypical 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.

Example of a user-generated build target

Suppose that you wanted to add a build target that would copy the latest version of file c:\MyFiles\MyInfo.xml to the WEB-INF directory of your Web application project. Inserting the following target into your *_build.xml file will accomplish this.
<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 [arrow] Project Tasks menu until the project is closed and re-opened.