Skip to content

Commit ae566bb

Browse files
committed
Enable license header exclusions (#29379)
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.
1 parent f93f7bb commit ae566bb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/LicenseHeadersTask.groovy

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ public class LicenseHeadersTask extends AntTask {
4949
@Input
5050
List<String> approvedLicenses = ['Apache', 'Generated']
5151

52+
/**
53+
* Files that should be excluded from the license header check. Use with extreme care, only in situations where the license on the
54+
* 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
55+
* possibility of inadvertently using the license on our own source files).
56+
*/
57+
@Input
58+
List<String> excludes = []
59+
5260
/**
5361
* Additional license families that may be found. The key is the license category name (5 characters),
5462
* followed by the family name and the value list of patterns to search for.
@@ -95,7 +103,7 @@ public class LicenseHeadersTask extends AntTask {
95103
for (File dir: dirSet.srcDirs) {
96104
// sometimes these dirs don't exist, e.g. site-plugin has no actual java src/main...
97105
if (dir.exists()) {
98-
ant.fileset(dir: dir)
106+
ant.fileset(dir: dir, excludes: excludes.join(' '))
99107
}
100108
}
101109
}

0 commit comments

Comments
 (0)