Skip to content

Commit f0b105e

Browse files
committed
melting-pot: test deployed binaries, too
In Java, binary API compatibility and source API compatibility are two distinct things. Recompiling the same source code against different dependencies than before might result in different bytecode, which works correctly at runtime with those new dependencies -- but when using the previously deployed bytecode against those new dependencies, errors happen because binary type signatures changed. For example, generic types might erase differently with the new dependencies, or different synthetic methods might be silently inserted. So, we need to check the new dependencies against both scenarios: 1. Do tests pass when run on the existing deployed component binary? 2. Does source compile with passing tests against the new dependencies? This commit is dedicated to Stephan Saalfeld.
1 parent 11f4d55 commit f0b105e

File tree

1 file changed

+58
-4
lines changed

1 file changed

+58
-4
lines changed

melting-pot.sh

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ resolveSource() {
466466
git clone "file://$cachedRepoDir" --branch "$scmBranch" --depth 1 "$destDir" 2> /dev/null ||
467467
die "$1: could not clone branch '$scmBranch' from local cache" 15
468468

469+
# Save the GAV string to a file, for convenience.
470+
echo "$1" > "$destDir/gav"
471+
469472
# Now verify that the cloned pom.xml contains the expected version!
470473
local expectedVersion=$(version "$1")
471474
local actualVersion=$(xpath "$destDir/pom.xml" project version)
@@ -784,7 +787,7 @@ meltDown() {
784787
local gav="$g:$a:$v"
785788

786789
test -z "$(isChanged "$gav")" &&
787-
args="$args \\\\\n -D$g.$a.version=$v -D$a.version=$v"
790+
args="$args \\\\\n -D$g.$a.version=$v -D$a.version=$v"
788791
done
789792

790793
# Override versions of changed GAVs.
@@ -795,14 +798,65 @@ meltDown() {
795798
do
796799
local a="$(artifactId "$gav")"
797800
local v="$(version "$gav")"
798-
args="$args \\\\\n -D$a.version=$v"
801+
args="$args \\\\\n -D$a.version=$v"
799802
done
800803
unset TLS
801804

802805
# Generate build script.
803806
info "Generating build.sh script"
804-
echo "#!/bin/sh" > build.sh
805-
echo "mvn $args \\\\\n dependency:list test \$@" >> build.sh
807+
echo '#!/bin/sh' > build.sh
808+
echo >> build.sh
809+
echo 'mvnPin() {' >> build.sh
810+
echo " mvn $args \\\\\n \$@" >> build.sh
811+
echo '}' >> build.sh
812+
echo >> build.sh
813+
echo 'unpackArtifact() {' >> build.sh
814+
echo ' # Download and unpack the given artifact' >> build.sh
815+
echo ' # (G:A:V) to the specified location.' >> build.sh
816+
echo ' gav=$1' >> build.sh
817+
echo ' out=$2' >> build.sh
818+
echo >> build.sh
819+
echo ' repoPrefix=$HOME/.m2/repository # TODO: generalize this' >> build.sh
820+
echo ' g=${gav%%:*}; r=${gav#*:}; a=${r%%:*}; v=${r##*:}' >> build.sh
821+
echo ' gavPath="$(echo "$g" | tr "." "/")/$a/$v/$a-$v"' >> build.sh
822+
echo ' jarPath="$repoPrefix/$gavPath.jar"' >> build.sh
823+
echo >> build.sh
824+
echo ' # HACK: The best goal to use would be dependency:unpack,' >> build.sh
825+
echo ' # or failing that, dependency:copy followed by jar xf.' >> build.sh
826+
echo ' # But those goals do not support remoteRepositories;' >> build.sh
827+
echo ' # see https://issues.apache.org/jira/browse/MDEP-390.' >> build.sh
828+
echo ' # So we use dependency:get and then extract it by hand.' >> build.sh
829+
echo ' mvnPin dependency:get \' >> build.sh
830+
echo " -DremoteRepositories=\"$remoteRepos\" \\" >> build.sh
831+
echo ' -Dartifact="$gav" &&' >> build.sh
832+
echo >> build.sh
833+
echo ' test -f "$jarPath" &&' >> build.sh
834+
echo ' mkdir -p "$out" &&' >> build.sh
835+
echo ' cd "$out" &&' >> build.sh
836+
echo ' jar xf "$jarPath" &&' >> build.sh
837+
echo ' cd - >/dev/null' >> build.sh
838+
echo '}' >> build.sh
839+
echo >> build.sh
840+
echo 'mvnPin dependency:list &&' >> build.sh
841+
echo >> build.sh
842+
echo 'if [ -f gav ]' >> build.sh
843+
echo 'then' >> build.sh
844+
echo ' echo' >> build.sh
845+
echo ' echo "================================================"' >> build.sh
846+
echo ' echo "========= Testing with deployed binary ========="' >> build.sh
847+
echo ' echo "================================================"' >> build.sh
848+
echo ' unpackArtifact "$(cat gav)" target/classes &&' >> build.sh
849+
echo ' mvnPin \' >> build.sh
850+
echo ' -Dmaven.main.skip=true \' >> build.sh
851+
echo ' -Dmaven.resources.skip=true \' >> build.sh
852+
echo ' test $@' >> build.sh
853+
echo 'fi &&' >> build.sh
854+
echo >> build.sh
855+
echo 'echo &&' >> build.sh
856+
echo 'echo "================================================" &&' >> build.sh
857+
echo 'echo "============ Rebuilding from source ============" &&' >> build.sh
858+
echo 'echo "================================================" &&' >> build.sh
859+
echo 'mvnPin clean test $@' >> build.sh
806860
chmod +x build.sh
807861

808862
# Clone source code.

0 commit comments

Comments
 (0)