Post Compile Exit

The Enterprise Extensions Dependency Build Post Compile Exit offers an extension point for customizing build processing. The Post Compile Exit is called after all compile processing - all languages defined to the build and all of their translators have completed - and before build map publishing and the build report is produced. This exit is called if the build is successful, if a simple compiler error has been encountered, or if some aspect of compile processing has encountered a build failure. Your exit code should take this into account when determining how to respond to the calling Enterprise Extensions build script. Determining which of the three possible outcomes the build has encountered is illustrated in the example exit below.

The Post Compile Exit allows you to insert additional logic into the build process to determine if the build, and all of the compiles, have completed successfully. If you determine that indeed the build was successful, you can signal to the Enterprise Extensions build script to complete as normal - publish build maps and generate a build report. If the compiles were not successful for some, regardless of the return code passed back to the build, you can signal to the Enterprise Extensions build script to complete in error. You can signal that the build is in error in two ways: set the publish build maps property to false or by only publishing build maps for the compiles not in error.

Enabling the Post Compile Exit

The Post Compile Exit is enabled by including the team.enterprise.build.ant.postCompileFile build property in the build definition. This property should identify the path to a build script on the build agent system that contains your Post Compile Exit code. This is an Ant script that you write to fulfill your customized post compile processing needs. The script should be encoded in UTF-8 the standard for all Ant scripts. The following is an example definition for the property:

team.enterprise.build.ant.postCompileFile=/u/dreilly/ant/testexit.xml
    

The Post Compile Exit can be as simple or as complex as is needed to meet your requirements. The only requirement for the exit is to set the team.enterprise.build.ant.postCompilePublish build property to false if the compiles were unsuccessful and none of the build maps are to be published or to true if the compiles were successful and all of the build maps are to be published. If this property is not set, it will default to false and build maps will not be published.

In the case where publishing should occur only for successful compiles, set team.enterprise.build.ant.postCompilePublish to true and set the team.enterprise.build.ant.postCompileReturn build property to a semicolon separated list of file versionable UUIDs that are in error and that should not have their build maps published.

Example Exits

Simple example

The following is a simple example which illustrates handling the three build result conditions:

<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed Materials - Property of IBM
    (c) Copyright IBM Corporation 2021. All Rights Reserved.
    
    Note to U.S. Government Users Restricted Rights:
    Use, duplication or disclosure restricted by GSA ADP Schedule
    Contract with IBM Corp.
-->
<project
    default="all"
    name="TestExit"
    xmlns:xt="antlib:com.ibm.team.build.extensions.toolkit">
    <description>Test Exit</description>
    
    <condition property="buildFailed" else="false">
        <isset property="team.enterprise.build.ant.exception"/>
    </condition>
    <condition property="compileFailed" else="false">
        <available file="${team.enterprise.scm.fetchDestination}/.compileErrorOccurred"/>
    </condition>
    <condition property="buildSuccessful">
        <and>
            <isfalse value="${buildFailed}"/>
            <isfalse value="${compileFailed}"/>
        </and>
    </condition>
    
    <!-- - - - - - - - - - - - - - - - - - - *
    *  TestExit init                         *
    *- - - - - - - - - - - - - - - - - - - -->
    <target name="init" description="init"/>
    
    <!-- - - - - - - - - - - - - - - - - - - *
    *  TestExit main                         *
    *- - - - - - - - - - - - - - - - - - - -->
    <target name="main" description="main">
        
        <echo>${team.enterprise.build.ant.postCompileFile}</echo>
        <echo>${team.enterprise.build.ant.postCompileReturn}</echo>
        <echo>${team.enterprise.build.ant.postCompilePublish}</echo>
        
        <property name="team.enterprise.build.ant.postCompileReturn" value=""/>
        <property name="team.enterprise.build.ant.postCompilePublish" value="true"/>
       
    </target>
    
    <!-- - - - - - - - - - - - - - - - - - - *
    *  TestExit term                         *
    *- - - - - - - - - - - - - - - - - - - -->
    <target name="term" description="term"/>
    
    <!-- Target called for manual test run -->
    <target depends="init,main,term" description="all" name="all"/>
</project>
    

Good build/Bad build Targets

The following example illustrates handling good and bad build results via targets:

<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed Materials - Property of IBM
    (c) Copyright IBM Corporation 2021. All Rights Reserved.
    
    Note to U.S. Government Users Restricted Rights:
    Use, duplication or disclosure restricted by GSA ADP Schedule
    Contract with IBM Corp.
-->
<project
    default="all"
    name="TestExit"
    xmlns:xt="antlib:com.ibm.team.build.extensions.toolkit">
    <description>Test Exit</description>
    
    <condition property="ewmBuildFailed" else="false">
        <or>
            <isset property="team.enterprise.build.ant.exception"/>
            <available file="${team.enterprise.scm.fetchDestination}/.compileErrorOccurred"/>
        </or>
    </condition>
    <condition property="ewmBuildSuccessful">
        <and>
            <isfalse value="${buildFailed}"/>
        </and>
    </condition>
    
    <!-- - - - - - - - - - - - - - - - - - - *
     * TestExit init                         *
     *- - - - - - - - - - - - - - - - - - - -->
    <target name="init" description="init"/>
    
    <!-- - - - - - - - - - - - - - - - - - - *
    * TestExit main                          *
    *- - - - - - - - - - - - - - - - - - - -->
    <target name="goodBuild" if="ewmBuildSuccessful" description="Build was good">
        
        <!-- Publish all build maps if EWM build successful -->
        <echo>${team.enterprise.build.ant.postCompileFile}</echo>
        <echo>${team.enterprise.build.ant.postCompileReturn}</echo>
        <echo>${team.enterprise.build.ant.postCompilePublish}</echo>
        
        <property name="team.enterprise.build.ant.postCompileReturn" value=""/>
        <property name="team.enterprise.build.ant.postCompilePublish" value="true"/>
        
    </target>
    
    <target name="badBuild" if="ewmBuildFailed" description="Build was bad">
        
        <!-- Publish no build maps if EWM build unsuccessful -->
        <echo>${team.enterprise.build.ant.postCompileFile}</echo>
        <echo>${team.enterprise.build.ant.postCompileReturn}</echo>
        <echo>${team.enterprise.build.ant.postCompilePublish}</echo>
        
        <property name="team.enterprise.build.ant.postCompileReturn" value=""/>
        <property name="team.enterprise.build.ant.postCompilePublish" value="false"/>
        
    </target>
    
    <!-- - - - - - - - - - - - - - - - - - - *
     * TestExit term                         *
     *- - - - - - - - - - - - - - - - - - - -->
    <target name="term" description="term"/>
    
    <!-- all  -  Default target definition -->
    <target depends="init,goodBuild,badBuild,term" description="all" name="all"/>
</project>
    

Partial publishing

The following example illustrates partially publishing build maps:

<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed Materials - Property of IBM
    (c) Copyright IBM Corporation 2021. All Rights Reserved.
    
    Note to U.S. Government Users Restricted Rights:
    Use, duplication or disclosure restricted by GSA ADP Schedule
    Contract with IBM Corp.
-->
<project
    default="all"
    name="TestExit"
    xmlns:xt="antlib:com.ibm.team.build.extensions.toolkit">
    <description>Test Exit</description>
    
    <!-- - - - - - - - - - - - - - - - - - - *
     * TestExit init                         *
     *- - - - - - - - - - - - - - - - - - - -->
    <target name="init" description="init"/>
    
    <!-- - - - - - - - - - - - - - - - - - - *
    * TestExit main                          *
    *- - - - - - - - - - - - - - - - - - - -->
    <target name="postCompileCheck" description="Set values regardless of EWM build">
        
        <!--
          Let EWM publish all successful build
          maps except for the three file UUIDs
          that specified below.
        -->
        
        <echo>${team.enterprise.build.ant.postCompileFile}</echo>
        <echo>${team.enterprise.build.ant.postCompileReturn}</echo>
        <echo>${team.enterprise.build.ant.postCompilePublish}</echo>
        
        <property name="team.enterprise.build.ant.postCompileReturn"
            value="_48LwoHyfEeuHVbdmprjUmw;_45fB8HyfEeuHVbdmprjUmw;_45dMwHyfEeuHVbdmprjUmw"/>
        <property name="team.enterprise.build.ant.postCompilePublish" value="true"/>
        
    </target>
    
    <!-- - - - - - - - - - - - - - - - - - - *
     * TestExit term                         *
     *- - - - - - - - - - - - - - - - - - - -->
    <target name="term" description="term"/>
    
    <!-- all  -  Default target definition -->
    <target depends="init,postCompileCheck,term" description="all" name="all"/>
</project>