sberlin@gmail.com | a3c948e | 2011-01-10 01:33:13 +0000 | [diff] [blame] | 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 | # Build everything first. |
| 6 | function cleanAndBuild { |
| 7 | mvn clean |
| 8 | ant clean.all |
| 9 | ant no_aop |
| 10 | ant dist test.dist |
| 11 | mvn package |
| 12 | cd build/no_aop |
| 13 | ant dist test.dist |
| 14 | cd ../.. |
| 15 | } |
| 16 | |
| 17 | function findAndCompareJars { |
| 18 | version=3.0 |
| 19 | for ANT in `find -name "*-snapshot.jar" -path "./build/dist/*"` |
| 20 | do |
| 21 | if [ $ANT = "./build/dist/guice-snapshot.jar" ]; then #Check main build |
| 22 | MVN=./core/target/guice-$version-SNAPSHOT.jar |
| 23 | extension=core |
| 24 | compareJars "$ANT" "$MVN" $extension |
| 25 | compareJars "./build/no_aop/$ANT" "./core/target/guice-$version-SNAPSHOT-no_aop.jar" "no_aop: $extension" #also compare no_aop core |
| 26 | else # Check extensions |
| 27 | extension=`echo $ANT | awk -F"-" '{print $2 }'` |
| 28 | MVN=./extensions/$extension/target/guice-$extension-$version-SNAPSHOT.jar |
| 29 | compareJars "$ANT" "$MVN" $extension |
| 30 | fi |
| 31 | |
| 32 | done; |
| 33 | } |
| 34 | |
| 35 | function compareJars { |
| 36 | ANT=$1 |
| 37 | MVN=$2 |
| 38 | extension=$3 |
| 39 | |
| 40 | echo Comparing $3 |
| 41 | mkdir tmp$$ |
| 42 | cp $ANT tmp$$/ant.jar |
| 43 | cp $MVN tmp$$/mvn.jar |
| 44 | cd tmp$$ |
| 45 | mkdir ant |
| 46 | mkdir mvn |
| 47 | cd ant |
| 48 | jar -xf ../ant.jar |
| 49 | cd .. |
| 50 | cd mvn |
| 51 | jar -xf ../mvn.jar |
| 52 | cd .. |
| 53 | |
| 54 | # ant puts LICENSE & NOTICE files in a different place |
| 55 | echo LICENSE > excludes |
| 56 | echo NOTICE >> excludes |
| 57 | # ant does not create DEPENDENCIES |
| 58 | echo DEPENDENCIES >> excludes |
| 59 | # ant/mvn slightly different in MANIFEST.MF |
| 60 | echo MANIFEST.MF >> excludes |
| 61 | # ant leaves empty directories for some jarjar'd paths -- |
| 62 | # we grep -v instead of exclude because we want to make sure |
| 63 | # if any files in those directories exist, that they're diff'd |
| 64 | diff -u --recursive -Xexcludes ant mvn | grep -v "Only in ant/com/google/inject/internal/asm: signature" | grep -v "Only in ant/com/google/inject/internal/cglib: beans" | grep -v "Only in ant/com/google/inject/internal/cglib: transform" | grep -v "Only in ant/com/google/inject/internal/cglib: util" |
| 65 | cd .. |
| 66 | rm -rf "tmp$$" |
| 67 | } |
| 68 | |
| 69 | cleanAndBuild |
| 70 | echo "Starting to compare jars... Check the output closely!" |
| 71 | echo |
| 72 | findAndCompareJars |
| 73 | echo |
| 74 | echo "If the only thing that printed out is 'Comparing <thing>', then you're good!" |