From 51503061ffa938a4b359029b0da658d0bd8892a0 Mon Sep 17 00:00:00 2001 From: Mike Drob Date: Fri, 16 Jun 2017 21:53:13 -0500 Subject: [PATCH] HBASE-16351 Improve error reporting for license failures --- .../src/main/resources/META-INF/LICENSE.vm | 30 +++++++++--- .../src/main/resources/META-INF/NOTICE.vm | 10 +--- pom.xml | 57 ++++++++++++++++++++++ 3 files changed, 81 insertions(+), 16 deletions(-) diff --git a/hbase-resource-bundle/src/main/resources/META-INF/LICENSE.vm b/hbase-resource-bundle/src/main/resources/META-INF/LICENSE.vm index f842d00c67..7183310654 100644 --- a/hbase-resource-bundle/src/main/resources/META-INF/LICENSE.vm +++ b/hbase-resource-bundle/src/main/resources/META-INF/LICENSE.vm @@ -1550,7 +1550,27 @@ ${dep.scm.url} #thrift_license() #end ## Note that this will fail the build if we don't have a license. update supplemental-models. -#if( !(${dep.licenses[0].name.contains("Apache License, Version 2.0")} || ${dep.licenses[0].name.contains("The Apache Software License, Version 2.0")}) ) +#if( ${dep.licenses.isEmpty()} ) +-- +ERROR: ${dep.name} dependency found without license information! + +Please find the appropriate license and update supplemental-models.xml or +revert the change that added this dependency. + +More info on the dependency: + +${dep.groupId} +${dep.artifactId} +${dep.version} + +maven central search +g:${dep.groupId} AND a:${dep.artifactId} AND v:${dep.version} + +project website +${dep.url} +project source +${dep.scm.url} +#elseif( !(${dep.licenses[0].name.contains("Apache License, Version 2.0")} || ${dep.licenses[0].name.contains("The Apache Software License, Version 2.0")}) ) #if( ${dep.licenses[0].name.contains("CDDL")} ) #if( ${dep.licenses[0].name.contains("1.0")} ) #set($aggregated = $cddl_1_0.add($dep)) @@ -1576,7 +1596,7 @@ This product includes ${dep.name} licensed under the ${dep.licenses[0].name}. ${dep.licenses[0].comments} #if(!(${non_aggregate_fine.contains($dep.licenses[0].name)})) -Please check ^^^^^^^^^^^^ this License for acceptability here: +ERROR: Please check ^^^^^^^^^^^^ this License for acceptability here: https://www.apache.org/legal/resolved @@ -1596,12 +1616,6 @@ project website ${dep.url} project source ${dep.scm.url} - -## fail the template. If you're looking at the source LICENSE.vm -## file based on a stacktrace or exception message, you need to find -## the generated LICENSE file that has the actual dependency info printed. -#set($empty = []) -${empty[0]} #end #end #end diff --git a/hbase-resource-bundle/src/main/resources/META-INF/NOTICE.vm b/hbase-resource-bundle/src/main/resources/META-INF/NOTICE.vm index c77ade53e7..953b316ed4 100644 --- a/hbase-resource-bundle/src/main/resources/META-INF/NOTICE.vm +++ b/hbase-resource-bundle/src/main/resources/META-INF/NOTICE.vm @@ -270,14 +270,7 @@ project website ${dep.url} project source ${dep.scm.url} - - - -## fail the template. If you're looking at the source NOTICE.vm -## file based on a stacktrace or exception message, you need to find -## the generated NOTICE file that has the actual dependency info printed. -${dep.license[0]} -#end +#else #if( !(${dep.licenses[0].name.contains("BSD")} || ${dep.licenses[0].name.contains("MIT")}) ) #if( !(${dep.licenses[0].name.equals("Public Domain")}) ) #if( !(${dep.licenses[0].name.contains("Apache Software License, Version 2.0")}) ) @@ -309,6 +302,7 @@ For source see '${dep.url}'. #end #end #end +#end ## Print out jetty #if(${jetty}) #jetty_notice(${jetty-with-crypt}) diff --git a/pom.xml b/pom.xml index 45f8e45934..1b87973a2e 100644 --- a/pom.xml +++ b/pom.xml @@ -913,6 +913,24 @@ + org.codehaus.mojo + build-helper-maven-plugin + + + negate-license-bundles-property + + bsh-property + + + skip.license.check = !${license.bundles.dependencies}; + + skip.license.check + + + + + + org.apache.maven.plugins maven-enforcer-plugin 1.4 @@ -1009,6 +1027,41 @@ + + check-aggregate-license + + process-resources + + enforce + + + + + + File license = new File("${license.aggregate.path}"); + + // Beanshell does not support try-with-resources, + // so we must close this scanner manually + Scanner scanner = new Scanner(license); + + while (scanner.hasNextLine()) { + if (scanner.nextLine().startsWith("ERROR:")) { + scanner.close(); + return false; + } + } + scanner.close(); + return true; + + + License errors detected, for more detail find ERROR in + ${license.aggregate.path} + + + + ${skip.license.check} + + @@ -1270,6 +1323,10 @@ false false + + + ${project.build.directory}/maven-shared-archive-resources/META-INF/LICENSE + ${project.build.finalName}.tar.gz yyyy-MM-dd'T'HH:mm -- 2.13.0