diff --git a/tools/travis/downloadDeps.sh b/tools/travis/downloadDeps.sh index 6045feb0b4a..5d9a033583a 100755 --- a/tools/travis/downloadDeps.sh +++ b/tools/travis/downloadDeps.sh @@ -1,3 +1,6 @@ +#!/bin/bash + +#Get all dependency blocks from all pom.xml files in the project 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\>"| sed -e 's/\^M//'); do #Tokenize values @@ -11,7 +14,7 @@ for line in $(find ../../ -name pom.xml -exec sed -n '//{:a;n;/<\/ unset VERSION unset GROUP elif [[ $1 == "/dependency" ]]; then - #Filter out project modules interdependencies and noredist artifacts + #Filter out project modules interdependencies if [[ $GROUP != *org.apache.cloudstack* ]] && [[ $GROUP != *com.cloud* ]] && [[ $ARTIFACT != cloudstack-service-console-proxy-rdpclient ]]; then if [[ -z $VERSION ]] ; then VERSION=LATEST @@ -25,21 +28,23 @@ for line in $(find ../../ -name pom.xml -exec sed -n '//{:a;n;/<\/ #If version is a maven var, get the value from parent pom if [[ $2 == \$\{* ]]; then VERSION=$(grep \<$(echo $2 | awk -v FS="(}|{)" '{print $2 }') ../../pom.xml | awk -v FS="(>|<)" '{print $3}') + #If version tag is empty, add LATEST to avoid maven errors elif [[ "$2" == "" ]]; then VERSION="LATEST" else VERSION=$2 fi elif [[ $1 == "artifactId" ]]; then + #This avoids exclusions inside dependency block to overwrite original dependency if [[ -z $ARTIFACT ]]; then ARTIFACT=$2 fi elif [[ $1 == "groupId" ]]; then + #This avoids exclusions inside dependency block to overwrite original dependency if [[ -z $GROUP ]]; then GROUP=$2 fi fi - done #Add the resolved plugins to properly download their dependencies @@ -52,17 +57,21 @@ while read line ; do echo $DATA >> deps.out done < /tmp/resolvedPlugins +#Remove duplicates and sort them, LANG export is needed to fix some sorting issue, sorting is needed for later function that relies on sorted input cat deps.out | LANG=C sort -u > cleandeps.out +#Define index of pomfiles, to avoid duplicate deps with different versions in pom.xml, several poms are created in case of more than one version of same artifact LASTPOM=0 echo '4.0.0org.apache.cloudstacktravis-build-depsDownload Deps for Travis CI1mido-maven-public-releasesmido-maven-public-releaseshttp://cs-maven.midokura.com/releasesjuniper-contrailhttp://juniper.github.io/contrail-maven/snapshots' > pom${LASTPOM}.xml while read line ; do set -- $line - + #This relies on correct sorting, and distributes different versions of same dependency througout different pom files if [[ $2 == $LASTARTIFACT ]]; then POMID=$(($POMID+1)) + #If value is greater than current number of poms, create a new one if [[ $POMID -gt $LASTPOM ]]; then LASTPOM=$POMID + #This outputs the necessary structure to start a pom and also defines the extra repositories echo '4.0.0org.apache.cloudstacktravis-build-depsDownload Deps for Travis CI1mido-maven-public-releasesmido-maven-public-releaseshttp://cs-maven.midokura.com/releasesjuniper-contrailhttp://juniper.github.io/contrail-maven/snapshots' > pom${LASTPOM}.xml fi else @@ -70,7 +79,6 @@ while read line ; do fi LASTARTIFACT=$2 echo "$1$2$3" >> pom${POMID}.xml - done < cleandeps.out RETURN_CODE=0 @@ -90,7 +98,7 @@ done mkdir -p src/main/resources echo '' > src/main/resources/test.xsd - +#Declare plugin tests to run 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") for i in "${arr[@]}" do @@ -98,6 +106,7 @@ do PLUGIN=$1 MOJO=$2 OPTION=$3 + #Get every listed version of the plugin and make a run for each version while read line ; do set -- $line JOBS="${JOBS} ${1}:${2}:${3}:${MOJO} $OPTION" @@ -105,8 +114,11 @@ do done echo "Running $JOBS" mvn $JOBS -f pom0.xml +if [[ $? -ne 0 ]]; then + RETURN_CODE=1 +fi - +#Cleanup some files created in the run rm -rf deps.out src target exit $RETURN_CODE