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 the compilation processing, when all the languages defined for the build and all of their translators have completed, and before the build maps are published 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 the compilation processing has encountered a build failure. Your exit code must take the three possibilities into account when it determines how it responds to the calling Enterprise 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
whether the build, and all of the compilations, have completed successfully. If you determine that
the build was successful, you can signal to the Enterprise Build script to complete as normal:
publish build maps and generate a build report. If the compilations were not entirely successful,
regardless of the return code that was passed back to the build, you can signal to the Enterprise
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 publish only the build maps for the
successful compilations.
Enabling the Post Compile Exit
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 compilations were unsuccessful and none of the build maps
are to be published, or to true
if the compilations were successful and all of the
build maps are to be published. If this property is not set, it defaults to false
and build maps are not published.
- Set the team.enterprise.build.ant.postCompilePublish build property to
true
. - Set the team.enterprise.build.ant.postCompileReturn build property to a semicolon-separated list of file versionable UUIDs that are in error and whose build maps are not to be published.
Example Exits
Simple example
The following code illustrates how to handle the three build result conditions.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed Materials - Property of IBM
(c) Copyright IBM Corporation 2022. 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 or bad build targets
The following code illustrates how to handle good and bad build results through 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 code illustrates how to publish only some of the 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>