Skip to content

Commit

Permalink
Merge pull request #306 from simonjhy/BLADE-729-4
Browse files Browse the repository at this point in the history
BLADE-729 fix maven profile diff error
  • Loading branch information
simonjhy committed Aug 25, 2023
2 parents 31a5f01 + 0a9fa36 commit 1f5e05b
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,26 @@ fi

unzip -p cli/build/libs/blade.jar "$embeddedMavenProfileJar" > /tmp/$timestamp/myExtractedMavenProfile.jar

cp /tmp/$timestamp/myExtractedMavenProfile.{jar,zip}
unzip -q /tmp/$timestamp/myExtractedMavenProfile.zip -d /tmp/$timestamp/localMavenJarExploded
mkdir -p /tmp/$timestamp/localMavenJarExploded
mkdir -p /tmp/$timestamp/remoteMavenJarExploded

cp /tmp/$timestamp/maven_profile.{jar,zip}
unzip -q /tmp/$timestamp/maven_profile.zip -d /tmp/$timestamp/remoteMavenJarExploded
unzip /tmp/$timestamp/myExtractedMavenProfile.jar -d /tmp/$timestamp/localMavenJarExploded
unzip /tmp/$timestamp/maven_profile.jar -d /tmp/$timestamp/remoteMavenJarExploded

echo "Doing a more detailed diff..."
diff -r /tmp/$timestamp/localMavenJarExploded /tmp/$timestamp/remoteMavenJarExploded
sed -i 's/Bnd-LastModified.*/Bnd-LastModified:/g; s/Canary-Timestamp.*/Canary-Timestamp:/g' /tmp/$timestamp/localMavenJarExploded/META-INF/MANIFEST.MF
sed -i 's/Bnd-LastModified.*/Bnd-LastModified:/g; s/Canary-Timestamp.*/Canary-Timestamp:/g' /tmp/$timestamp/remoteMavenJarExploded/META-INF/MANIFEST.MF

echo "Doing the standard jar diff..."
diff -s /tmp/$timestamp/myExtractedMavenProfile.jar /tmp/$timestamp/maven_profile.jar
diff -s /tmp/$timestamp/localMavenJarExploded/ /tmp/$timestamp/remoteMavenJarExploded/

if [ "$?" != "0" ]; then
echo Failed local blade.jar diff with downloaded maven profile jar. The embedded maven profile jar and nexus maven profile jar are not identical
rm -rf /tmp/$timestamp/localMavenJarExploded/
rm -rf /tmp/$timestamp/remoteMavenJarExploded/
exit 1
fi

# Now lets go ahead and publish the blade cli jar for real since the embedded maven profile was correct
rm -rf /tmp/$timestamp/localMavenJarExploded/
rm -rf /tmp/$timestamp/remoteMavenJarExploded/

./gradlew -q --no-daemon --console=plain $nexusOpt -P${releaseType} --refresh-dependencies :cli:publish --info ${scanOpt} > /tmp/$timestamp/blade-cli-publish-command.txt; retcode=$?
bladeCliPublishCommand=$(cat /tmp/$timestamp/blade-cli-publish-command.txt)
Expand All @@ -231,13 +233,27 @@ fi

unzip -p /tmp/$timestamp/blade.jar "$embeddedMavenProfileJar" > /tmp/$timestamp/myExtractedMavenProfile.jar

diff -s /tmp/$timestamp/myExtractedMavenProfile.jar /tmp/$timestamp/maven_profile.jar
mkdir -p /tmp/$timestamp/localMavenJarExploded
mkdir -p /tmp/$timestamp/remoteMavenJarExploded

unzip /tmp/$timestamp/myExtractedMavenProfile.jar -d /tmp/$timestamp/localMavenJarExploded
unzip /tmp/$timestamp/maven_profile.jar -d /tmp/$timestamp/remoteMavenJarExploded

sed -i 's/Bnd-LastModified.*/Bnd-LastModified:/g; s/Canary-Timestamp.*/Canary-Timestamp:/g' /tmp/$timestamp/localMavenJarExploded/META-INF/MANIFEST.MF
sed -i 's/Bnd-LastModified.*/Bnd-LastModified:/g; s/Canary-Timestamp.*/Canary-Timestamp:/g' /tmp/$timestamp/remoteMavenJarExploded/META-INF/MANIFEST.MF

diff -s /tmp/$timestamp/localMavenJarExploded/ /tmp/$timestamp/remoteMavenJarExploded/

if [ "$?" != "0" ]; then
echo Failed local blade.jar diff with downloaded maven profile jar. The embedded maven profile jar and nexus maven profile jar are not identical
rm -rf /tmp/$timestamp/localMavenJarExploded/
rm -rf /tmp/$timestamp/remoteMavenJarExploded/
exit 1
fi

rm -rf /tmp/$timestamp/localMavenJarExploded/
rm -rf /tmp/$timestamp/remoteMavenJarExploded/

localBladeVersion=$(java -jar /tmp/$timestamp/blade.jar version)

# Already handled in the dockerfile
Expand Down

0 comments on commit 1f5e05b

Please sign in to comment.