HBASE-26871 addendum. use the jar command from JAVA_HOME (#4297)

Conflicts:
	hbase-shaded/hbase-shaded-check-invariants/src/test/resources/ensure-jars-have-correct-contents.sh
	hbase-shaded/hbase-shaded-with-hadoop-check-invariants/src/test/resources/ensure-jars-have-correct-contents.sh
This commit is contained in:
Sean Busbey 2022-03-30 14:41:51 -05:00 committed by Andrew Purtell
parent b3c3e2f41a
commit 828ea9187e
2 changed files with 22 additions and 2 deletions

View File

@ -48,6 +48,12 @@ do
esac
done
if [ -z "${JAVA_HOME}" ]; then
echo "[ERROR] Must have JAVA_HOME defined." 1>&2
exit 1
fi
JAR="${JAVA_HOME}/bin/jar"
# should still have jars to check.
if [ $# -lt 1 ]; then
usage
@ -113,7 +119,11 @@ allowed_expr+=")"
declare -i bad_artifacts=0
declare -a bad_contents
for artifact in "${artifact_list[@]}"; do
bad_contents=($(jar tf "${artifact}" | grep -v -E "${allowed_expr}" || true))
bad_contents=($("${JAR}" tf "${artifact}" | grep -v -E "${allowed_expr}" || true))
class_count=$("${JAR}" tf "${artifact}" | grep -c -E '\.class$' || true)
if [ ${#bad_contents[@]} -eq 0 ] && [ "${class_count}" -lt 1 ]; then
bad_contents=("The artifact contains no java class files.")
fi
if [ ${#bad_contents[@]} -gt 0 ]; then
echo "[ERROR] Found artifact with unexpected contents: '${artifact}'"
echo " Please check the following and either correct the build or update"

View File

@ -48,6 +48,12 @@ do
esac
done
if [ -z "${JAVA_HOME}" ]; then
echo "[ERROR] Must have JAVA_HOME defined." 1>&2
exit 1
fi
JAR="${JAVA_HOME}/bin/jar"
# should still have jars to check.
if [ $# -lt 1 ]; then
usage
@ -113,7 +119,11 @@ allowed_expr+=")"
declare -i bad_artifacts=0
declare -a bad_contents
for artifact in "${artifact_list[@]}"; do
bad_contents=($(jar tf "${artifact}" | grep -v -E "${allowed_expr}" || true))
bad_contents=($("${JAR}" tf "${artifact}" | grep -v -E "${allowed_expr}" || true))
class_count=$("${JAR}" tf "${artifact}" | grep -c -E '\.class$' || true)
if [ ${#bad_contents[@]} -eq 0 ] && [ "${class_count}" -lt 1 ]; then
bad_contents=("The artifact contains no java class files.")
fi
if [ ${#bad_contents[@]} -gt 0 ]; then
echo "[ERROR] Found artifact with unexpected contents: '${artifact}'"
echo " Please check the following and either correct the build or update"