From 7ae3cc1084d7ddc6baeedf230ecbc5ff4ab25d03 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 31 Mar 2021 17:35:29 -0700 Subject: [PATCH] GUACAMOLE-1298: Ensure LICENSE/NOTICE generation takes current build into account (not central repository). --- doc/licenses/generate-license-files.sh | 46 ++++++++++++++------------ pom.xml | 23 +++++++++++++ 2 files changed, 48 insertions(+), 21 deletions(-) diff --git a/doc/licenses/generate-license-files.sh b/doc/licenses/generate-license-files.sh index 07ea3d845..3148d12d7 100755 --- a/doc/licenses/generate-license-files.sh +++ b/doc/licenses/generate-license-files.sh @@ -28,8 +28,8 @@ # generate-license-files.sh # ------------------------- # -# Automatically iterates through the runtime dependencies of the Maven project -# in the current directory, creating new LICENSE and NOTICE files which +# Automatically iterates through the provided runtime dependencies of the Maven +# project in the current directory, creating new LICENSE and NOTICE files which # contain all the license information of bundled dependencies, as well as any # required notices. # @@ -38,10 +38,12 @@ # # USAGE: # -# path/to/generate-license-files.sh OUTPUT_DIRECTORY +# path/to/generate-license-files.sh DEPENDENCY_LIST OUTPUT_DIRECTORY # -# where OUTPUT_DIRECTORY is the directory in which the LICENSE and NOTICE -# files should be written, along with verbatim copies of all relevant licenses. +# where DEPENDENCY_LIST is the list of Maven dependencies to consider when +# generating LICENSE and NOTICE (as produced by "mvn dependency:list") and +# OUTPUT_DIRECTORY is the directory in which the LICENSE and NOTICE files +# should be written. # # Structure of license information # -------------------------------- @@ -110,26 +112,22 @@ LICENSES_DIR="`dirname "$0"`" ## BASEDIR="$LICENSES_DIR/../.." +## +## The file containing all relevant runtime dependencies, as generated by +## "mvn dependency:list". +## +DEPENDENCY_LIST="$1" + ## ## The output directory in which the generated LICENSE, NOTICE, etc. files ## should be placed. ## -OUTPUT_DIR="$1" - -## -## Lists the Maven coordinates of all runtime dependencies of the current -## project. Each dependency is listed on its own line. -## -list_dependencies() { - mvn -q dependency:list -DincludeScope=runtime -DoutputFile=/dev/stdout \ - | grep -v '\' \ - | grep -o '[^: ]*:[^: ]*:[^: ]*:[^: ]*' | sort -u -} +OUTPUT_DIR="$2" ## ## Lists the license information directories (subdirectories of the ## "doc/licenses/" directory in the main guacamole-client source tree) that -## apply to runtime dependencies of the current project. If any runtime +## apply to the list of runtime dependencies provided via STDIN. If any runtime ## dependencies are not described by license information included in the ## guacamole-client source tree, a error is printed to STDERR. ## @@ -141,7 +139,7 @@ list_dependency_license_info() { # List the license directories of all runtime dependencies, as dictated by # the "maven-coordinates.txt" files included within those directores - list_dependencies | while read DEPENDENCY; do + grep -o '[^: ]*:[^: ]*:[^: ]*:[^: ]*' | while read DEPENDENCY; do if ! grep -l "$DEPENDENCY[[:space:]]*$" "$LICENSES_DIR"/*/maven-coordinates.txt; then error "License information missing for $DEPENDENCY" @@ -269,8 +267,14 @@ trim_file() { } # Verify that an output directory was provided -if [ -z "$OUTPUT_DIR" ]; then - error "USAGE: $0 OUTPUT_DIRECTORY" +if [ -z "$DEPENDENCY_LIST" -o -z "$OUTPUT_DIR" ]; then + error "USAGE: $0 DEPENDENCY_LIST OUTPUT_DIRECTORY" + exit 1 +fi + +# Verify input file actually exists +if [ ! -r "$DEPENDENCY_LIST" ]; then + error "$DEPENDENCY_LIST cannot be read." exit 1 fi @@ -293,7 +297,7 @@ cp "$BASEDIR/NOTICE" "$OUTPUT_DIR/" # PREAMBLE_ADDED=0 -list_dependency_license_info | sort_dependency_license_info | \ +list_dependency_license_info < "$DEPENDENCY_LIST" | sort_dependency_license_info | \ while read LICENSE_INFO_DIR; do # Add subcomponent license preamble if not already added diff --git a/pom.xml b/pom.xml index e49e865cd..4c109731d 100644 --- a/pom.xml +++ b/pom.xml @@ -120,6 +120,28 @@ + + + org.apache.maven.plugins + maven-dependency-plugin + 3.1.2 + + + list-runtime-dependencies + generate-resources + + runtime + false + org.apache.guacamole + ${project.build.directory}/runtime-dependencies.txt + + + list + + + + + @@ -163,6 +185,7 @@ ${rootlocation}/doc/licenses/generate-license-files.sh + ${project.build.directory}/runtime-dependencies.txt ${project.build.directory}/licenses ${skipLicenseGeneration}