Skip to content

License Scanning for Maven #198

License Scanning for Maven

License Scanning for Maven #198

Workflow file for this run

#workflows/license-scanning-maven.yml
name: License Scanning for Maven
on:
schedule:
- cron: '0 8,18 * * 1-5'
workflow_dispatch:
push:
paths:
- './pom.xml'
- '.github/workflows/license-scanning-maven.yml'
env:
ALLOW_LICENSES: "
licenses/license/name!='Apache License, Version 2.0' and
not(contains(licenses/license/url, '://www.apache.org/licenses/LICENSE-2.0.txt')) and
not(contains(licenses/license/url, '://opensource.org/licenses/Apache-2.0')) and
licenses/license/name!='BSD License' and
not(contains(licenses/license/url, 'antlr.org/license.html')) and
licenses/license/name!='New BSD License' and
not(contains(licenses/license/url, '://www.opensource.org/licenses/bsd-license.php')) and
licenses/license/name!='BSD-3-Clause' and
not(contains(licenses/license/url, '://asm.ow2.io/license.html')) and
licenses/license/name!='Eclipse Public License - v 1.0' and
not(contains(licenses/license/url, '://www.eclipse.org/legal/epl-v10.html')) and
licenses/license/name!='Eclipse Public License - v 2.0' and
not(contains(licenses/license/url, '://www.eclipse.org/legal/epl-v20.html')) and
not(contains(licenses/license/url, '://www.eclipse.org/legal/epl-2.0')) and
licenses/license/name!='GNU Lesser General Public License' and
not(contains(licenses/license/url, '://www.gnu.org/licenses/old-licenses/lgpl-2.1.html')) and
licenses/license/name!='GNU General Public License (GPL), version 2, with the Classpath exception' and
not(contains(licenses/license/url, '://openjdk.java.net/legal/gplv2+ce.html')) and
licenses/license/name!='The MIT License' and
not(contains(licenses/license/url, '://opensource.org/licenses/MIT')) and
not(contains(licenses/license/url, '://www.opensource.org/licenses/mit-license.php')) and
licenses/license/name!='CDDL + GPLv2 with classpath exception' and
not(contains(licenses/license/url, '://github.com/javaee/javax.annotation/blob/master/LICENSE')) and
licenses/license/name!='Public Domain'
"
REPORT_PATH: "target/generated-resources/licenses.xml"
permissions:
contents: read
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: 21
cache: maven
distribution: 'adopt'
- name: Install XQ
run: pip install xq
- name: Build with Maven
run: mvn clean package -Dmaven.test.skip=true
working-directory: .
- name: License XML report
run: mvn org.codehaus.mojo:license-maven-plugin:2.0.0:download-licenses
working-directory: .
- name: Validate XML report
run: |
LICENSE_REPORT=`xq "//dependency[licenses/license/name!=${{ env.ALLOW_LICENSES }}]" ./${{ env.REPORT_PATH }}`
LINES_FOUND=`echo $LICENSE_REPORT | wc -l`
echo "License issues found ..."
if [ $LINES_FOUND -gt 1 ]; then echo $LICENSE_REPORT ; exit -1; fi
working-directory: .
- name: Upload license XML reports
uses: actions/upload-artifact@v6
with:
name: license-xml-report
path: './**/${{ env.REPORT_PATH }}'