You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@yetus.apache.org by aw...@apache.org on 2022/05/02 16:09:52 UTC
[yetus] branch main updated: YETUS-135. asflicense does not validate rat jar (#270)
This is an automated email from the ASF dual-hosted git repository.
aw pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/yetus.git
The following commit(s) were added to refs/heads/main by this push:
new 51d597ee YETUS-135. asflicense does not validate rat jar (#270)
51d597ee is described below
commit 51d597ee17e7c12f91e32b48d20cbb96a9735d97
Author: Allen Wittenauer <aw...@apache.org>
AuthorDate: Mon May 2 09:09:47 2022 -0700
YETUS-135. asflicense does not validate rat jar (#270)
Signed-off-by: Nick Dimiduk <nd...@apache.org>
---
precommit/src/main/shell/plugins.d/asflicense.sh | 51 ++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/precommit/src/main/shell/plugins.d/asflicense.sh b/precommit/src/main/shell/plugins.d/asflicense.sh
index d8748b9c..89d4dd5d 100755
--- a/precommit/src/main/shell/plugins.d/asflicense.sh
+++ b/precommit/src/main/shell/plugins.d/asflicense.sh
@@ -28,6 +28,30 @@ function asflicense_usage
yetus_add_option "--asflicense-rat-jar=<file>" "Path to Apache Creadur Rat jar file"
}
+
+## @description Validate the rat jar
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function asflicense_ratjar_validate
+{
+ declare filename=$1
+ declare result
+ result=1
+
+ if [[ "${filename}" =~ .jar$ ]]; then
+ "${JAVA_HOME}/bin/jar" tvf "${filename}" org/apache/rat >/dev/null 2>&1
+ result=$?
+ fi
+ return "${result}"
+}
+
+## @description process asflicense args
+## @audience private
+## @stability evolving
+## @replaceable no
function asflicense_parse_args
{
declare i
@@ -54,6 +78,10 @@ function asflicense_parse_args
add_test asflicense
;;
*)
+ # for other builds, the rat jar file _must_ be present
+ # if it isn't, then assume asflicense wasn't actually
+ # meant to get added. we also are not going to flag
+ # a message here since this case will be common
if [[ -f "${ASFLICENSE_RAT_JAR}" ]]; then
add_test asflicense
fi
@@ -61,6 +89,29 @@ function asflicense_parse_args
esac
}
+## @description perform asflicense prechecks
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function asflicense_precheck
+{
+ case ${BUILDTOOL} in
+ ant|gradle|maven)
+ :
+ ;;
+ *)
+ if ! asflicense_ratjar_validate "${ASFLICENSE_RAT_JAR}"; then
+ delete_test asflicense
+ add_vote_table_v2 0 asflicense "" "${ASFLICENSE_RAT_JAR} is not Apache Rat."
+ return 1
+ fi
+ ;;
+ esac
+ return 0
+}
+
## @description Verify all files have an Apache License
## @audience private
## @stability evolving