Part 1 of this series explains the motivation and objectives of build automation, and describes the overall approach. Part 2 describes how you can implement this approach using Application Developer V4 with CVS as the code repository. This article, Part 3, shows how to set up automated builds using IBM ® WebSphere® Studio Application Developer V5 (hereafter called Application Developer), with IBM Rational® ClearCase as the software configuration management (SCM) system. While this article applies to ClearCase, the procedures and scripts described below can be used with CVS and other SCMs with relatively minor changes.
Here is a brief overview of the approach described in this article series:
- Developers work on projects in an Application Developer workspace, where they create code, make changes, and unit test. When satisfied with their code, developers copy their projects into the SCM.
- Builders add the names of any newly created projects to the list of projects to be included in the build.
- The automation process periodically runs and performs the following tasks within a single, batch-mode (headless) Application Developer Ant session:
- Extracts all projects to be included in the build from the SCM to a local directory
- Creates a new Application Developer workspace
- Imports each project into the new workspace
- Builds each project in turn
- Writes any build-time errors to a log output file
- Exports the executables to an appropriate location. This can be an FTP site or a mounted file system
Application Developer V5 includes the Ant tasks needed to do sub-steps 1-6 above, with the exception of steps 3 and 6.
To import projects into a workspace and export them via FTP, you must extend Application Developer using the plug-ins provided with this article.
ImportProject plug-in provides a new Ant task,
ImportProject, and it enables an Ant session
to import projects in a workspace just as selecting File => Import => Existing Project Into Workspace does in the user interface.
CommonsNet plug-in contains the Apache Jakarta project
Commons/Net internet protocol suite
Java™ library, packaged as a WebSphere Studio plug-in archive. The
makes it possible to FTP files from within an Ant session. The remaining Ant tasks in the build process use the
which is included in Application Developer V5, and described in detail in the article series
Using Ant with WebSphere Studio Application Developer.
Setting up the build machine
Setting up the machine used to run automated builds (the build machine) involves the following steps:
- Install Application Developer.
- Install the IBM Rational ClearCase client.
- Install the
- Install the
NetComponentsplug-in and JAR file (only if using FTP).
- Set up the build script files.
- Create a ClearCase view containing the projects to be built.
These steps are described in detail below.
Installing Application Developer
The build machine must have Application Developer installed on it. If the application to be built relies on the Programming Model Extensions in WebSphere Studio Application Developer Integration Edition, then the build machine should instead have Integration Edition installed. Rational ClearCase LT client is packaged with Application Developer, and can be installed when Application Developer is installed. You must configure Rational ClearCase client to point to the ClearCase server, which you can do during ClearCase client installation. This approach works on a build machine running either Windows® or Linux; this article assumes that the build machine is running Windows.
Installing the ImportProject plug-in
To install the plug-in that enables the
ImportProject Ant task, download the
and unzip it in the
WSAD_HOME is the root directory where Application Developer is installed.
Installing the NetComponents Plug-in and JAR
To copy the results of the build to the appropriate destination via FTP, you must install the NetComponents Java library, which is a documented library dependency
to the Ant ftp task. The version of Ant that comes with Application Developer V5 is Ant V1.5.3, which requires the
The latest version of Ant, V1.6.0, on the other hand, requires the
To install the
NetComponentsPlugin-1.3.8.zipand unzip the archive in the
<WSAD_HOME>/wstoolsdirectory. This will create the directory for the library file (
<WSAD_HOME>/wstools/eclipse/plugins/com.oroinc.net_1.3.8), and the necessary
plug-in.xml. Because of licensing restrictions, you need to download the actual library JAR file separately.
NetComponents-1.3.8.zipfrom http://www.savarese.org/oro/. Copy
NetComponents.jarfrom this archive into
Setting up the build script files
The next step is to extract the build script files from buildscripts.zip into a directory (such as
C:\Automation) on the build machine.
There are five files in this archive:
|The main executable that sets up the build environment and invokes Application Developer in headless mode.|
|The main Ant build file. Edit this file and add the names of each project that should be built.|
|A wrapper script for build.bat that is useful for running automated builds as a scheduled task.|
|An Ant build file containing the targets used to build Application Developer projects.|
|A configuration file containing variables used to set up the build environment.|
You must set several variables in the
setupBuild.bat file to match your environment:
WSAD_HOME variable to the root directory where Application Developer is installed:
rem WSAD 5.0 installation directory - use back slashes SET WSAD_HOME=C:\PROGRA~1\IBM\WSAD
CLEARCASE_HOME directory to the
bin directory of the Rational ClearCase installation:
rem ClearCase base directory (usually \PROGRA~1\Rational\CLEARC~1\bin) rem use back slashes SET CLEARCASE_HOME=C:\PROGRA~1\Rational\CLEARC~1\bin
AUTOMATION_HOME variable to the directory
buildscripts.zip archive was extracted:
rem Root directory of the automation scripts and workspaces rem (usually C:\Automation) rem use back slashes SET AUTOMATION_HOME=C:\Automation
to the hostname and port of the FTP server to which the results of the build will be copied:
rem FTP server SET FTP_SERVER=myftpserver rem FTP port (default port is 21) SET FTP_PORT=21
FTP_PASSWORD variables are used to authenticate to the FTP server:
rem FTP user ID SET FTP_USER=build rem FTP password rem If you "rem" out the following line, you will be prompted to enter rem the password. rem This means that you will not be able to run truly unattended build. SET FTP_PASSWORD=buildpass
FTP_REMOTEDIR variable is the location on the FTP server where the build results will be copied:
rem Directory on FTP server to upload the newly built files rem use forward slashes SET FTP_REMOTEDIR=/dailybuilds/%CLEARCASE_VOB%
Creating a ClearCase view
The last step in setting up the build machine is to create a suitable ClearCase view to the Versioned Object Base (VOB) containing the projects to be built. Name this view
CC_VOB is the name of the ClearCase VOB.
It should be located in the
AUTOMATION_HOME directory. For example, if the name of the VOB is projectVOB and the
AUTOMATION_HOME directory is
C:\Automation, then name the view
projectVOB_view, and put it in
Running a build
Before running a build, edit
build.xml and add an Ant task to the
buildAll target for each project to be built.
The format of these tasks is shown in the example below -- the three projects to be built are named
projectEAR, projectEJB, and projectWEB.
<target name="buildAll" depends="init"> <ant antfile="ProjectBuild.xml"><property name="project.name" value="projectEAR"/></ant> <ant antfile="ProjectBuild.xml"><property name="project.name" value="projectEJB"/></ant> <ant antfile="ProjectBuild.xml"><property name="project.name" value="projectWEB"/></ant> </target>
Important: Keep this list up-to-date as projects are added to the VOB. If there is no task for a project, it will not be included in the build.
To run a build from the command line, open a command prompt, navigate to the
build.bat, specifying the ClearCase VOB you want to build and the Ant targets you want to invoke:
C:\buildscripts> build <CLEARCASE_VOB> [ <Ant target> ] ...
For example, the following statement will build all of the projects listed in
C:\buildscripts> build cc_build_view buildAll
If you don't specify any Ant targets, you will be presented with a list describing all of the available targets:
To set up a Windows machine to automatically run a scheduled build without manual intervention, you must add a scheduled task that cleans up any previous builds and invokes a new build with the correct parameters. From the Windows Start menu, select Programs => Accessories => System Tools => Scheduled Tasks. Then select File => New and enter a sensible name such as Automated daily build. Double-click the new task and complete the fields as shown below:
The values above assume that
AUTOMATION_HOME = C:\Automation.
fullbuild.bat executable is a simple wrapper around
It removes old build data from the
AUTOMATION_HOME\dailybuilds directory and calls
init, extractCode, buildAll, and
From the Schedule tab, set the task to run when you want and click OK.
The build should now run automatically as scheduled.
Log data will be written to
as specified in the
This simple approach to build automation has proved successful on a number of development projects. The build process imports and builds Application Developer workspace projects just as developers do, and the resulting build artifacts are accurate, reliable, and repeatable.
The authors would like to thank Jim Thorpe, the author of the
ImportProject Ant task,
for his help in making automated builds a possibility.
|Code sample||buildscripts.zip ( HTTP | FTP )||6 KB|
|Code sample||ImportProject.zip ( HTTP | FTP )||23 KB|
|Code sample||NetComponentsPlugin-1.3.8.zip ( HTTP | FTP )||1 KB|
- Using Ant with WebSphere Studio Application Developer -- Part 1 of 3: How to run Ant both inside and outside Application Developer.
- Using Ant with WebSphere Studio Application Developer -- Part 2 of 3: How you can use special Ant tasks for Application Developer production Ant builds of J2EE modules
- Using Ant with WebSphere Studio Application Developer -- Part 3 of 3: How to add two Ant tasks to WebSphere Studio Application Developer