diff --git a/tools/travis/before_install.sh b/tools/travis/before_install.sh index 31efc653609..dd90ec6ad81 100755 --- a/tools/travis/before_install.sh +++ b/tools/travis/before_install.sh @@ -84,3 +84,28 @@ echo -e "\nInstalling some python packages: " sudo pip install lxml > /dev/null sudo pip install texttable > /dev/null + +#Download project dependencies in a way we can retry if there's a failure, without failing the whole build +RETRY_COUNT=3 + +#Resolve plugins first +for ((i=0;i<$RETRY_COUNT;i++)) +do + mvn org.apache.maven.plugins:maven-dependency-plugin:resolve-plugins + if [[ $? -eq 0 ]]; then + break; + fi +done + +#Resolve remaining deps +cd tools/travis +./downloadDeps.sh 2> /dev/null + +for ((i=0;i<$RETRY_COUNT;i++)) +do + mvn org.apache.maven.plugins:maven-dependency-plugin:resolve + if [[ $? -eq 0 ]]; then + break; + fi +done +cd ../.. diff --git a/tools/travis/downloadDeps.sh b/tools/travis/downloadDeps.sh new file mode 100755 index 00000000000..29248e0c8b9 --- /dev/null +++ b/tools/travis/downloadDeps.sh @@ -0,0 +1,43 @@ +#Create dummy pom +echo '4.0.0org.apache.cloudstacktravis-build-depsDownload Deps for Travis CI1' > pom.xml + +#Get all dependency blocks +for line in $(find . -name pom.xml -exec sed -n '//{:a;n;/<\/dependencies>/b;p;ba}' {} \; | grep -e "artifactId" -e "groupId" -e "version" -e "dependency\>" -e "exclusion\>" -e "exclusions\>"); do + + #Tokenize values + set -- $(echo $line | awk -v FS="(>|<)" '{print $2, $3}') + + #Start processing data + + if [ $1 == "dependency" ]; then + #Create new artifact dep + ARTIFACT=$line + elif [ $1 == "/dependency" ]; then + #Filter out project modules interdependencies and noredist artifacts + if [[ $ARTIFACT != *org.apache.cloudstack* ]] && [[ $ARTIFACT != *com.cloud* ]] && [[ $ARTIFACT != *org.midonet* ]] && [[ $ARTIFACT != *net.juniper* ]] ; then + echo $ARTIFACT$line >> pom.xml + fi + elif [ $1 == "version" ]; then + #If version is a maven var, get the value from parent pom + if [[ $2 == \$\{* ]]; then + + VER=$(grep \<$(echo $2 | awk -v FS="(}|{)" '{print $2 }') ../../pom.xml | awk -v FS="(>|<)" '{print $3}') + if [[ "$VER" == "" ]]; then + ARTIFACT=org.apache.cloudstack + else + ARTIFACT="$ARTIFACT$VER" + fi + elif [[ "$2" == "" ]]; then + ARTIFACT="$ARTIFACTLATEST" + else + ARTIFACT=$ARTIFACT$line + fi + else + ARTIFACT=$ARTIFACT$line + fi + +done + + +#Finish dummy pom +echo "" >> pom.xml