This is an automated email from the ASF dual-hosted git repository. tbouron pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-dist.git
The following commit(s) were added to refs/heads/master by this push: new a22d6d4 enhance license generation scripts new 48bea88 Merge pull request #142 from ahgittin/licensing a22d6d4 is described below commit a22d6d48033ab25ca4edb56ee4aeb3d0bc9cd0e0 Author: Alex Heneveld <alex.henev...@cloudsoftcorp.com> AuthorDate: Tue Apr 23 09:47:32 2019 +0100 enhance license generation scripts * make friendlier for downstream projects to reuse (--loadonly mode, --keep-metadata-files, extra args to maven) * search in linked directories * remove outdated/unsupported reporting instructions --- dist/licensing/README.md | 25 ------------------- dist/licensing/generate-all.sh | 35 ++++++++++++++++++++------- dist/licensing/generate-license-and-notice.sh | 18 +++++++++++--- 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/dist/licensing/README.md b/dist/licensing/README.md index 1f5323b..2a1d458 100644 --- a/dist/licensing/README.md +++ b/dist/licensing/README.md @@ -91,31 +91,6 @@ If so: 3. Add the reference to the project in `generate-all.sh` -# Reports - -In the usage/dist/ project of Brooklyn - -To see a tree of license info: - - mvn org.heneveld.maven:license-audit-maven-plugin:report \ - -Dformat=summary \ - -DlicensesPreferred=ASL2,ASL,EPL1,BSD-2-Clause,BSD-3-Clause,CDDL1.1,CDDL1,CDDL \ - -DoverridesFile=licensing/overrides.yaml \ - -DextrasFiles=`cat licensing/extras-files` - -## CSV License Report - -If you need to generate a CSV report of license usage, e.g. for use in a spreadsheet: - - mvn org.heneveld.maven:license-audit-maven-plugin:report \ - -Dformat=csv \ - -DlistDependencyIdOnly=true \ - -DsuppressExcludedDependencies=true \ - -DlicensesPreferred=ASL2,ASL,EPL1,BSD-2-Clause,BSD-3-Clause,CDDL1.1,CDDL1,CDDL \ - -DoverridesFile=licensing/overrides.yaml \ - -DextrasFiles=`cat licensing/extras-files` \ - -DoutputFile=dependencies-licenses.csv - ## Other Tools The command `mvn project-info-reports:dependencies` is a different tool for checking mvn dependencies; diff --git a/dist/licensing/generate-all.sh b/dist/licensing/generate-all.sh index b8566ad..4c1a0a1 100755 --- a/dist/licensing/generate-all.sh +++ b/dist/licensing/generate-all.sh @@ -32,6 +32,11 @@ EOF while [ ! -z "$*" ] ; do if [ "$1" == "--help" ]; then usage ; exit 0; fi + if [ "$1" == "--loadonly" ]; then + LOAD_ONLY=true + shift + continue + fi usage echo Unexpected argument: $1 @@ -39,9 +44,8 @@ while [ ! -z "$*" ] ; do done - -REF_DIR=$(pushd $(dirname $0) > /dev/null ; pwd -P ; popd > /dev/null) -PARTS_DIR=$REF_DIR/parts +REF_DIR=$(pushd $(dirname $BASH_SOURCE) > /dev/null ; pwd -P ; popd > /dev/null) +if [ -z "$PARTS_DIR" ] ; then PARTS_DIR=$REF_DIR/parts ; fi ROOT_DIR=$REF_DIR/../../.. MVN_OUTFILE=$REF_DIR/notices.autogenerated @@ -63,6 +67,7 @@ make_for() { OUT=${PROJ}/$2 MODE=$3 SEARCH_ROOT=$4 + ARGS=$5 if [ -z "$SEARCH_ROOT" ] ; then SEARCH_ROOT=$PROJ ; fi echo Generating for $PROJ mode $MODE to $2... @@ -77,11 +82,12 @@ make_for() { --license $PARTS_DIR/license-top \ --license $PARTS_DIR/license-deps \ --notice $PARTS_DIR/notice-top --notice-compute-with-flags " - -DextrasFiles=$(prefix_and_join_array "" ":" "" $(find $SEARCH_ROOT -name "license-inclusions-source-*")) + -DextrasFiles=$(prefix_and_join_array "" ":" "" $(find -L $SEARCH_ROOT -name "license-inclusions-source-*")) -DonlyExtras=true" \ --notice $PARTS_DIR/notice-additional --notice-compute-with-flags " - -DextrasFiles=$(prefix_and_join_array "" ":" "" $(find $SEARCH_ROOT -name "license-inclusions-binary-*"))" \ - --libraries ${REF_DIR} ${SEARCH_ROOT} + -DextrasFiles=$(prefix_and_join_array "" ":" "" $(find -L $SEARCH_ROOT -name "license-inclusions-binary-*"))" \ + $ARGS \ + --libraries ${REF_DIR} ${SEARCH_ROOT} elif [ "$MODE" == "binary-primary" ] ; then @@ -90,8 +96,9 @@ make_for() { --license $PARTS_DIR/license-top \ --license $PARTS_DIR/license-deps \ --notice $PARTS_DIR/notice-top --notice-compute-with-flags " - -DextrasFiles=$(prefix_and_join_array "" ":" "" $(find $SEARCH_ROOT -name "license-inclusions-source-*" -or -name "license-inclusions-binary-*"))" \ - --libraries ${REF_DIR} ${SEARCH_ROOT} + -DextrasFiles=$(prefix_and_join_array "" ":" "" $(find -L $SEARCH_ROOT -name "license-inclusions-source-*" -or -name "license-inclusions-binary-*"))" \ + $ARGS \ + --libraries ${REF_DIR} ${SEARCH_ROOT} elif [ "$MODE" == "binary-omitted" ] ; then @@ -100,8 +107,9 @@ make_for() { --license $PARTS_DIR/license-top \ --license $PARTS_DIR/license-deps \ --notice $PARTS_DIR/notice-top --notice-compute-with-flags " - -DextrasFiles=$(prefix_and_join_array "" ":" "" $(find $SEARCH_ROOT -name "license-inclusions-source-*")) + -DextrasFiles=$(prefix_and_join_array "" ":" "" $(find -L $SEARCH_ROOT -name "license-inclusions-source-*")) -DonlyExtras=true" \ + $ARGS \ --libraries ${REF_DIR} ${SEARCH_ROOT} else @@ -116,6 +124,12 @@ make_for() { # build licenses for all the projects +if [ "$LOAD_ONLY" == "true" ] ; then + echo loaded license generation libraries + +else + + # include deps in files pulled in to Go CLI binary builds make_for $ROOT_DIR/brooklyn-client/cli/ release/license/files binary-primary make_for $ROOT_DIR/brooklyn-client/cli/ . binary-additional @@ -149,3 +163,6 @@ cp $OUT/{NOTICE,LICENSE} $PROJ/../karaf/apache-brooklyn/src/main/resources/ # finally in root project list everything make_for $ROOT_DIR/brooklyn-dist/dist ../.. binary-additional $ROOT_DIR + +fi + diff --git a/dist/licensing/generate-license-and-notice.sh b/dist/licensing/generate-license-and-notice.sh index 120cf27..09a8175 100755 --- a/dist/licensing/generate-license-and-notice.sh +++ b/dist/licensing/generate-license-and-notice.sh @@ -27,6 +27,7 @@ Usage: generate-license-and-notice.sh [-o <output-dir>] [-s <suffix>] [ [--notice <header-file>] [--notice-compute-with-flags <flags>]* ]+ [--libraries <search-dir> [<seach-dir>]+] + [--keep-metadata-file <filename>] Generates LICENSE and NOTICE files based on dependencies. @@ -91,6 +92,13 @@ while [ ! -z "$*" ] ; do continue fi + if [ "$1" == "--keep-metadata-file" ] ; then + shift + KEEP_METADATA_FILE=$1 + shift + continue + fi + usage echo Unexpected argument: $1 exit 1 @@ -130,9 +138,9 @@ TEMP_MVN_OUT=`pwd -P`/temp.license-maven-output.log echo > $TEMP_METADATA_FILE if [ ! -z "$LIBRARIES" ] ; then - echo Using metadata libraries $(find "${LIBRARIES[@]}" -name "license-metadata-*") + echo Using metadata libraries from "${LIBRARIES[@]}": $(find -L "${LIBRARIES[@]}" -name "license-metadata-*") # sort by filename first, then by path, with later ones alpha being the ones that are ultimately used - for x in $(find "${LIBRARIES[@]}" -name "license-metadata-*" | sed 's/\(.*\/\)\(.*\)/\2 --- \1\2/' | sort | sed 's/.* --- //') ; do + for x in $(find -L "${LIBRARIES[@]}" -name "license-metadata-*" | sed 's/\(.*\/\)\(.*\)/\2 --- \1\2/' | sort | sed 's/.* --- //') ; do cat $x >> $TEMP_METADATA_FILE done fi @@ -182,7 +190,7 @@ MISSING=() if [ -s ${TEMP_LICENSES_}2 ] ; then echo Adding ${LICENSES[$I]} to $LICENSE_FILE and `cat ${TEMP_LICENSES_}2 | wc -l` licenses:`cat ${TEMP_LICENSES_}2 | sed 's/^/ /' | paste -sd ';' -` cat ${LICENSES[${#LICENSES[@]}-1]} >> $LICENSE_FILE - LICENSE_TEXT_PATHS=$(find ${LIBRARIES[@]} -name license-text) + LICENSE_TEXT_PATHS=$(find -L ${LIBRARIES[@]} -name license-text) while read x ; do @@ -219,6 +227,10 @@ fi cp $NOTICE_FILE $NOTICE_FILE.tmp grep -v "License URL:" $NOTICE_FILE.tmp > $NOTICE_FILE +if [ ! -z "$KEEP_METADATA_FILE" ] ; then + cp $TEMP_METADATA_FILE $KEEP_METADATA_FILE +fi + rm -f $NOTICE_FILE.tmp $TEMP_METADATA_FILE $TEMP_NOTICE_DATA_FILE $TEMP_MVN_OUT ${TEMP_LICENSES_}* exit 0