Running the AutoBuild sample within the product

The AutoBuild sample demonstrates the functions of the Rational® Application Developer for WebSphere® Software build utility (the build utility) that is included with the product installation files in two ways: from the workbench or command line. You can use the workbench to run the AutoBuild sample within an integrated development environment. Alternatively, you can run the AutoBuild sample using the command line (in headless mode) without opening the workbench at all.

About this task

You can find build utility samples in the IBM® Rational Software Delivery platform installation files under <installation_directory>\samples directory:
  • This graphic is a Windows icon. On Windows:c:\Program Files\IBM\SDP\samples
  • This graphic is a Linux icon. On Linux:/opt/IBM/SDP/samples
One of the build utility samples is the AutoBuild sample. Running the AutoBuild sample modifies its original files. A backup copy of the original AutoBuild sample is available in the AutoBuild.zip file under the samples directory:
  • This graphic is a Windows icon. On Windows:c:\Program Files\IBM\SDP\samples
  • This graphic is a Linux icon. On Linux:/opt/IBM/SDP/samples
Alternatively, a copy of the AutoBuild.zip is available from the Web at: http://www.ibm.com/support/docview.wss?uid=swg21319667

Procedure

  1. Create a workspace for your build utility session to store your projects and metadata in a folder, and run the Autobuild sample in the workbench or from the command line.
    Option Description
    Workbench Start the product. In the workspace Launcher dialog box specify a workspace folder in the workspace field.
    Command-line Open a command prompt and set the workspace environment variable. See To run your build scripts from the command-line section in the Running the build utility within the product topic.
  2. If you have already run the AutoBuild sample and want to run it again, you need to reset the environment:
    1. Verify that a directory is defined for the workspace and is empty. Remove any files and directories under the workspace that are from a previous run of the AutoBuild sample.
    2. Use the AutoBuild.zip backup copy to replace the following \samples\AutoBuild directory:
      • This graphic is a Windows icon. On Windows:c:\Program Files\IBM\SDP\samples\AutoBuild
      • This graphic is a Linux icon. On Linux:/opt/IBM/SDP/samples/AutoBuild
  3. Import the AutoBuild sample into your workspace:
    Option Description
    Workbench
    1. In the toolbar select File > New > Project.
    2. In the New Project wizard, expand the General folder and select Project. Click Next.
    3. In the Project name field, specify a label for your project that contains the AutoBuild sample. For example, type samples. Click Finish.
    4. In the toolbar, select File > New > Folder.
    5. In the New Folder wizard, verify the newly created project is specified in the Enter or select the parent folder field.
    6. Click Advanced.
    7. Select the Link to folder in the file system check box.
    8. Click Browse and navigate to the AutoBuild sample. For example:
      • This graphic is a Windows icon. On Windows:c:\Program Files\IBM\SDP\samples\AutoBuild
      • This graphic is a Linux icon. On Linux:/opt/IBM/SDP/samples/AutoBuild
    9. Click OK > Finish.
    Command-line Continue with the next step.
  4. To study what the AutoBuild sample does, open the AdderBuild.xml build script in a text editor. You can find it in the \samples\AutoBuild directory. This script file implements the following Ant tasks:
    init
    • Prints out information about the build including some of the variables that are defined
    • Builds the workspace
    importAndBuildEverything
    • Imports and builds all projects listed in the AdderBuildImport.psf file by calling projectSetImportAndBuild Ant task
    • Builds the workspace
    • Builds the AdderEJBClient_UtilJar.jar file
    • Imports and builds the AdderErrorWeb project to demonstrate a build failure
    projectSetImportAndBuild
    • Imports all the projects listed in the AdderBuildImport.psf file by calling projectSetImport
    • Builds all the projects listed in the AdderBuildImport.psf by calling projectSetBuild
    projectImportAndBuild
    • Imports the project projectName
    • Builds the project projectName
    DebugTraceHighlight
    • Prints out a debug message
  5. Run the AutoBuild sample.
    Option Description
    Workbench
    1. Right-click AdderBuild.xml file and select Run As > Ant Build ....
    2. By default the Targets tab opens of the Edit Configuration wizard. Under the Check targets to execute list, the importAndBuildEverything Ant task is selected to run first.
    3. Click the JRE tab. Under the Runtime JRE section, select Run in the same JRE as the Workspace option. Click Apply and then Run.
      Tip: By default the Separate JRE option is selected. The Run in the same JRE as the Workspace option enables the classpath of the workbench to access the additional Ant tasks that perform operations that are specific to the workbench, such as projectImport, projectBuild, workspaceBuild, ejbDeploy, or earExport. If your Ant build script uses any Ant tasks that perform workbench operations, verify that you selected the Run in the same JRE as the Workspace option; otherwise you might get the following error message in the Console view:
      Problem: failed to create task or type <Ant task>
      Cause: The name is undefined.
      Where <Ant task> is the name of the Ant task that perform workbench operations. See Ant tasks for workbench operations topic for a list of Ant tasks that perform operations specific to the workbench.
    Command-line You can study how the AutoBuild sample runs, open the buildAdderExample file in a text editor. You can find it in the \samples\AutoBuild directory. Look for the following command in the script:
    "%RUNANT_DIR%\..\..\bin\runant" -buildfile  "%RUNANT_DIR%\AdderBuild.xml" %*  importAndBuildEverything
    This command issues the runAnt command to start the build utility with the build script file AdderBuild.xml, and requests to start the importAndBuildEverything Ant task. Switch back to the command prompt and run the buildAdderExample command, for example:
    • This graphic is a Windows icon. On Windows:c:\Program Files\IBM\SDP\samples\AutoBuild>buildAdderExample.bat
    • This graphic is a Linux icon. On Linux:/opt/IBM/SDP/samples/AutoBuild>./buildAdderExample.sh
  6. In the AutoBuild sample there is a test for failure for the AdderErrorWeb project. If you receive a similar BUILD FAILED message for this AdderErrorWeb project, due to the test for failure you can safely ignore this message:
    buildECLIPSE:
         [echo] buildMASTER for AdderErrorWeb
    [projectBuild] Building: AdderErrorWeb (Begin)
    [projectBuild]  (Begin)
    [projectBuild]  (Done)
    [projectBuild]  (Begin)
    [projectBuild]  (Done)
    [projectBuild] The user operation is waiting for background work to complete. (Begin)
    [projectBuild] The user operation is waiting for background work to complete. (Done)
    [projectBuild] The user operation is waiting for background work to complete. (Begin)
    [projectBuild] The user operation is waiting for background work to complete. (Done)
    [projectGetErrors] ----------
    [projectGetErrors] 1. ERROR in \AdderErrorWeb\src\AdderJavaErrors.java
    [projectGetErrors] (at line 2)    org.eclipse.jdt.core.problem
    [projectGetErrors] The import xyz cannot be resolved
    [projectGetErrors] ----------
    [projectGetErrors] 2. ERROR in \AdderErrorWeb\src\AdderJavaErrors.java
    [projectGetErrors] (at line 5)    org.eclipse.jdt.core.problem
    [projectGetErrors] Syntax error on token "x", delete this token
    [projectGetErrors] ----------
    [projectGetErrors] 3. ERROR in \AdderErrorWeb\WebContent\AdderJspErrors.jsp
    [projectGetErrors] (at line 23)    org.eclipse.jst.jsp.core.validationMarker
    [projectGetErrors] badVariable cannot be resolved
    
    BUILD FAILED
    C:\IBM\SDP\7552\20100721_2133\samples\AutoBuild\AdderBuild.xml:110: The following error occurred while executing this line:
    C:\IBM\SDP\7552\20100721_2133\samples\AutoBuild\AdderBuild.xml:153: The following error occurred while executing this line:
    C:\IBM\SDP\7552\20100721_2133\samples\AutoBuild\AdderBuild.xml:163: The following error occurred while executing this line:
    C:\IBM\SDP\7552\20100721_2133\samples\AutoBuild\AdderErrorWeb\build.xml:18: The following error occurred while executing this line:
    C:\IBM\SDP\7552\20100721_2133\samples\AutoBuild\AdderBuild\buildMASTER.xml:173: The following error occurred while executing this line:
    C:\IBM\SDP\7552\20100721_2133\samples\AutoBuild\AdderBuild\buildMASTER.xml:43: FAIL-ON-ERROR.  projectName=AdderErrorWeb  errorCount=3  errorMessage[1]=The import xyz cannot be resolved
    
    Total time: 26 seconds
    HeadlessWorkspaceSettings: RESTORED autoBuild=true maxFile=1048576
    runAnt BUILD FAILED.
  7. The output for the AutoBuild sample is project archive files, such as the EAR, WAR, and JAR files. The output is located in the directory defined for your java.io.tmpdir property, which typically corresponds to your system's TMP environment variable. For example, you can find the following project archive files in the C:\Documents and Settings\Administrator\Local Settings\Temp directory; and /tmp or /var/tmp for Linux operating system:
    • Adder.ear
    • AdderClient.jar
    • AdderEJB.jar
    • AdderEJBClient_UtilJar.jar
    • AdderStaticWeb.war
    • AdderWeb.war
    Alternatively, you can determine the directory location of the output from the System Output of running the AutoBuild sample. For example, look for the following System Output in the command-prompt or in the Console view of the workbench:
    [ejbExport] EJBExport completed to /tmp/AdderEJB.jar
    ...
    [appClientExport] AppClientExport completed to /tmp/AdderClient.jar
    ...
    [warExport] WARExport completed to /tmp/AdderWeb.war
    ...
    In this example, the AdderEJB.jar, AdderClient.jar, and AdderWeb.war are located in the /tmp directory for a Linux operating system.

Feedback