Auto skip license headers on no source (#35640)
* Unmute BuildExamplePluginsIT * Skip licenseHeaders when there are no sources
This commit is contained in:
parent
7b2d547e8e
commit
8659af68e0
|
@ -24,7 +24,9 @@ import org.apache.rat.license.SimpleLicenseFamily
|
||||||
import org.elasticsearch.gradle.AntTask
|
import org.elasticsearch.gradle.AntTask
|
||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.api.tasks.Input
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.InputFiles
|
||||||
import org.gradle.api.tasks.OutputFile
|
import org.gradle.api.tasks.OutputFile
|
||||||
|
import org.gradle.api.tasks.SkipWhenEmpty
|
||||||
import org.gradle.api.tasks.SourceSet
|
import org.gradle.api.tasks.SourceSet
|
||||||
|
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
|
@ -39,12 +41,6 @@ public class LicenseHeadersTask extends AntTask {
|
||||||
@OutputFile
|
@OutputFile
|
||||||
File reportFile = new File(project.buildDir, 'reports/licenseHeaders/rat.log')
|
File reportFile = new File(project.buildDir, 'reports/licenseHeaders/rat.log')
|
||||||
|
|
||||||
/**
|
|
||||||
* The list of java files to check. protected so the afterEvaluate closure in the
|
|
||||||
* constructor can write to it.
|
|
||||||
*/
|
|
||||||
protected List<FileCollection> javaFiles
|
|
||||||
|
|
||||||
/** Allowed license families for this project. */
|
/** Allowed license families for this project. */
|
||||||
@Input
|
@Input
|
||||||
List<String> approvedLicenses = ['Apache', 'Generated']
|
List<String> approvedLicenses = ['Apache', 'Generated']
|
||||||
|
@ -65,11 +61,16 @@ public class LicenseHeadersTask extends AntTask {
|
||||||
|
|
||||||
LicenseHeadersTask() {
|
LicenseHeadersTask() {
|
||||||
description = "Checks sources for missing, incorrect, or unacceptable license headers"
|
description = "Checks sources for missing, incorrect, or unacceptable license headers"
|
||||||
// Delay resolving the dependencies until after evaluation so we pick up generated sources
|
|
||||||
project.afterEvaluate {
|
|
||||||
javaFiles = project.sourceSets.collect({it.allJava})
|
|
||||||
inputs.files(javaFiles)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of java files to check. protected so the afterEvaluate closure in the
|
||||||
|
* constructor can write to it.
|
||||||
|
*/
|
||||||
|
@InputFiles
|
||||||
|
@SkipWhenEmpty
|
||||||
|
public List<FileCollection> getJavaFiles() {
|
||||||
|
return project.sourceSets.collect({it.allJava})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,9 +98,8 @@ public class LicenseHeadersTask extends AntTask {
|
||||||
Files.deleteIfExists(reportFile.toPath())
|
Files.deleteIfExists(reportFile.toPath())
|
||||||
|
|
||||||
// run rat, going to the file
|
// run rat, going to the file
|
||||||
List<FileCollection> input = javaFiles
|
|
||||||
ant.ratReport(reportFile: reportFile.absolutePath, addDefaultLicenseMatchers: true) {
|
ant.ratReport(reportFile: reportFile.absolutePath, addDefaultLicenseMatchers: true) {
|
||||||
for (FileCollection dirSet : input) {
|
for (FileCollection dirSet : javaFiles) {
|
||||||
for (File dir: dirSet.srcDirs) {
|
for (File dir: dirSet.srcDirs) {
|
||||||
// sometimes these dirs don't exist, e.g. site-plugin has no actual java src/main...
|
// sometimes these dirs don't exist, e.g. site-plugin has no actual java src/main...
|
||||||
if (dir.exists()) {
|
if (dir.exists()) {
|
||||||
|
|
|
@ -4,4 +4,3 @@ apply plugin: 'nebula.maven-scm'
|
||||||
|
|
||||||
test.enabled = false
|
test.enabled = false
|
||||||
jarHell.enabled = false
|
jarHell.enabled = false
|
||||||
licenseHeaders.enabled = false
|
|
||||||
|
|
|
@ -74,7 +74,6 @@ task destroy(type: org.elasticsearch.gradle.vagrant.VagrantCommandTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
thirdPartyAudit.enabled = false
|
thirdPartyAudit.enabled = false
|
||||||
licenseHeaders.enabled = false
|
|
||||||
test.enabled = false
|
test.enabled = false
|
||||||
|
|
||||||
// installKDC uses tabs in it for the Kerberos ACL file.
|
// installKDC uses tabs in it for the Kerberos ACL file.
|
||||||
|
|
|
@ -16,5 +16,3 @@ subprojects {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// the qa modules does not have any source files
|
|
||||||
licenseHeaders.enabled = false
|
|
||||||
|
|
|
@ -38,6 +38,5 @@ task destroy(type: org.elasticsearch.gradle.vagrant.VagrantCommandTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
thirdPartyAudit.enabled = false
|
thirdPartyAudit.enabled = false
|
||||||
licenseHeaders.enabled = false
|
|
||||||
test.enabled = false
|
test.enabled = false
|
||||||
jarHell.enabled = false
|
jarHell.enabled = false
|
||||||
|
|
|
@ -38,6 +38,5 @@ task destroy(type: org.elasticsearch.gradle.vagrant.VagrantCommandTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
thirdPartyAudit.enabled = false
|
thirdPartyAudit.enabled = false
|
||||||
licenseHeaders.enabled = false
|
|
||||||
test.enabled = false
|
test.enabled = false
|
||||||
jarHell.enabled = false
|
jarHell.enabled = false
|
||||||
|
|
Loading…
Reference in New Issue