blob: e81a7f48cc92c2663982ad374c0838b2c52857e1 [file] [log] [blame]
sberlin@gmail.coma3c948e2011-01-10 01:33:13 +00001#!/bin/bash
Sam Berlin22d4cca2014-08-09 14:21:04 -04002## Compares the ant jars to the maven jars and makes sure they're the same
3## (or different where/how expected)
sberlin@gmail.coma3c948e2011-01-10 01:33:13 +00004
Sam Berlin22d4cca2014-08-09 14:21:04 -04005## Note: The no_aop build doesn't compare cleanly for some reason.
6## Maybe a difference between the ant & maven munge preprocessor?
7
8RETVAL=0
9
sberlin@gmail.coma3c948e2011-01-10 01:33:13 +000010function cleanAndBuild {
Sam Berlin22d4cca2014-08-09 14:21:04 -040011 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 Berlinc8836d32014-08-11 15:35:52 -040016 #ant -f build/no_aop/build.xml dist > /dev/null
sberlin@gmail.coma3c948e2011-01-10 01:33:13 +000017}
18
19function findAndCompareJars {
Sam Berlin22d4cca2014-08-09 14:21:04 -040020 version=4.0
Christian Edward Gruber80ed8182014-03-20 19:47:05 -070021 for ANT in `find ./build/dist/* -name "*-snapshot.jar" `
sberlin@gmail.coma3c948e2011-01-10 01:33:13 +000022 do
Sam Berlin22d4cca2014-08-09 14:21:04 -040023 if [ $ANT = "./build/dist/guice-snapshot.jar" ]; then
24 ## Check the main build.
sberlin@gmail.coma3c948e2011-01-10 01:33:13 +000025 MVN=./core/target/guice-$version-SNAPSHOT.jar
26 extension=core
27 compareJars "$ANT" "$MVN" $extension
Sam Berlin22d4cca2014-08-09 14:21:04 -040028 #compareJars "./build/no_aop/$ANT" "./core/target/guice-$version-SNAPSHOT-no_aop.jar" "no_aop: $extension"
29 else
30 ## Check extensions.
sberlin@gmail.coma3c948e2011-01-10 01:33:13 +000031 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
39function compareJars {
40 ANT=$1
41 MVN=$2
42 extension=$3
Sam Berlin22d4cca2014-08-09 14:21:04 -040043 curdir=`pwd`
sberlin@gmail.coma3c948e2011-01-10 01:33:13 +000044
45 echo Comparing $3
Sam Berlin22d4cca2014-08-09 14:21:04 -040046 mkdir "tmp$$"
sberlin@gmail.coma3c948e2011-01-10 01:33:13 +000047 cp $ANT tmp$$/ant.jar
48 cp $MVN tmp$$/mvn.jar
Sam Berlin22d4cca2014-08-09 14:21:04 -040049 cd "tmp$$"
sberlin@gmail.coma3c948e2011-01-10 01:33:13 +000050 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 Berlin22d4cca2014-08-09 14:21:04 -040059 ## ant puts LICENSE & NOTICE files in a different place
sberlin@gmail.coma3c948e2011-01-10 01:33:13 +000060 echo LICENSE > excludes
61 echo NOTICE >> excludes
Sam Berlin22d4cca2014-08-09 14:21:04 -040062 ## ant does not create DEPENDENCIES
sberlin@gmail.coma3c948e2011-01-10 01:33:13 +000063 echo DEPENDENCIES >> excludes
Sam Berlin22d4cca2014-08-09 14:21:04 -040064 ## ant/mvn slightly different in MANIFEST.MF
sberlin@gmail.coma3c948e2011-01-10 01:33:13 +000065 echo MANIFEST.MF >> excludes
Sam Berlin22d4cca2014-08-09 14:21:04 -040066
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.coma3c948e2011-01-10 01:33:13 +000086 rm -rf "tmp$$"
87}
88
Sam Berlin22d4cca2014-08-09 14:21:04 -040089## 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.
91if [ "$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
105fi