From 08ecae97e3e14d8c27b744c320e5dcb27d2a4a1a Mon Sep 17 00:00:00 2001 From: Sean Busbey Date: Wed, 30 Mar 2022 14:41:51 -0500 Subject: [PATCH] HBASE-26871 addendum. use the jar command from JAVA_HOME (#4297) --- .../resources/ensure-jars-have-correct-contents.sh | 10 ++++++++-- .../resources/ensure-jars-have-correct-contents.sh | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/hbase-shaded/hbase-shaded-check-invariants/src/test/resources/ensure-jars-have-correct-contents.sh b/hbase-shaded/hbase-shaded-check-invariants/src/test/resources/ensure-jars-have-correct-contents.sh index fbc48d11f2c2..f9fc294cc992 100644 --- a/hbase-shaded/hbase-shaded-check-invariants/src/test/resources/ensure-jars-have-correct-contents.sh +++ b/hbase-shaded/hbase-shaded-check-invariants/src/test/resources/ensure-jars-have-correct-contents.sh @@ -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,8 +119,8 @@ 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)) - class_count=$(jar tf "${artifact}" | grep -c -E '\.class$' || 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 diff --git a/hbase-shaded/hbase-shaded-with-hadoop-check-invariants/src/test/resources/ensure-jars-have-correct-contents.sh b/hbase-shaded/hbase-shaded-with-hadoop-check-invariants/src/test/resources/ensure-jars-have-correct-contents.sh index fbc48d11f2c2..f9fc294cc992 100644 --- a/hbase-shaded/hbase-shaded-with-hadoop-check-invariants/src/test/resources/ensure-jars-have-correct-contents.sh +++ b/hbase-shaded/hbase-shaded-with-hadoop-check-invariants/src/test/resources/ensure-jars-have-correct-contents.sh @@ -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,8 +119,8 @@ 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)) - class_count=$(jar tf "${artifact}" | grep -c -E '\.class$' || 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