This is an automated email from the ASF dual-hosted git repository.

huxing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new 3fc6909  Add dependencies check script (#3941)
3fc6909 is described below

commit 3fc69095cfa6d1acb604260f843627bc61abf6a3
Author: Huang YunKun <hty...@gmail.com>
AuthorDate: Wed May 22 10:57:19 2019 +0800

    Add dependencies check script (#3941)
    
    * add plugin to do dependencies check
    * remove third-party properties file
    * polish config
    * polish config
    * use missing info in bash
---
 .gitignore      |  5 ++-
 licenseCheck.sh | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 pom.xml         | 35 +++++++++++++++++++++
 3 files changed, 135 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 0938f78..8989935 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,4 +31,7 @@ Thumbs.db
 *.orig
 
 # flatten ignore
-.flattened-pom.xml
\ No newline at end of file
+.flattened-pom.xml
+
+# license check result
+license-list.txt
\ No newline at end of file
diff --git a/licenseCheck.sh b/licenseCheck.sh
new file mode 100755
index 0000000..9992f10
--- /dev/null
+++ b/licenseCheck.sh
@@ -0,0 +1,96 @@
+#!/bin/bash
+
+APPEND_ARG=""
+FOLDER="./"
+LINE_FLAG="=============================================="
+TARGET_FILE="./license-list.txt"
+
+red=`tput setaf 1`
+green=`tput setaf 2`
+reset=`tput sgr0`
+
+
+if [ -n "$1" ]; then
+    echo "checking module $1"
+    APPEND_ARG="-f $1"
+    FOLDER="$1"
+else
+    echo "checking whole project"
+fi
+
+echo "Running command: ./mvnw clean package -DskipTests=true -PlicenseCheck 
$APPEND_ARG"
+
+./mvnw clean package -DskipTests=true -PlicenseCheck $APPEND_ARG
+
+status=$?
+if [ $status -eq 0 ]; then
+  echo "mvn command exec success"
+else
+  echo "${red}mvn command exec fail${reset}"
+  exit 1
+fi
+
+
+#contact and generate license file
+rm -rf $TARGET_FILE
+LICENSE_FILES=`find $FOLDER -type f -name "THIRD-PARTY.txt"|grep 
generated-sources`
+
+echo "Find license files:"
+echo "$LICENSE_FILES"
+
+for i in $LICENSE_FILES
+    do
+        echo "$LINE_FLAG" >> $TARGET_FILE
+        echo $i >> $TARGET_FILE
+        cat $i >> $TARGET_FILE
+    done
+
+echo "license files generated at $TARGET_FILE"
+
+#fix missing license dependencies
+missingLicense=(
+    "(Unknown license) jsr173_api:(Apache License, Version 2.0) jsr173_api"
+    "(Unknown license) \"Java Concurrency in Practice\" book annotations:(BEA 
licensed) \"Java Concurrency in Practice\" book annotations"
+    "(Unknown license) Java Portlet Specification V2.0:(Apache License, 
Version 2.0) Java Portlet Specification V2.0"
+)
+
+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
+done
+
+check_unknown_license=`cat $TARGET_FILE | grep "Unknown license"`
+
+#checking unknown license
+if grep -q "Unknown license" $TARGET_FILE
+then
+    echo "${red}Find unknown license${reset}"
+    echo "$check_unknown_license"
+    exit 1
+fi
+
+allowLicense=(
+    "CDDL"
+    "Apache"
+    "Common Development and Distribution License"
+    "Eclipse Public License"
+    "MIT"
+    "The 3-Clause BSD License"
+    "Public domain"
+)
+
+#filter allow license
+license_need_check=`cat $TARGET_FILE | grep -v 
"generated-sources/license/THIRD-PARTY.txt" | grep -v "third-party 
dependencies" | grep -v $LINE_FLAG`
+
+for i in "${allowLicense[@]}"; do
+    license_need_check=`echo "$license_need_check"|grep -vi "$i"`
+done
+
+if test -z "$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
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index a1f7b56..e9a1661 100644
--- a/pom.xml
+++ b/pom.xml
@@ -302,6 +302,41 @@
                 </plugins>
             </build>
         </profile>
+        <profile>
+            <id>licenseCheck</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>license-maven-plugin</artifactId>
+                        <version>1.20</version>
+                        <executions>
+                            <execution>
+                                <id>license-check</id>
+                                <phase>generate-sources</phase>
+                                <goals>
+                                    <goal>add-third-party</goal>
+                                </goals>
+                                <configuration>
+                                    <includeOptional>false</includeOptional>
+                                    <useMissingFile>false</useMissingFile>
+                                    <failOnMissing>false</failOnMissing>
+                                    <licenseMerges>
+                                        <licenseMerge>Apache License, Version 
2.0|The Apache Software License, Version
+                                            2.0|ASF 2.0|Apache 
2|Apache-2.0|Apache 2.0 License|Apache 2.0|Apache License v2.0|Apache License 
2.0|The Apache License, Version 2.0|The Apache Software License, Version 2.0
+                                        </licenseMerge>
+                                        <licenseMerge>The MIT License|MIT 
License</licenseMerge>
+                                        <licenseMerge>The 3-Clause BSD 
License|New BSD License|3-Clause BSD
+                                            License|BSD|3-Clause BSD 
License|The New BSD License
+                                        </licenseMerge>
+                                    </licenseMerges>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
     </profiles>
 
     <build>

Reply via email to