| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| A utility ant script get the eclipse builder from Git. |
| |
| Hudson jobs can call this script from ant as one of it first build steps. |
| Such as, start with a wget fetch from CGit (where following $dash; is literally a '-', |
| it is escaped here just for XML rules against two dashes in a comment); |
| |
| wget -O getEBuilder.xml ‐‐no-verbose http://git.eclipse.org/c/platform/eclipse.platform.releng.aggregator.git/plain/production/testScripts/hudsonBootstrap/getEBuilder.xml |
| 2>&1 |
| |
| Then use ant to invoke the functionality. Example: |
| |
| ant -f getEBuilder.xml -EBUILDER_HASH=910fca82df3ea649ba8ee758259561582e13bf8b |
| |
| --> |
| <project |
| name="getEBuilder" |
| default="getEBuilder" |
| basedir="."> |
| |
| |
| <target |
| name="init" |
| depends="initWorkspace" |
| unless="getEBuilderInitialized"> |
| |
| <!-- assign defaults if not on hudson, for local testing if nothing else --> |
| <property |
| name="WORKSPACE" |
| value="${basedir}" /> |
| |
| <condition |
| property="gitHost" |
| value="${env.GIT_HOST}" |
| else="git.eclipse.org"> |
| <isset property="env.GIT_HOST" /> |
| </condition> |
| |
| <!-- normally provided by caller, but if not, assume master --> |
| <property |
| name="EBUILDER_HASH" |
| value="master" /> |
| |
| <!-- git is fall back, if no method set explicitly --> |
| <condition |
| property="fetchSource" |
| value="git"> |
| <and> |
| <not> |
| <isset property="EBuilderlocal" /> |
| </not> |
| <not> |
| <isset property="downloadURL" /> |
| </not> |
| </and> |
| </condition> |
| <property |
| name="scmProject" |
| value="eclipse.platform.releng.aggregator" /> |
| |
| <property |
| name="folderName" |
| value="eclipse.platform.releng.aggregator" /> |
| |
| <property |
| name="eScriptLocation" |
| value="${folderName}/production/testScripts" /> |
| |
| <echo message="=== Properties in 'getEBuilder.xml'" /> |
| <echo message=" WORKSPACE: ${WORKSPACE}" /> |
| <echo message=" folderName: ${folderName}" /> |
| <echo message=" eScriptLocation: ${eScriptLocation}" /> |
| <echo message=" scmProject: ${scmProject}" /> |
| <echo message=" EBUILDER_HASH: ${EBUILDER_HASH}" /> |
| <echo message=" The following are used, in order (if defined), to get 'production scripts'" /> |
| <echo message=" (fetchDirect from) downloadURL: ${downloadURL}" /> |
| <echo message=" (copy from local cache directory) EBuilderlocal: ${EBuilderlocal}" /> |
| <echo message=" fetchSource (from Git): ${fetchSource}" /> |
| |
| <property |
| name="getEBuilderInitialized" |
| value="true" /> |
| </target> |
| |
| |
| <target |
| name="getEBuilder" |
| depends="init"> |
| |
| <!-- remove old one, if there, and make sure directory exists for |
| eventual checkout/copy/globmapper |
| --> |
| <delete dir="${WORKSPACE}/${folderName}" /> |
| <mkdir dir="${WORKSPACE}/${folderName}" /> |
| |
| <antcall target="fetchEBuilder" /> |
| <antcall target="EBuildercleanup" /> |
| |
| <ant antfile="${WORKSPACE}/${eScriptLocation}/runTests2.xml" /> |
| |
| </target> |
| |
| <target |
| name="fetchEBuilderFromGit" |
| depends="init,fetchEBuilderLocal" |
| unless="EBuilderfetched"> |
| <echo message="Fetching EBuilder from Git via CGit" /> |
| <get |
| src="http://${gitHost}/c/platform/${scmProject}.git/snapshot/${scmProject}-${EBUILDER_HASH}.zip" |
| dest="${WORKSPACE}/${scmProject}-${EBUILDER_HASH}.zip" |
| httpusecaches="false" |
| verbose="true" /> |
| <unzip |
| src="${WORKSPACE}/${scmProject}-${EBUILDER_HASH}.zip" |
| dest="${WORKSPACE}/tempEBuilder/" |
| overwrite="true" /> |
| |
| <echo message="preparing to move ${WORKSPACE}/tempEBuilder" /> |
| <echo message=" into ${WORKSPACE}/${folderName}" /> |
| <echo message=" using regexp mapper" /> |
| <!-- We need only the 'production/testscripts' directory. And input can be of different "depths" depending on where it comes from. --> |
| <move |
| verbose="true" |
| todir="${WORKSPACE}/${folderName}"> |
| <fileset dir="${WORKSPACE}/tempEBuilder" /> |
| <mapper |
| type="regexp" |
| from=".*production([/\\])testScripts(.*)" |
| to="production\1testScripts\2" /> |
| </move> |
| |
| <echo message="Fetched EBuilder/production/testscrips to ${WORKSPACE}/${folderName}" /> |
| <property |
| name="EBuilderfetched" |
| value="true" /> |
| |
| </target> |
| |
| <!-- specify -DnoEBuildercleanup=true on command line, to have zip and folder left in place, |
| such as for debugging or desired to copy the zip to your local cache. |
| --> |
| <target |
| name="EBuildercleanup" |
| unless="noEBuildercleanup"> |
| |
| <!-- we've moved the files, now to remove the empty dir --> |
| <delete |
| dir="${WORKSPACE}/${scmProject}-${EBUILDER_HASH}" |
| failonerror="false" /> |
| |
| <!-- cleanup (may eventually want to "cache" this zip file, so no need to re-fetch if already exists --> |
| <delete |
| file="${WORKSPACE}/${scmProject}-${EBUILDER_HASH}.zip" |
| failonerror="false" /> |
| |
| <delete |
| dir="${WORKSPACE}/tempEBuilder" |
| failonerror="false" /> |
| <echo message="Cleaned temporary working copies" /> |
| |
| </target> |
| |
| <!-- Will leave here for now, though doesn't add much. It used to have an additional |
| "fetch from cvs task" (That is, we had three choices: local, git, cvs). |
| --> |
| <target |
| name="fetchEBuilder" |
| depends="init, fetchEBuilderFromGit" |
| unless="EBuilderfetched"> |
| <fail message="EBuilder was not fetched by any available method. Is a local variable not set?" /> |
| </target> |
| |
| <target |
| name="fetchEBuilderLocal" |
| depends="init,fetchEBuilderDirect" |
| if="EBuilderlocal" |
| unless="EBuilderfetched"> |
| <echo message="Fetching pre-made EBuilder subset from local machine." /> |
| <unzip |
| src="${EBuilderlocal}/${scmProject}-${EBUILDER_HASH}.zip" |
| dest="${WORKSPACE}" |
| overwrite="true" /> |
| |
| <move |
| todir="${WORKSPACE}/${folderName}" |
| failonerror="true"> |
| <fileset dir="${WORKSPACE}/${scmProject}-${EBUILDER_HASH}"> |
| <include name="**/*" /> |
| </fileset> |
| </move> |
| |
| <echo message="Copied EBuilder to ${WORKSPACE}/${folderName}" /> |
| <property |
| name="EBuilderfetched" |
| value="true" /> |
| </target> |
| <target |
| name="fetchEBuilderDirect" |
| depends="init" |
| if="downloadURL" |
| unless="EBuilderfetched"> |
| <echo message="Fetching pre-made EBuilder subset from download site." /> |
| <get |
| src="${downloadURL}/${scmProject}-${EBUILDER_HASH}.zip" |
| dest="${WORKSPACE}" |
| httpusecaches="false" |
| verbose="true" /> |
| |
| <available |
| file="${WORKSPACE}/${scmProject}-${EBUILDER_HASH}.zip" |
| property="EzipExists" /> |
| |
| <antcall target="unzipDownloadedZip" /> |
| |
| <condition property="EBuilderfetched"> |
| <available file="${WORKSPACE}/${folderName}/production" /> |
| </condition> |
| |
| </target> |
| |
| <target |
| name="unzipDownloadedZip" |
| if="EzipExists"> |
| |
| <echo message="Fetched EBuilder from ${downloadURL}" /> |
| <unzip |
| src="${WORKSPACE}/${scmProject}-${EBUILDER_HASH}.zip" |
| dest="${WORKSPACE}" |
| overwrite="true" /> |
| |
| <!-- Not sure this is needed, since 'folderName' and 'scmProject' are |
| the same. (At least, the defaults set in this script). |
| --> |
| <move todir="${WORKSPACE}/${folderName}"> |
| <fileset dir="${WORKSPACE}/${scmProject}"> |
| <include name="**/*" /> |
| </fileset> |
| </move> |
| <echo message="Moved EBuilder (subset) to ${WORKSPACE}/${folderName}" /> |
| |
| </target> |
| |
| |
| <target |
| name="initWorkspace" |
| unless="WORKSPACE"> |
| <property environment="env" /> |
| <condition |
| property="WORKSPACE" |
| value="${env.WORKSPACE}" |
| else="${basedir}"> |
| <isset property="env.WORKSPACE" /> |
| </condition> |
| </target> |
| </project> |