sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 1 | #!/bin/bash |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 2 | ## Compares the ant jars to the maven jars and makes sure they're the same |
| 3 | ## (or different where/how expected) |
sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 4 | |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 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 | |
sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 10 | function cleanAndBuild { |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 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 |
Sam Berlin | c8836d3 | 2014-08-11 15:35:52 -0400 | [diff] [blame] | 16 | #ant -f build/no_aop/build.xml dist > /dev/null |
sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | function findAndCompareJars { |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 20 | version=4.0 |
Christian Edward Gruber | 80ed818 | 2014-03-20 19:47:05 -0700 | [diff] [blame] | 21 | for ANT in `find ./build/dist/* -name "*-snapshot.jar" ` |
sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 22 | do |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 23 | if [ $ANT = "./build/dist/guice-snapshot.jar" ]; then |
| 24 | ## Check the main build. |
sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 25 | MVN=./core/target/guice-$version-SNAPSHOT.jar |
| 26 | extension=core |
| 27 | compareJars "$ANT" "$MVN" $extension |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 28 | #compareJars "./build/no_aop/$ANT" "./core/target/guice-$version-SNAPSHOT-no_aop.jar" "no_aop: $extension" |
| 29 | else |
| 30 | ## Check extensions. |
sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 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 |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 43 | curdir=`pwd` |
sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 44 | |
| 45 | echo Comparing $3 |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 46 | mkdir "tmp$$" |
sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 47 | cp $ANT tmp$$/ant.jar |
| 48 | cp $MVN tmp$$/mvn.jar |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 49 | cd "tmp$$" |
sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 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 | |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 59 | ## ant puts LICENSE & NOTICE files in a different place |
sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 60 | echo LICENSE > excludes |
| 61 | echo NOTICE >> excludes |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 62 | ## ant does not create DEPENDENCIES |
sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 63 | echo DEPENDENCIES >> excludes |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 64 | ## ant/mvn slightly different in MANIFEST.MF |
sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 65 | echo MANIFEST.MF >> excludes |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 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" |
sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 86 | rm -rf "tmp$$" |
| 87 | } |
| 88 | |
Sam Berlin | 22d4cca | 2014-08-09 14:21:04 -0400 | [diff] [blame] | 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 |