-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource-prep.vm
124 lines (118 loc) · 4.13 KB
/
source-prep.vm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# 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 -XX:ParallelGCThreads=2 ${antEnvOpts}"
export M2_OPTS="-Xmx1g -XX:MaxPermSize=256m -XX:ParallelGCThreads=2 ${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 ]]
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
# update pom file
for token in $(echo $mavenArgs)
do
identify=$(echo $token| cut -c-2)
if [[ "${identify}" != "-P" ]]; then
comp_name=$(echo $token| cut -c 3-| cut -d"=" -f1| awk -F".version" '{print $1}')
comp_version=$(echo $token| cut -d"=" -f2)
if [[ "$comp_name" == "hive" ]]; then
hive_jar_version=$comp_version
else
# update pom
[[ ! -z "$comp_name" ]] && echo "Updating pom for $comp_name with $comp_version" && perl -pi -e "s/<${comp_name}.version>[^<]+</<${comp_name}.version>${comp_version}</g" pom.xml
fi
fi
done
mvn -B versions:set -DnewVersion=${hive_jar_version} $mavenBuildArgs
mvn -B clean install -DskipTests -Dmaven.repo.local=$workingDir/maven $mavenArgs $mavenTestArgs
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 $mavenTestArgs
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]}