From e53b27bd8063870b5198660179ac1296b673785c Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Wed, 4 Apr 2018 16:08:55 -0400 Subject: [PATCH 1/2] Enable license header exclusions There are some scenarios where the license on a source file is one that is compatible with our projects yet we do not want to add the license to the list of approved license headers (to keep the number of files with that compatible license contained). This commit adds the ability to exclude a file from the license check. --- .../gradle/precommit/LicenseHeadersTask.groovy | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/LicenseHeadersTask.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/LicenseHeadersTask.groovy index fccbb43e87230..9e67f6d5dcb33 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/LicenseHeadersTask.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/LicenseHeadersTask.groovy @@ -49,6 +49,14 @@ public class LicenseHeadersTask extends AntTask { @Input List approvedLicenses = ['Apache', 'Generated'] + /** + * Files that should be excluded from the license header check. Use with extreme care, only in situations where the license on the + * source file is compatible with the codebase but we do not want to add the license to the list of approved headers (to avoid the + * possibility of inadvertently using the license on our own source files). + */ + @Input + List excludedJavaFiles = [] + /** * Additional license families that may be found. The key is the license category name (5 characters), * followed by the family name and the value list of patterns to search for. @@ -95,7 +103,7 @@ public class LicenseHeadersTask extends AntTask { for (File dir: dirSet.srcDirs) { // sometimes these dirs don't exist, e.g. site-plugin has no actual java src/main... if (dir.exists()) { - ant.fileset(dir: dir) + ant.fileset(dir: dir, excludes: excludedJavaFiles.join(' ')) } } } From 63dd7ca869512b7cc426c42fd054fa42e7f9a8aa Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Wed, 4 Apr 2018 16:39:48 -0400 Subject: [PATCH 2/2] Use a more general name --- .../elasticsearch/gradle/precommit/LicenseHeadersTask.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/LicenseHeadersTask.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/LicenseHeadersTask.groovy index 9e67f6d5dcb33..45f60c35bf68f 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/LicenseHeadersTask.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/LicenseHeadersTask.groovy @@ -55,7 +55,7 @@ public class LicenseHeadersTask extends AntTask { * possibility of inadvertently using the license on our own source files). */ @Input - List excludedJavaFiles = [] + List excludes = [] /** * Additional license families that may be found. The key is the license category name (5 characters), @@ -103,7 +103,7 @@ public class LicenseHeadersTask extends AntTask { for (File dir: dirSet.srcDirs) { // sometimes these dirs don't exist, e.g. site-plugin has no actual java src/main... if (dir.exists()) { - ant.fileset(dir: dir, excludes: excludedJavaFiles.join(' ')) + ant.fileset(dir: dir, excludes: excludes.join(' ')) } } }