Skip to content

Commit

Permalink
Improve license check script (apache#4196)
Browse files Browse the repository at this point in the history
  • Loading branch information
ralf0131 authored Aug 4, 2019
1 parent f65816d commit 9bf51e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Thumbs.db
.flattened-pom.xml

# license check result
license-list.txt
license-list
24 changes: 18 additions & 6 deletions licenseCheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
APPEND_ARG=""
FOLDER="./"
LINE_FLAG="=============================================="
TARGET_FILE="./license-list.txt"
TARGET_FILE="./license-list"

red=`tput setaf 1`
green=`tput setaf 2`
Expand Down Expand Up @@ -57,9 +57,13 @@ missingLicense=(
for i in "${missingLicense[@]}"; do
search=`echo $i |awk -F: '{print $1}'`
replace=`echo $i |awk -F: '{print $2}'`
sed -i -e 's/'"$search"'/'"$replace"'/g' $TARGET_FILE
sed -i.bak 's/'"$search"'/'"$replace"'/g' $TARGET_FILE
done

if [ -f $TARGET_FILE.bak ]; then
rm -rf $TARGET_FILE.bak
fi

check_unknown_license=`cat $TARGET_FILE | grep "Unknown license"`

#checking unknown license
Expand All @@ -78,6 +82,12 @@ allowLicense=(
"MIT"
"The 3-Clause BSD License"
"Public domain"
"JSR.*107"
"Common Public License Version 1.0"
"org.scijava:native-lib-loader"
"org.codehaus.woodstox:stax2-api"
"wsdl4j:wsdl4j"
"net.jcip:jcip-annotations"
)

#filter allow license
Expand All @@ -87,10 +97,12 @@ for i in "${allowLicense[@]}"; do
license_need_check=`echo "$license_need_check"|grep -vi "$i"`
done

if test -z "$license_need_check"
then
# remove empty lines
echo $license_need_check | sed '/^[[:space:]]*$/d' > license-need-check

if [ ! -s license-need-check ]; then
echo "${green}All dependencies license looks good${reset}"
else
echo "${red}Please check below license${reset}"
echo "$license_need_check"
fi
cat license-need-check
fi

0 comments on commit 9bf51e5

Please sign in to comment.