Building UML development projects by using Ant scripts

You can use build scripts, such as Ant tasks, to run project builds. There are many preconfigured Ant tasks that you can use, including tasks from the Eclipse platform. You can also create your own custom Ant tasks.

About this task

This procedure describes three Ant scripts that you can use to run a transformation configuration and optionally build related target projects:

To run a build using an Ant task:

  1. Create a file in your project named build.xml.
  2. In the build.xml file, insert the code content from one of the three following Ant scripts:
    Ant script Attribute descriptions
    com.ibm.xtools.umldt.buildTransformationConfiguration Ant script:
    <?xml version="1.0" encoding="UTF-8"?>
       <project name="myProject" default="build" basedir=".">
          <target name="build">
             <echo>Running transformation 'myProject/myConfig.tc' ...</echo>
             <com.ibm.xtools.umldt.buildTransformationConfiguration
                transformConfig   = "myProject/myConfig.tc"
                invokeTargetBuild = "incremental"
                markerFailureThreshold  = "error"/>
          </target>
    </project>

    transformConfig: The path of the transformation configuration. This attribute is required.

    invokeTargetBuild: An optional attribute that specifies the type of build to perform on the target projects of the transformation configuration. If this attribute is omitted (or has a value that is not in the list below) no actions are performed on the target projects. Possible values are as follows:
    • incremental: Performs an incremental build
    • full: to discard the existing builder state and rebuild everything from scratch
    • clean: to discard the existing builder state but not rebuild.

    markerFailureThreshold: An optional attribute that specifies the minimum marker severity that should cause the task to fail. This attribute only applies if the invokeTargetBuild attribute is specified as incremental or full. Possible values are info, warning, and error. Other values are ignored. After each target project is built, the severity of the markers on that project are checked. The presence of a problem with severity no less than the value of this attribute causes the task to fail with a message that identifies the offending project.

    com.ibm.xtools.transform.core.runTransformation Ant script:
    <?xml version="1.0" encoding="UTF-8"?>
       <project name="myProject" default="generate" basedir=".">
          <target name="generate">
             <echo>Running transformation 'myProject/myConfig.tc' ...</echo>
             <com.ibm.xtools.transform.core.runTransformation 
                transformConfig="myProject/myConfig.tc" reverse="false"/>
          </target>
    </project>

    Replace the myProject variable with the name of your target project and the myConfig.tc variable with the name of the transformation configuration file being referenced in that project.

    For transformation types that support a reverse transformation, to run the reverse transformation, set the reverse attribute to true.

    You can run multiple transformations by specifying additional <com.ibm.xtools.transform.core.runTransformation> elements in the build.xml file.

    eclipse.incrementalBuild Ant script:
    <?xml version="1.0" encoding="UTF-8"?>
       <project name="myProject" default="generate" basedir=".">
          <target name="generate">
             <echo>Running transformation ...</echo>
             <eclipse.incrementalBuild
                kind    = "kind"
                project = "myProject"
                builder = "com.ibm.xtools.umldt.core.internal.builders.UMLDevelopmentBuilder"/>
          </target>
    </project>
    kind: The kind of build to perform. Possible values are as follows:
    • incremental: Performs an incremental build
    • full: Discards the existing builder state and rebuilds everything from scratch
    • clean: Discards the existing builder state but does not rebuild

    project: Replace with the name of the project to be built

    builder: The name of the builder to run; if this value is not specified then all builders are run

  3. Save and then close the build.xml file.
  4. Optional: Customize the launch configuration settings for the Ant build.
    1. Right-click build.xml; then click Run As > External Tools Configurations.
    2. Create a new configuration or select an existing Ant Build configuration.
    3. Click the JRE tab; then under the Runtime JRE section, select Run in the same JRE as the workspace.
    4. Configure other optional launch settings for your environment.
    5. Click Apply; then click Close.
  5. Right-click build.xml; then click Run As > Ant Build.

Feedback