blob: babc245e74fb5ac1e41d8de376d6f5d6ab9843f4 [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##### Remember this is a velocity template
set -e
set -x
if [[ -n "${javaHome}" ]]
then
export JAVA_HOME=$javaHome
export PATH=$JAVA_HOME/bin/:$PATH
fi
export ANT_OPTS="-Xmx1g -XX:MaxPermSize=256m ${antEnvOpts}"
export M2_OPTS="-Xmx1g -XX:MaxPermSize=256m ${mavenEnvOpts}"
cd $workingDir/
(
if [[ "$clearLibraryCache" == "true" ]]
then
rm -rf ivy maven
fi
mkdir -p maven ivy
if [[ "${repositoryType}" = "svn" ]]
then
if [[ -n "$branch" ]]
then
echo "Illegal argument for svn: branch '${branch}'."
exit 1
fi
if [[ -d ${repositoryName}-source ]] && [[ ! -d ${repositoryName}-source/.svn ]]
then
rm -rf ${repositoryName}-source
fi
if [[ ! -d ${repositoryName}-source ]]
then
svn co ${repository} ${repositoryName}-source
fi
cd ${repositoryName}-source
svn revert -R .
rm -rf $(svn status --no-ignore | egrep -v '^X|^Performing status on external' | awk '{print $2}')
svn update
elif [[ "${repositoryType}" = "git" ]]
then
if [[ -z "$branch" ]]
then
echo "Illegal argument for git: branch name is required."
exit 1
fi
if [[ -d ${repositoryName}-source ]] && [[ ! -d ${repositoryName}-source/.git ]]
then
rm -rf ${repositoryName}-source
fi
if [[ ! -d ${repositoryName}-source ]]
then
git clone $repository ${repositoryName}-source
fi
cd ${repositoryName}-source
git fetch origin
git reset --hard HEAD && git clean -f -d
git checkout $branch || git checkout -b $branch origin/$branch
git reset --hard origin/$branch
git merge --ff-only origin/$branch
git gc
else
echo "Unknown repository type '${repositoryType}'"
exit 1
fi
patchCommandPath=$workingDir/scratch/smart-apply-patch.sh
patchFilePath=$workingDir/scratch/build.patch
if [[ -f $patchFilePath ]]
then
chmod +x $patchCommandPath
$patchCommandPath $patchFilePath
fi
if [[ "${buildTool}" == "maven" ]]
then
rm -rf $workingDir/maven/org/apache/hive
mvn -B clean install -DskipTests -Dmaven.repo.local=$workingDir/maven $mavenArgs $mavenBuildArgs
mvn -B test -Dmaven.repo.local=$workingDir/maven -Dtest=TestDummy $mavenArgs $mavenTestArgs
cd itests
mvn -B clean install -DskipTests -Dmaven.repo.local=$workingDir/maven $mavenArgs $mavenBuildArgs
mvn -B test -Dmaven.repo.local=$workingDir/maven -Dtest=TestDummy $mavenArgs $mavenTestArgs
elif [[ "${buildTool}" == "ant" ]]
then
ant $antArgs -Divy.default.ivy.user.dir=$workingDir/ivy \
-Dmvn.local.repo=$workingDir/maven clean package test \
-Dtestcase=nothing
else
echo "Unknown build tool ${buildTool}"
exit 127
fi
) 2>&1 | tee $logDir/source-prep.txt
exit ${PIPESTATUS[0]}