Common Build Infrastructure/Getting Started/Build In Hudson/Ant Script

From Eclipsepedia

Jump to: navigation, search

There are a few slight modifications to make to the ant script that will be used to build using Hudson.

1. In the build.properties file the following needs to be added:

writableBuildRoot=${WORKSPACE}/build

2. In the build.properties file the property settings for forceContext and fetchTag can be set or the values can be specified in the build script. These settings control how the plugin qualifiers are created and where the code is retrieve (i.e. Head or if not specified according to your map entries).

3. In the ANT script by default in the Build from Eclipse script, the build directory is the same name as the BuildType and Timestamp of the build. However, this can leave extra directories laying around on Hudson taking up space. So it is recommended that this directory be set to something like athena:

<property name="buildDir" value="${writableBuildRoot}/athena" />

Note.png
Build Dir
This can also be set in the build.properties file as well.


4. (Optional) If their are long delays between when the build actuall finishes the last target and the cleanup step, an alternative custom cleanup step can be created to delete specific items. Athena uses the <fileset> option in many places and depending on the size of the directories and number of files, this can take a long time to do cleanups. See sample ant script for an alternative.

Sample Build.properties


## BEGIN PROJECT BUILD PROPERTIES ##

# default settings for all this project's builds, for this branch; see also o.e.d.common.releng/build.properties for more overrideable defaults

# To permit automatic downloads of non-EPL compatible code, set this to property to "I accept"
thirdPartyDownloadLicenseAcceptance="I accept"

# MUST BE SET #
projectid=webtools.xpath2
zipPrefix=wst-xpath2-psychopath
incubation=
version=1.1.0
buildType=N
mainFeatureToBuildID=org.eclipse.wst.xml.xpath2.processor.feature
testFeatureToBuildID=org.eclipse.wst.xml.xpath2.processor_tests.feature

# MUST BE SET #
JAVA_HOME=/opt/public/common/ibm-java2-ppc-50
JAVA50_HOME=/opt/public/common/ibm-java2-ppc-50
dependencyURLs=http://download.eclipse.org/eclipse/downloads/drops/R-3.5-200906111540/eclipse-SDK-3.5-linux-gtk-ppc.tar.gz,http://download.eclipse.org/tools/orbit/downloads/drops/R20090825191606/orbit-R20090825191606.zip,http://downloads.sourceforge.net/project/eclemma/06_EclEmma_Runtime_for_Equinox/1.1.0/org.eclemma.runtime.equinox_1.1.0.200908261008.zip


#what steps should we do? default: build.steps=buildUpdate,buildZips,buildTests,generateDigests,test,publish,cleanup
#build.steps=buildUpdate,buildZips,buildTests,generateDigests,test,publish,cleanup
build.steps=buildUpdate,buildZips,buildTests,generateDigests,test,publish

compilerArg=-enableJavadoc -encoding ISO-8859-1
flattenDependencies=true
parallelCompilation=true
generateFeatureVersionSuffix=true
individualSourceBundles=true

writableBuildRoot=${WORKSPACE}/build
## END PROJECT BUILD PROPERTIES ##

Sample Ant Script

The following is taken from the cbi-wtp-wst.xsl-psychopath build that is currently running on Athena. This build experienced a 20 minute delay at times in the cleanup process, and by switching to a customized cleanup target the cleanup improved (i.e. 20 minute delay cut down to 1 minute).

&lt;project default="run" name="org.eclipse.wst.xml.xpath2.releng/build.xml - Run a PsychoPath build using the Athena CBI">
	&lt;!-- load properties and set timestamp for the build -->
	&lt;property name="WORKSPACE" location="../../../../"/>
	&lt;property environment="env"/>
	&lt;property file="build.properties" />
	&lt;tstamp>
		&lt;format property="buildTimestamp" pattern="yyyyMMddHHmm" />
	&lt;/tstamp>
	&lt;property name="forceContextQualifier" value="v${buildTimestamp}" />
	&lt;property name="fetchTag" value="HEAD" />
 
	&lt;!-- calculate workspaceDir as parent of this folder, the project's .releng folder (relengBuilderDir) -->
	&lt;property name="relengBuilderDir" value="${basedir}" />
	&lt;dirname file="${relengBuilderDir}" property="workspaceDir" />
 
	&lt;!-- 
		can build in /tmp, eg., in /tmp/build, or in workspace, eg.,
		${WORKSPACE}/build
	-->
	&lt;property name="writableBuildRoot" value="/tmp/build" />
 
	&lt;!-- 
		can be simple path, eg., 
		${writableBuildRoot}/${buildType}${buildTimestamp} or longer, eg.,
		${writableBuildRoot}/${topprojectName}/${projectName}/downloads/drops/${version}/${buildType}${buildTimestamp} or
		${writableBuildRoot}/${topprojectName}/${projectName}/${subprojectName}/downloads/drops/${version}/${buildType}${buildTimestamp}
	-->
	&lt;property name="buildDir" value="${writableBuildRoot}/athena" />
 
	&lt;target name="init">
		&lt;delete dir="${buildDir}" failonerror="false"/>
	&lt;/target>
 
	&lt;target name="run" depends="init">
		&lt;echo message="Workspace: ${WORKSPACE}"/>
		&lt;echo message="Writable Build Root: ${writableBuildRoot}"/>
		&lt;mkdir dir="${writableBuildRoot}"/>
		&lt;!-- invoke a new Eclipse process and launch the build from the common.releng folder -->
		&lt;property name="relengCommonBuilderDir" value="${workspaceDir}/org.eclipse.dash.common.releng" />
		&lt;ant antfile="${relengCommonBuilderDir}/buildAll.xml" target="runEclipse" dir="${relengCommonBuilderDir}" />
		&lt;antcall target="cleanUp" inheritall="true"/>
	&lt;/target>
 
	&lt;target name="cleanUp">
		&lt;delete dir="${buildDir}/eclipse" failonerror="false" />
		&lt;delete dir="${buildDir}/testing" failonerror="false" />
		&lt;delete dir="${buildDir}/compilelogs" failonerror="false"/>
		&lt;delete dir="${buildDir}/testResults/consolelogs" failonerror="false"/>
		&lt;delete dir="${buildDir}/testResults/html" failonerror="false"/>
		&lt;delete>
			&lt;fileset dir="${writableBuildRoot}">
				&lt;include name="*AllFeatures*.zip, *Master*.zip "/>
			&lt;/fileset>
		&lt;/delete>
	&lt;/target>	
&lt;/project>