checkLicense.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. #
  3. # Licensed to the Apache Software Foundation (ASF) under one or more
  4. # contributor license agreements. See the NOTICE file distributed with
  5. # this work for additional information regarding copyright ownership.
  6. # The ASF licenses this file to You under the Apache License, Version 2.0
  7. # (the "License"); you may not use this file except in compliance with
  8. # the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. set -e
  19. if [ -d "/tmp/seatunnel-dependencies" ]; then
  20. rm -rf /tmp/seatunnel-dependencies/*
  21. fi
  22. ./mvnw clean -pl '!seatunnel-dist' --batch-mode --no-snapshot-updates dependency:copy-dependencies -DincludeScope=runtime -DoutputDirectory=/tmp/seatunnel-dependencies
  23. # List all modules(jars) that belong to the SeaTunnel itself, these will be ignored when checking the dependency
  24. ls /tmp/seatunnel-dependencies | sort > all-dependencies.txt
  25. echo "start"
  26. # licenses
  27. echo '=== Self modules: ' && ./mvnw --batch-mode --quiet -Dexec.executable='echo' -Dexec.args='${project.artifactId}-${project.version}.jar' exec:exec | tee self-modules.txt
  28. # Exclude all self modules(jars) to generate all third-party dependencies
  29. echo '=== Third party dependencies: ' && grep -vf self-modules.txt all-dependencies.txt | sort | uniq | tee third-party-dependencies.txt
  30. # 1. Compare the third-party dependencies with known dependencies, expect that all third-party dependencies are KNOWN
  31. # and the exit code of the command is 0, otherwise we should add its license to LICENSE file and add the dependency to
  32. # known-dependencies.txt. 2. Unify the `sort` behaviour: here we'll sort them again in case that the behaviour of `sort`
  33. # command in target OS is different from what we used to sort the file `known-dependencies.txt`, i.e. "sort the two file
  34. # using the same command (and default arguments)"
  35. diff -w -B -U0 <(sort < tools/dependencies/known-dependencies.txt) <(sort < third-party-dependencies.txt)