Skip to content

Commit

Permalink
Fixed multi-module license check
Browse files Browse the repository at this point in the history
  • Loading branch information
robmoffat committed Mar 8, 2023
1 parent 4bb4bd8 commit 4339b8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/acceptable-licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@
<name>The Apache License, Version 2.0</name>
<name>The Apache Software License, Version 2.0</name>
<name>The BSD License</name>
<name>The GNU General Public License (GPL), Version 2, With Classpath Exception</name>
<name>The GNU Lesser General Public License, Version 2.1</name>
<name>The MIT License (MIT)</name>
<name>The MIT License</name>
<name>Unicode/ICU License</name>
<name>Universal Permissive License, Version 1.0</name>
<name>W3C license</name>
<name>jQuery license</name>
<name>jQuery license</name>
10 changes: 4 additions & 6 deletions .github/workflows/license-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ jobs:
run: mvn org.codehaus.mojo:license-maven-plugin:2.0.0:download-licenses
- name: Validate XML report
run: |
ALLOW_LICENSES=`cat .github/workflows/acceptable-licenses.txt`
find . -name licenses.xml | awk '{print "cat " $1}' | sh | xq "//dependency[licenses/license/name!=${{ env.ALLOW_LICENSES }}] | sort | uniq > target/complete-licenses.txt
comm -23 target/complete-licenses.txt .github/workflows/acceptable-licenses.txt > target/license-report.txt
LINES_FOUND=`cat target/license-report.txt | wc -l`
echo "License issues found ..."
if [ $LINES_FOUND -gt 1 ]; then cat target/license-report.txt ; exit -1; fi
ALLOW_LICENSES=`cat .github/workflows/acceptable-licenses.txt | sed "s/<name>/license/license/name!='/" | sed "s/</name>/' | tr -s '\n' '!' | sed 's/\!/ or /g' `
find . -name licenses.xml -exec xq "//dependency[count(licenses/license[${ALLOW_LICENSES}])=0]" {} \; > target/license-issues.xml
LINES_FOUND=`cat target/license-issues.xml | wc -l`
if [ $LINES_FOUND -gt 3 ]; then cat target/license-report.txt ; exit -1; fi
working-directory: maven
- name: Upload license reports
uses: actions/upload-artifact@v3
Expand Down

0 comments on commit 4339b8d

Please sign in to comment.