Skip to content

Commit b9f5d38

Browse files
rsafonsecaDaanHoogland
authored andcommitted
Improve plugin dependency download Add download for midonet and juniper stuff, this increases runtime for a few minutes, may remove in future if travis show too much overhead
Signed-off-by: Daan Hoogland <daan@onecht.net>
1 parent 0d671b9 commit b9f5d38

2 files changed

Lines changed: 90 additions & 36 deletions

File tree

‎tools/travis/before_install.sh‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,17 @@ done
110110

111111
#Resolve remaining deps
112112
cd tools/travis
113-
./downloadDeps.sh 2> /dev/null
114113
echo -e "\nDownloading Project dependencies"
115-
echo -e "$(cat pom.xml |wc -l) lines in dummy pom.xml"
116114

117115
for ((i=0;i<$RETRY_COUNT;i++))
118116
do
119-
mvn org.apache.maven.plugins:maven-dependency-plugin:resolve > /tmp/phase2
117+
./downloadDeps.sh > /tmp/phase2
120118
if [[ $? -eq 0 ]]; then
121-
echo -e "\nProject dependencies downloaded successfully"
119+
echo -e "\n$(cat cleandeps.out |wc -l) project dependencies downloaded successfully"
122120
break;
123121
fi
124122
echo -e "\nDependency download failed"
125-
cat /tmp/phase2
123+
cat /tmp/phase2 | grep -i -e "fail" -e "error" -e "exception"
126124
#Test DNS record
127125
getent hosts repo1.maven.org
128126
while ! nc -vzw 5 repo1.maven.org 80; do echo -e "\nFailed to connect to repo1.maven.org:80 will retry in 10 seconds"; sleep 10; done

‎tools/travis/downloadDeps.sh‎

Lines changed: 87 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
#Create dummy pom
2-
echo '<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.apache.cloudstack</groupId><artifactId>travis-build-deps</artifactId><name>Download Deps for Travis CI</name><version>1</version><dependencies>' > pom.xml
3-
4-
#Get all dependency blocks
5-
for line in $(find ../../ -name pom.xml -exec sed -n '/<dependencies>/{:a;n;/<\/dependencies>/b;p;ba}' {} \; | grep -e "artifactId" -e "groupId" -e "version" -e "dependency\>" -e "exclusion\>" -e "exclusions\>"); do
1+
for line in $(find ../../ -name pom.xml -exec sed -n '/<dependencies>/{:a;n;/<\/dependencies>/b;p;ba}' {} \; | grep -e "artifactId" -e "groupId" -e "version" -e "dependency\>" -e "exclusion\>" -e "exclusions\>"| sed -e 's/\^M//'); do
62

73
#Tokenize values
84
set -- $(echo $line | awk -v FS="(>|<)" '{print $2, $3}')
95

106
#Start processing data
117

12-
if [ $1 == "dependency" ]; then
8+
if [[ $1 == "dependency" ]]; then
139
#Create new artifact dep
14-
ARTIFACT=$line
15-
elif [ $1 == "/dependency" ]; then
16-
#Check if version is empty to fix maven 3.2.5 run
17-
if [[ $ARTIFACT != *version* ]]; then
18-
continue;
19-
fi
10+
unset ARTIFACT
11+
unset VERSION
12+
unset GROUP
13+
elif [[ $1 == "/dependency" ]]; then
2014
#Filter out project modules interdependencies and noredist artifacts
21-
if [[ $ARTIFACT != *org.apache.cloudstack* ]] && [[ $ARTIFACT != *com.cloud* ]] && [[ $ARTIFACT != *org.midonet* ]] && [[ $ARTIFACT != *net.juniper* ]] ; then
22-
echo $ARTIFACT$line >> pom.xml
15+
if [[ $GROUP != *org.apache.cloudstack* ]] && [[ $GROUP != *com.cloud* ]] && [[ $ARTIFACT != cloudstack-service-console-proxy-rdpclient ]]; then
16+
if [[ -z $VERSION ]] ; then
17+
VERSION=LATEST
18+
if [[ $GROUP == jstl ]] || [[ $ARTIFACT == mysql-connector-java ]] || [[ $GROUP == org.apache.axis ]]; then
19+
continue
20+
fi
21+
fi
22+
echo "$GROUP $ARTIFACT $VERSION" >> deps.out
2323
fi
24-
elif [ $1 == "version" ]; then
24+
elif [[ $1 == "version" ]]; then
2525
#If version is a maven var, get the value from parent pom
2626
if [[ $2 == \$\{* ]]; then
27-
28-
VER=$(grep \<$(echo $2 | awk -v FS="(}|{)" '{print $2 }') ../../pom.xml | awk -v FS="(>|<)" '{print $3}')
29-
if [[ "$VER" == "" ]]; then
30-
ARTIFACT=org.apache.cloudstack
31-
else
32-
ARTIFACT="$ARTIFACT<version>$VER</version>"
33-
fi
27+
VERSION=$(grep \<$(echo $2 | awk -v FS="(}|{)" '{print $2 }') ../../pom.xml | awk -v FS="(>|<)" '{print $3}')
3428
elif [[ "$2" == "" ]]; then
35-
ARTIFACT="$ARTIFACT<version>LATEST</version>"
29+
VERSION="LATEST"
3630
else
37-
ARTIFACT=$ARTIFACT$line
31+
VERSION=$2
3832
fi
39-
else
40-
ARTIFACT=$ARTIFACT$line
33+
elif [[ $1 == "artifactId" ]]; then
34+
if [[ -z $ARTIFACT ]]; then
35+
ARTIFACT=$2
36+
fi
37+
elif [[ $1 == "groupId" ]]; then
38+
if [[ -z $GROUP ]]; then
39+
GROUP=$2
40+
fi
4141
fi
4242

4343
done
@@ -47,10 +47,66 @@ while read line ; do
4747
NAME=$(echo $line | sed -e 's/.jar$//')
4848
VERSION=${NAME##*-}
4949
ARTIFACT=${NAME%-*}
50-
GROUP=$(find ~/.m2/repository -name ${NAME}.pom -exec sed -n "1,/${ARTIFACT}/p" {} \; | tac | grep -m 1 -e "<groupId>" | sed -e 's/^[[:space:]]*//' | tr -d '\r')
51-
DATA="<dependency>${GROUP}<artifactId>${ARTIFACT}</artifactId><version>${VERSION}</version></dependency>"
52-
echo $DATA >> pom.xml
50+
GROUP=$(find ~/.m2/repository -name ${NAME}.pom -exec sed -n "1,/${ARTIFACT}/p" {} \; | tac | grep -m 1 -e "<groupId>" | sed -e 's/^[[:space:]]*//' -e 's/\^M//' | tr -d '\r' | awk -v FS="(>|<)" '{print $3}')
51+
DATA="${GROUP} ${ARTIFACT} ${VERSION}"
52+
echo $DATA >> deps.out
5353
done < /tmp/resolvedPlugins
5454

55-
#Finish dummy pom
56-
echo "</dependencies></project>" >> pom.xml
55+
cat deps.out | LANG=C sort -u > cleandeps.out
56+
57+
LASTPOM=0
58+
echo '<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.apache.cloudstack</groupId><artifactId>travis-build-deps</artifactId><name>Download Deps for Travis CI</name><version>1</version><repositories><repository><id>mido-maven-public-releases</id><name>mido-maven-public-releases</name><url>http://cs-maven.midokura.com/releases</url></repository><repository><id>juniper-contrail</id><url>http://juniper.github.io/contrail-maven/snapshots</url></repository></repositories><dependencies>' > pom${LASTPOM}.xml
59+
while read line ; do
60+
set -- $line
61+
62+
if [[ $2 == $LASTARTIFACT ]]; then
63+
POMID=$(($POMID+1))
64+
if [[ $POMID -gt $LASTPOM ]]; then
65+
LASTPOM=$POMID
66+
echo '<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.apache.cloudstack</groupId><artifactId>travis-build-deps</artifactId><name>Download Deps for Travis CI</name><version>1</version><repositories><repository><id>mido-maven-public-releases</id><name>mido-maven-public-releases</name><url>http://cs-maven.midokura.com/releases</url></repository><repository><id>juniper-contrail</id><url>http://juniper.github.io/contrail-maven/snapshots</url></repository></repositories><dependencies>' > pom${LASTPOM}.xml
67+
fi
68+
else
69+
POMID=0
70+
fi
71+
LASTARTIFACT=$2
72+
echo "<dependency><groupId>$1</groupId><artifactId>$2</artifactId><version>$3</version></dependency>" >> pom${POMID}.xml
73+
74+
done < cleandeps.out
75+
76+
RETURN_CODE=0
77+
for ((i=0;i<=$LASTPOM;i++))
78+
do
79+
echo "</dependencies></project>" >> pom${i}.xml
80+
mvn org.apache.maven.plugins:maven-dependency-plugin:resolve -f pom${i}.xml
81+
if [[ $? -ne 0 ]]; then
82+
RETURN_CODE=1
83+
fi
84+
85+
done
86+
87+
#Run a few plugin goals to download some more deps
88+
89+
#Hack to run maven-jaxb2-plugin generate, can be removed when we stop using such an old version...
90+
mkdir -p src/main/resources
91+
echo '<?xml version="1.0" encoding="utf-8" ?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"></xs:schema>' > src/main/resources/test.xsd
92+
93+
94+
declare -a arr=("maven-surefire-plugin test" "maven-pmd-plugin pmd" "maven-compiler-plugin compile" "maven-resources-plugin resources" "maven-checkstyle-plugin check" "maven-site-plugin attach-descriptor" "maven-surefire-plugin test" "maven-jar-plugin jar" "license-maven-plugin check" "maven-jgit-buildnumber-plugin extract-buildnumber" "maven-jaxb2-plugin generate" "maven-war-plugin war -DfailOnMissingWebXml=false" "gmaven-plugin compile")
95+
for i in "${arr[@]}"
96+
do
97+
set -- $i
98+
PLUGIN=$1
99+
MOJO=$2
100+
OPTION=$3
101+
while read line ; do
102+
set -- $line
103+
JOBS="${JOBS} ${1}:${2}:${3}:${MOJO} $OPTION"
104+
done < <(grep $PLUGIN cleandeps.out)
105+
done
106+
echo "Running $JOBS"
107+
mvn $JOBS -f pom0.xml
108+
109+
110+
rm -rf deps.out src target
111+
112+
exit $RETURN_CODE

0 commit comments

Comments
 (0)