Previous Next vertical dots separating previous/next from contents/index/pdf

Creating Custom Ant Build Files for an Application

If you want to extend or modify the standard build process, Workshop for WebLogic will export an Ant script that duplicates the standard application build. You can then modify the Ant script as needed and do command line builds. Modifying the generated Ant script does not alter the build process within Workshop for WebLogic.

Ant Build Script Functionality

Workshop for WebLogic generates the following types of Ant build scripts:

The exported Ant script contains a set of standard targets for building, assembling, staging and generating module archives. You can view the targets supported for a specific script with the command ant -projecthelp. The functionality of these targets is detailed in the following table.

Supported Ant Targets

TargetDependenciesDetails
build   Compiles the source files; does not package the results. The target in an EAR project's Ant script builds all child module projects in dependency order.
assemble build(a formal dependency does not exist on "build" but that target must be called prior to asssemble) Assembles the project for iterative dev deployment; requires that the "ear.root" property is specified. The target in an EAR project's Ant script assembles all child module projects.
stage build(a formal dependency does not exist on "build" but that target must be called prior to stage) Copies all of project's resources and build artifacts into a form that's ready for archive creation; staging directory can be overridden via the "staging.dir" property. The target in an EAR project's Ant script stages all child module projects.
archive stage Creates an archive containing all projects's resources and build artifacts; archive name and location can be overridden via the "archive.path" property. Note that the archive target builds an EAR file if run from an EAR script; if run from an Ant script generated from a web project, it generates a WAR file.
clean   Removes the files and directories generated by the build target

Generating Ant Build Scripts

To Export an Ant Build Script for a Project:

  1. Right click on the project name in the Package Explorer view and choose Export to display the Select dialog.
  2. Choose Workshop Ant Script. Click Next.
  3. In the Ant Script Generators: pane, click on the type of Ant script to generate:
  4. In the File Name box, choose the path and file name for the generated Ant script. Click Finish.

To Export an Ant Build Script for an Application:

To generate Ant scripts for an entire application, right click on each project name and generate the Ant script for each member project (web, utility, and EJB projects) individually. Then right click on the EAR project and generate the Ant script.

To Generate the Workspace Metadata File:

If you want to run your Ant scripts on a remote machine that does not have access to the workspace, you must first generate a workspace metadata file:

  1. Choose File > Export to display the Select dialog.
  2. Choose Workspace Metadata for Workshop Ant Script . Click Next.
  3. From the Select Projects dialog:
    • On the Projects pane, choose the projects to use when creating the workspace metadata file.
    • In the Export Destination box specify the location and name for the workspace metadata file.

    Click Next to continue.

  4. On the final screen, The wl.home and workspace.dir will be automatically populated. The purpose of that screen is to define variables to relativize absolute paths that would be written into the metadata file. The user can see the remaining absolute paths in the lower box. When a new variable is defined that covers a portion of one of the absolute paths, those absolute paths will be removed from that box. Every variable that’s defined at this point will need to be passed to the ant script at runtime using the -D syntax. Click Finish.

Caveats and Implementation Notes:

Executing Ant Build Scripts

To Build a Project by Running the Ant Script:

  1. Generate the Ant script for the project.
  2. Configure the execution environment of your shell by executing wl.home/common/bin/commEnv.cmd (or wl.home/common/bin/commEnv.sh for Linux).

    Use of the Ant scripts without prior execution of commEnv.cmd (commEnv.sh for Linux) is not currently supported
    .
  3. Change to the Eclipse project directory.
  4. Execute the desired Ant targets as follows (example illustrates the creation of the project archive):

    ant build archive -Dworkspace=workspacepath

    where the parameters are:

    workspacepath is the full path for the workspace folder (e.g., on Windows you might specify the path as C:/MyWork/Workspaces/MyApp) OR the full path and file name of the workspace metadata file.

    If your path names have embedded spaces, you must use quote marks to delimit the path name, e.g.,

    ant build -Dworkspace="C:\Documents and Settings\MyWorkspace"

To Build an EAR File Using the Ant Script:

  1. Generate the Ant script for each project in the EAR.
  2. Generate the Ant script for the EAR project.
  3. Configure the execution environment of your shell by executing wl.home/common/bin/commEnv.*
  4. Change to the Eclipse directory for the EAR project.
  5. Execute the desired target in the EAR project's Ant script as follows:

    ant build archive -Dworkspace=workspacepath

To Execute Ant Scripts on a Remote Machine:

  1. Generate the workspace metadata file as discussed above.
  2. Generate the necessary project Ant build scripts.
  3. Copy the following files to the remote machine:

    • the Ant script(s)
    • the workspace metatdata file
    • everything else in the project and/or ear file, minus the contents of the build directories
  4. Following the project or EAR build instructions above but specify the location of the workspace metadata file as the value of -Dworkspace= argument instead of the workspace directory location.

Caveats and Implementation Notes:

Related Topics

Understanding the Build Process

Apache Ant online Manual

 

Skip navigation bar   Back to Top