| <project |
| name="getModel" |
| basedir="."> |
| |
| <!-- |
| This file and its additional targets is not |
| required when running on Hudson. |
| It is primarily "left over" from doing builds as cronjobs. |
| It is left here in source tree in case anyone finds it useful |
| when running from command line, or similar. |
| |
| To make use of it, one needs to specify two targets on ant command line, |
| first 'getModelFromGit', and then one of the three main targets of build.xml. |
| The 'getModelFromGit' will either clone the 'simrel.build' project or pull the |
| latest revision. Note: if using from with the Eclpse IDE and you have changed |
| your "*.aggrcon" file, you should "commit" (but not push) it so that is survives |
| the "pull". |
| |
| Example usage: |
| ant -f fetchAndBuild.xml getModelFromGit runAggregatorValidateOnly |
| --> |
| |
| <import file="build.xml" /> |
| |
| <target |
| name="getModelFromGit" |
| description="This target is left over from doing cronjobs or running from command line. Is not required with running from Hudson" |
| depends="getBUILD_HOME, init, initBranch, cloneRepo, configRepo, pullRepo, getModelFromGerrit" |
| unless="modelRetrived"> |
| |
| <!-- |
| While Hudson normally does clone and 'pull' |
| we provide these methods in "fetchAndbuild.xml", |
| to ease some command line methods of running. |
| --> |
| |
| <git-checkout |
| dir="${buildModelDir}" |
| commit="${commitOrBranch}" /> |
| <echo message="checked out ${commitOrBranch} of org.eclipse.simrel.build into ${buildModelDir}" /> |
| |
| <property |
| name="modelRetrived" |
| value="true" /> |
| </target> |
| |
| <!-- Similar to getModelFromGit, but need to ?merge? refspec into local |
| branch --> |
| <target |
| name="getModelFromGerrit" |
| depends="init, cloneRepo, configRepo, pullRepo" |
| if="GERRIT_REFSPEC" |
| unless="modelRetrived"> |
| <!-- While Hudson normally does clone and 'pull', we "check" here to |
| make |
| sure. In particular, in some cases, a build might be triggered by a |
| change |
| in "tools" repo, so even then we want to make sure to get 'latest' |
| of "build" |
| repo. In both cases, we *then* want to get a specific revision, if |
| passed |
| to us by a previous job. This is so that the various jobs we have, |
| 'validate', |
| 'build', and 'build_clean' can all work on the same revision. --> |
| <git-checkout-refspec |
| dir="${buildModelDir}" |
| branch="${commitOrBranch}" |
| refspec="${GERRIT_REFSPEC}" /> |
| <echo message="checked out ${commitOrBranch} with ${GERRIT_REFSPEC} for org.eclipse.simrel.build into ${buildModelDir}" /> |
| |
| <property |
| name="modelRetrived" |
| value="true" /> |
| </target> |
| <macrodef name="git-clone"> |
| <attribute name="repository" /> |
| <attribute name="dir" /> |
| <attribute name="branch" /> |
| <sequential> |
| <echo message="execute git in @{dir}" /> |
| <echo message="git clone -b @{branch} @{repository} --config core.autocrlf=input --config merge.defaultToUpstream=true" /> |
| <exec |
| executable="git" |
| failonerror="true" |
| resultproperty="cloneResult" |
| dir="@{dir}"> |
| <arg line="clone -b @{branch} @{repository} --config core.autocrlf=input --config merge.defaultToUpstream=true" /> |
| </exec> |
| <antcall target="checkStatus"> |
| <param |
| name="status" |
| value="${cloneResult}" /> |
| <param |
| name="message" |
| value="Cloning Failed" /> |
| </antcall> |
| </sequential> |
| </macrodef> |
| |
| <!-- We do modify the source tree during build, to change URLs to local |
| file system, if building on build.eclipse.org, so need to 'clean' and |
| 'reset' |
| before pull. For pull we always do a fetch followed by a checkout, in |
| case |
| we change branches in Hudson job, etc. ... say, to do a "Luna_maintenance_patch". --> |
| <macrodef name="git-pull"> |
| <attribute name="dir" /> |
| <attribute name="branch" /> |
| <sequential> |
| <echo message="Doing git-pull task: " /> |
| <echo message=" dir: @{dir}" /> |
| <echo message=" branch: @{branch}" /> |
| <echo message=" = = = execute git clean in @{dir}" /> |
| <echo message="git clean -d -ff -x" /> |
| <exec |
| executable="git" |
| failonerror="true" |
| resultproperty="RCclean" |
| dir="@{dir}"> |
| <arg line="clean -d -ff -x" /> |
| </exec> |
| <antcall target="checkStatus"> |
| <param |
| name="status" |
| value="${RCclean}" /> |
| <param |
| name="message" |
| value="Cleaning Failed" /> |
| </antcall> |
| <echo message=" === doing git reset --hard" /> |
| <exec |
| executable="git" |
| failonerror="true" |
| resultproperty="RCreset" |
| dir="@{dir}"> |
| <arg line="reset --hard" /> |
| </exec> |
| <antcall target="checkStatus"> |
| <param |
| name="status" |
| value="${RCreset}" /> |
| <param |
| name="message" |
| value="Reset Failed" /> |
| </antcall> |
| <echo message=" === git fetch --all --prune" /> |
| <exec |
| executable="git" |
| failonerror="true" |
| resultproperty="RCfetch" |
| dir="@{dir}"> |
| <arg line="fetch --all --prune" /> |
| </exec> |
| |
| <antcall target="checkStatus"> |
| <param |
| name="status" |
| value="${RCfetch}" /> |
| <param |
| name="message" |
| value="fetch Failed" /> |
| </antcall> |
| |
| <echo message=" === git checkout -B @{branch}" /> |
| <exec |
| executable="git" |
| failonerror="true" |
| resultproperty="RCcheckout" |
| dir="@{dir}"> |
| <arg line="checkout -f -B @{branch}" /> |
| </exec> |
| <antcall target="checkStatus"> |
| <param |
| name="status" |
| value="${RCcheckout}" /> |
| <param |
| name="message" |
| value="Checkout Failed" /> |
| </antcall> |
| </sequential> |
| </macrodef> |
| |
| <!-- This can leave repo in "detached" state, which, shouldn't hurt anything |
| we're doing, as long as Hudson can check out/clone branch the next time |
| the |
| job runs. --> |
| <macrodef name="git-checkout"> |
| <attribute name="dir" /> |
| <attribute name="commit" /> |
| <sequential> |
| <echo message="execute git checkout @{commit} in @{dir}" /> |
| <exec |
| executable="git" |
| failonerror="true" |
| resultproperty="RCcheckout" |
| dir="@{dir}"> |
| <arg line="checkout @{commit}" /> |
| </exec> |
| <antcall target="checkStatus"> |
| <param |
| name="status" |
| value="${RCcheckout}" /> |
| <param |
| name="message" |
| value="Checkout Failed" /> |
| </antcall> |
| </sequential> |
| </macrodef> |
| |
| <macrodef name="git-checkout-refspec"> |
| <attribute name="dir" /> |
| <attribute name="branch" /> |
| <attribute name="refspec" /> |
| <sequential> |
| <echo message="execute git fetch --force origin +@{refspec}:@{branch} in @{dir}" /> |
| <condition property="branchesNotEqual"> |
| <not> |
| <equals |
| casesensitive="true" |
| arg1="@{branch}" |
| arg2="${GERRIT_BRANCH}" |
| forcestring="true" /> |
| </not> |
| </condition> |
| <fail |
| if="branchesNotEqual" |
| message="FAILED: Sanity check of variables found branch, @{branch}, is not equal to Gerrit branch, ${GERRIT_BRANCH}, as expected" /> |
| <echo message="Git Version:" /> |
| <exec executable="git"> |
| <arg line="--version" /> |
| </exec> |
| <exec |
| executable="git" |
| failonerror="true" |
| resultproperty="RCfetchRefspec" |
| dir="@{dir}"> |
| <arg line="fetch --force origin +@{refspec}" /> |
| </exec> |
| <antcall target="checkStatus"> |
| <param |
| name="status" |
| value="${RCfetchRefspec}" /> |
| <param |
| name="message" |
| value="Checkout/Fetch of refspec FAILED" /> |
| </antcall> |
| <exec |
| executable="git" |
| failonerror="true" |
| resultproperty="RCfetchRefspecPull" |
| dir="@{dir}"> |
| <arg line="merge FETCH_HEAD" /> |
| </exec> |
| <antcall target="checkStatus"> |
| <param |
| name="status" |
| value="${RCfetchRefspecPull}" /> |
| <param |
| name="message" |
| value="Checkout/Fetch/Pull of refspec FAILED" /> |
| </antcall> |
| </sequential> |
| </macrodef> |
| |
| <!-- We never really need/use 'clone' when on Hudson. We do use "pull", |
| to make sure "current", and then in main task we "checkout" the exact |
| commit |
| we want. This is primarily so that all tasks (validate, build-with-Cache, |
| and build-Clean, all operate on exact same input). [Though, still need |
| "exact" |
| input in aggrcon files, for that to be completely valid.] --> |
| |
| <target |
| name="cloneRepo" |
| depends="init" |
| unless="localRepoExists"> |
| |
| <echo message="git clone task for org.eclipse.simrel.build to execute in ${BUILD_HOME} using branch ${BRANCH_BUILD}" /> |
| |
| <git-clone |
| repository="${git_protocol}/gitroot/simrel/org.eclipse.simrel.build.git" |
| dir="${BUILD_HOME}" |
| branch="${BRANCH_BUILD}" /> |
| |
| <property |
| name="localRepoExists" |
| value="true" /> |
| |
| </target> |
| |
| <target |
| name="pullRepo" |
| depends="init" |
| if="localRepoExists" |
| unless="buildRepoPulled"> |
| <echo message="git pull task to execute in ${buildModelDir}" /> |
| <!-- in macro "pull", we actually do a fetch, then check out --> |
| <git-pull |
| dir="${buildModelDir}" |
| branch="${BRANCH_BUILD}" /> |
| <property |
| name="buildRepoPulled" |
| value="true" /> |
| |
| </target> |
| |
| <target name="initBranch"> |
| <!-- |
| By default we assume "master". Therefore, for update releases we |
| need to specify BRANCH_BUILD on command line, such as -DBUILD_BRANCH=Neon_maintenance --> |
| <property |
| name="BRANCH_BUILD" |
| value="master" /> |
| |
| <!-- in general, several sources for "commit or Branch" for the main 'commit'. --> |
| <condition |
| property="commitOrBranch" |
| value="${GERRIT_BRANCH}"> |
| <isset property="GERRIT_BRANCH" /> |
| </condition> |
| <condition |
| property="commitOrBranch" |
| value="${commit}" |
| else="${BRANCH_BUILD}"> |
| <isset property="commit" /> |
| </condition> |
| |
| </target> |
| </project> |