GUACAMOLE-1298: Ensure LICENSE/NOTICE generation takes current build into account (not central repository).
diff --git a/doc/licenses/generate-license-files.sh b/doc/licenses/generate-license-files.sh
index 07ea3d8..3148d12 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
# --------------------------------
@@ -111,25 +113,21 @@
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 '\<org\.apache\.guacamole\>' \
- | 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 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 @@
}
# 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 @@
#
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 e49e865..4c10973 100644
--- a/pom.xml
+++ b/pom.xml
@@ -120,6 +120,28 @@
</executions>
</plugin>
+ <!-- Automatically generate list of runtime dependencies -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.1.2</version>
+ <executions>
+ <execution>
+ <id>list-runtime-dependencies</id>
+ <phase>generate-resources</phase>
+ <configuration>
+ <includeScope>runtime</includeScope>
+ <excludeReactor>false</excludeReactor>
+ <excludeGroupIds>org.apache.guacamole</excludeGroupIds>
+ <outputFile>${project.build.directory}/runtime-dependencies.txt</outputFile>
+ </configuration>
+ <goals>
+ <goal>list</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
<pluginManagement>
@@ -163,6 +185,7 @@
<configuration>
<executable>${rootlocation}/doc/licenses/generate-license-files.sh</executable>
<arguments>
+ <argument>${project.build.directory}/runtime-dependencies.txt</argument>
<argument>${project.build.directory}/licenses</argument>
</arguments>
<skip>${skipLicenseGeneration}</skip>