1 #!/bin/bash 2 ## Compares the ant jars to the maven jars and makes sure they're the same 3 ## (or different where/how expected) 4 5 ## Note: The no_aop build doesn't compare cleanly for some reason. 6 ## Maybe a difference between the ant & maven munge preprocessor? 7 8 RETVAL=0 9 10 function cleanAndBuild { 11 mvn clean > /dev/null 12 ant clean.all > /dev/null 13 #ant no_aop > /dev/null 14 ant dist > /dev/null 15 mvn package -DskipTests=true -Dmaven.javadoc.skip=true > /dev/null 16 #ant -f build/no_aop/build.xml dist > /dev/null 17 } 18 19 function findAndCompareJars { 20 version=4.0 21 for ANT in `find ./build/dist/* -name "*-snapshot.jar" ` 22 do 23 if [ $ANT = "./build/dist/guice-snapshot.jar" ]; then 24 ## Check the main build. 25 MVN=./core/target/guice-$version-SNAPSHOT.jar 26 extension=core 27 compareJars "$ANT" "$MVN" $extension 28 #compareJars "./build/no_aop/$ANT" "./core/target/guice-$version-SNAPSHOT-no_aop.jar" "no_aop: $extension" 29 else 30 ## Check extensions. 31 extension=`echo $ANT | awk -F"-" '{print $2 }'` 32 MVN=./extensions/$extension/target/guice-$extension-$version-SNAPSHOT.jar 33 compareJars "$ANT" "$MVN" $extension 34 fi 35 36 done; 37 } 38 39 function compareJars { 40 ANT=$1 41 MVN=$2 42 extension=$3 43 curdir=`pwd` 44 45 echo Comparing $3 46 mkdir "tmp$$" 47 cp $ANT tmp$$/ant.jar 48 cp $MVN tmp$$/mvn.jar 49 cd "tmp$$" 50 mkdir ant 51 mkdir mvn 52 cd ant 53 jar -xf ../ant.jar 54 cd .. 55 cd mvn 56 jar -xf ../mvn.jar 57 cd .. 58 59 ## ant puts LICENSE & NOTICE files in a different place 60 echo LICENSE > excludes 61 echo NOTICE >> excludes 62 ## ant does not create DEPENDENCIES 63 echo DEPENDENCIES >> excludes 64 ## ant/mvn slightly different in MANIFEST.MF 65 echo MANIFEST.MF >> excludes 66 67 ## ant leaves empty directories for some jarjar'd paths -- 68 ## we grep -v instead of exclude because we want to make sure 69 ## if any files in those directories exist, that they're diff'd. 70 ## ant 1.8+ also creates package-info classes all the time, and 71 ## maven doesn't -- so we just ignore the package-info classes. 72 diff -u --recursive -Xexcludes ant mvn | \ 73 grep -v "^Only in ant/com/google/inject/internal/asm: signature$" | \ 74 grep -v "^Only in ant/com/google/inject/internal/cglib: beans$" | \ 75 grep -v "^Only in ant/com/google/inject/internal/cglib: transform$" | \ 76 grep -v "^Only in ant/com/google/inject/internal/cglib/transform: impl$" | \ 77 grep -v "^Only in ant/com/google/inject/internal/cglib: util$" | \ 78 grep -v "^Only in ant: net$" | \ 79 grep -v "^Only in ant: org$" | \ 80 grep -v "^Only in ant/com/google/inject/.*: package-info\.class$" 81 # failure is 0 because we're using grep -v to filter things out 82 if [ $? -eq 0 ]; then 83 export RETVAL=1 84 fi 85 cd "$curdir" 86 rm -rf "tmp$$" 87 } 88 89 ## Only bother doing this on the jdk8/mvn build (before we publish snapshots). 90 ## Otherwise it's a waste of time building mvn+ant each time. 91 if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && \ 92 [ "$LABEL" == "mvn" ]; then 93 echo "Cleaning and building ant & maven..." 94 cleanAndBuild 95 echo "Starting to compare jars..." 96 echo 97 findAndCompareJars 98 if [ $RETVAL -eq 0 ]; then 99 echo "Everything looks good!" 100 exit 0 101 else 102 echo "Some things don't match -- see above for details." 103 exit 1 104 fi 105 fi 106