blob: 7ce6c9ba74daac25c83ad222299051ebf636de12 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
A utility ant script get the base builder from Git (or CVS).
Hudson jobs (or builds) can call this script from generic ant
as one of it first build steps to get the eclipse antRunner, for example.
-->
<project
name="getBaseBuilder"
default="getBaseBuilder"
basedir=".">
<target
name="hudson-init"
if="hudson"
depends="checkHudson">
<!-- as of this writing, 04/22/2012, this was current list of
hudson provided variables. We take advantage of a number
of them, but "translate" them into our own variable names,
for a little loser build-system seperattion
BUILD_NUMBER
The current build number, such as "153"
BUILD_ID
The current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss)
JOB_NAME
Name of the project of this build, such as "foo"
BUILD_TAG
String of "hudson-${JOB_NAME}-${BUILD_NUMBER}". Convenient to put into a resource file, a jar file, etc for easier identification.
EXECUTOR_NUMBER
The unique number that identifies the current executor (among executors of the same machine) that's carrying out this build. This is the number you see in the "build executor status", except that the number starts from 0, not 1.
NODE_NAME
Name of the slave if the build is on a slave, or "" if run on master
NODE_LABELS
Whitespace-separated list of labels that the node is assigned.
JAVA_HOME
If your job is configured to use a specific JDK, this variable is set to the JAVA_HOME of the specified JDK. When this variable is set, PATH is also updated to have $JAVA_HOME/bin.
WORKSPACE
The absolute path of the workspace.
HUDSON_URL
Full URL of Hudson, like http://server:port/hudson/
BUILD_URL
Full URL of this build, like http://server:port/hudson/job/foo/15/
JOB_URL
Full URL of this job, like http://server:port/hudson/job/foo/
SVN_REVISION
For Subversion-based projects, this variable contains the revision number of the module.
CVS_BRANCH
For CVS-based projects, this variable contains the branch of the module. If CVS is configured to check out the trunk, this environment variable will not be set.
HUDSON_USER
Currently logged in user
-->
<property environment="hudson" />
<property
name="WORKSPACE"
value="${hudson.WORKSPACE}" />
<!--
<property
name="BUILD_ID"
value="${hudson.BUILD_ID}" />
<property
name="BUILD_NUMBER"
value="${hudson.BUILD_NUMBER}" />
<property
name="JOB_NAME"
value="${hudson.JOB_NAME}" />
-->
</target>
<target
name="init"
depends="hudson-init"
unless="getBaseBuilderInitialized">
<property environment="env" />
<condition
property="TMP"
value="${env.TMP_DIR}"
else="/tmp">
<isset property="env.TMP_DIR" />
</condition>
<echo message="TMP: ${TMP}" />
<!--
TODO: need make platform independendent, as in test.xml, to compute right one.
(and, pass in?)
(and make "version" variable)
-->
<property
name="platformURL"
value="http://download.eclipse.org/eclipse/downloads/drops4/R-4.3-201306052000" />
<!-- we currently use binary platform, since smaller, but could use SDK, if ever a reason to -->
<!-- moved to SDK to get API Tools -->
<property
name="platformFile"
value="eclipse-SDK-4.3-linux-gtk-x86_64.tar.gz" />
<property
name="buildTools.repository"
value="http://build.eclipse.org/eclipse/buildtools/" />
<property
name="webtools.repository"
value="http://download.eclipse.org/webtools/releng/repository/" />
<property
name="buildTools.feature"
value="org.eclipse.releng.build.tools.feature.feature.group" />
<property
name="webtools.feature"
value="org.eclipse.wtp.releng.tools.feature.feature.group" />
<!-- assign defaults if not on hudson, for local testing if nothing else -->
<property
name="WORKSPACE"
value="${basedir}" />
<property
name="builderVersion"
value="R38M6PlusRC3G" />
<property
name="cvsRoot"
value=":pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse" />
<property
name="cvsProject"
value="org.eclipse.releng.basebuilder" />
<!-- the desired folder name (made to stay consistent with cvs module name, though Git project
is named eclipse.platform.releng.basebuilder fil-->
<property
name="folderName"
value="org.eclipse.releng.basebuilder" />
<condition
property="fetchSource"
value="git">
<not>
<isset property="basebuilderlocal" />
</not>
</condition>
<echo message="hudson: ${hudson}" />
<echo message="WORKSPACE: ${WORKSPACE}" />
<echo message="basebuilder version: ${builderVersion}" />
<echo message="cvsRoot: ${cvsRoot}" />
<echo message="cvsProject: ${cvsProject}" />
<echo message="fetchSource: ${fetchSource}" />
<!-- leave useGit undefined to imply to use CVS. Callers can override git defaults with -DfetchSource=cvs
or, anything besides 'git' implies cvs.
-->
<condition
property="useGit"
value="true">
<equals
arg1="${fetchSource}"
arg2="git"
casesensitive="false"
trim="true" />
</condition>
<echo message="useGit: ${useGit}" />
<!-- don't need? yet
<echo message="BUILD_ID: ${BUILD_ID}" />
<echo message="BUILD_NUMBER: ${BUILD_NUMBER}" />
<echo message="JOB_NAME: ${JOB_NAME}" />
<echo message="buildId: ${buildId}" />
-->
<!-- not used? But, may want in future?
<condition
property="buildcleanarg"
value="-Dbuild.clean=${build.clean}"
else="">
<isset property="build.clean" />
</condition>
<condition
property="buildercleanarg"
value="-Dcheckout.builder.clean=${checkout.builder.clean}"
else="">
<isset property="checkout.builder.clean" />
</condition>
-->
<property
name="getBaseBuilderInitialized"
value="true" />
</target>
<target
name="getBaseBuilder"
depends="checkHudson, init">
<!-- remove old one, if there, and make sure one exists for eventual checkout/copy/globmapper -->
<delete dir="${WORKSPACE}/${folderName}" />
<mkdir dir="${WORKSPACE}/${folderName}" />
<antcall target="doGetBaseBuilder" />
<antcall target="fetchBasePlatform" />
</target>
<target
name="fetchBasePlatform"
depends="init"
if="platformURL">
<get
dest="${TMP}/${platformFile}"
src="${platformURL}/${platformFile}"
usetimestamp="true" />
<untar
compression="gzip"
src="${TMP}/${platformFile}"
dest="${TMP}">
</untar>
<chmod perm="ugo+x">
<fileset dir="${TMP}/eclipse">
<include name="eclipse" />
<include name="*.so*" />
</fileset>
</chmod>
<exec
dir="${TMP}/eclipse"
executable="${TMP}/eclipse/eclipse">
<arg value="-nosplash" />
<arg value="-debug" />
<arg value="-consolelog" />
<arg value="-data" />
<arg value="${WORKSPACE}/workspace-toolsinstall" />
<arg value="-application" />
<arg value="org.eclipse.equinox.p2.director" />
<arg value="-repository" />
<arg value="${buildTools.repository},${webtools.repository}" />
<arg value="-installIU" />
<arg value="${buildTools.feature},${webtools.feature}" />
<arg line="-vmargs -Djava.io.tmpdir=${TMP}" />
</exec>
<!-- we "move" so the directory structure so it flat under basebuilder ...
for compatibility to older code/scripts -->
<move todir="${WORKSPACE}/${folderName}">
<fileset dir="${TMP}/eclipse/">
<include name="**/*" />
</fileset>
</move>
<echo message="platform and tools installed, platform ${platformFile}, fetched using tychoeclipsebuilder/getBaseBuilderAndTools.xml" />
</target>
<target
name="doGetBaseBuilder"
unless="platformURL">
<antcall target="fetchBaseBuilder" />
<antcall target="fetchBaseBuilderLocal" />
<echo message="basebuilder, version ${builderVersion}, fetched using tychoeclipsebuilder/getBaseBuilderAndTools.xml" />
</target>
<!-- hurestic to check if we are running on hudson variable, if so -->
<target name="checkHudson">
<!-- HUDSON_USER should just be "anonyous" for most of our cases (currently)
but seems a safe variable to check ... if set, assume we are on hudson,
if not set, assume we are not and leave "hudson" unset (not false)
Hmm, seems HUDSON_USER is not reliably set. The only 4 I saw reliably
set were
[echoproperties] env.HUDSON_COOKIE
[echoproperties] env.HUDSON_HOME
[echoproperties] env.HUDSON_SERVER_COOKIE
[echoproperties] env.HUDSON_URL
Not sure which would be best/safest to use in huristic, but
I'll go with URL for now.
-->
<property environment="env" />
<condition property="hudson">
<isset property="env.HUDSON_URL" />
</condition>
</target>
<target
name="fetchBaseBuilderFromGit"
depends="init"
if="useGit">
<echo message="Fetching basebuilder from Git via CGit" />
<get
src="http://git.eclipse.org/c/platform/eclipse.platform.releng.basebuilder.git/snapshot/eclipse.platform.releng.basebuilder-${builderVersion}.zip"
dest="${WORKSPACE}/basebuilder-${builderVersion}.zip" />
<unzip
src="${WORKSPACE}/basebuilder-${builderVersion}.zip"
dest="${WORKSPACE}"
overwrite="true" />
<move todir="${WORKSPACE}/${folderName}">
<fileset dir="${WORKSPACE}/eclipse.platform.releng.basebuilder-${builderVersion}">
<include name="**/*" />
</fileset>
</move>
<chmod perm="ugo+x">
<fileset dir="${WORKSPACE}/${folderName}">
<include name="eclipse" />
<include name="*.so*" />
</fileset>
</chmod>
<!-- we've moved the files, now to remove the empty dir -->
<delete dir="${WORKSPACE}/eclipse.platform.releng.basebuilder-${builderVersion}" />
<!-- not sure why I couldn't get globmapper to work here with unzip?
<globmapper
from="eclipse.platform.releng.basebuilder-${builderVersion}/*"
to="${folderName}/*" />
-->
<!--
cleanup (may eventually want to "cache" this zip file, so no need to re-fetch if already exists
-->
<delete file="${WORKSPACE}/basebuilder-${builderVersion}.zip" />
</target>
<target
name="fetchBaseBuilderFromCVS"
depends="init"
unless="useGit">
<echo message="Fetching basebuilder from CVS" />
<cvs
cvsroot="${cvsRoot}"
command="export"
quiet="true"
dest="${WORKSPACE}"
tag="${builderVersion}"
package="${cvsProject}">
</cvs>
</target>
<target
name="fetchBaseBuilder"
depends="init, fetchBaseBuilderFromCVS, fetchBaseBuilderFromGit"
unless="basebuilderlocal">
<echo message="Fetched basebuilder to ${WORKSPACE}/${folderName}" />
</target>
<target
name="fetchBaseBuilderLocal"
depends="init"
if="basebuilderlocal"
unless="platformURL">
<unzip
src="${basebuilderlocal}/basebuilder-${builderVersion}.zip"
dest="${WORKSPACE}"
overwrite="true" />
<move todir="${WORKSPACE}/${folderName}">
<fileset dir="${WORKSPACE}/eclipse.platform.releng.basebuilder-${builderVersion}">
<include name="**/*" />
</fileset>
</move>
<chmod perm="ugo+x">
<fileset dir="${WORKSPACE}/${folderName}">
<include name="eclipse" />
<include name="*.so*" />
</fileset>
</chmod>
<echo message="Copied basebuilder to ${WORKSPACE}/${folderName}" />
</target>
</project>