Replace protected setter with protected member
It is more groovy? It is easier to read at least.
This commit is contained in:
parent
5968c4d9d1
commit
56f061b0b4
|
@ -38,26 +38,21 @@ public class LicenseHeadersTask extends AntTask {
|
|||
@OutputFile
|
||||
File reportFile = new File(project.buildDir, 'reports/licenseHeaders/rat.log')
|
||||
|
||||
private List<FileCollection> javaFiles
|
||||
/**
|
||||
* The list of java files to check. protected so the afterEvaluate closure in the
|
||||
* constructor can write to it.
|
||||
*/
|
||||
protected List<FileCollection> javaFiles
|
||||
|
||||
LicenseHeadersTask() {
|
||||
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 {
|
||||
List<FileCollection> javaFiles = project.sourceSets.collect({it.allJava})
|
||||
setJavaFiles(javaFiles)
|
||||
javaFiles = project.sourceSets.collect({it.allJava})
|
||||
inputs.files(javaFiles)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source sets this task processes. Should only be used by the afterEvaluate closure
|
||||
* in the constructor.
|
||||
*/
|
||||
protected void setJavaFiles(List<FileCollection> javaFiles) {
|
||||
this.javaFiles = javaFiles
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runAnt(AntBuilder ant) {
|
||||
ant.project.addTaskDefinition('ratReport', Report)
|
||||
|
|
|
@ -48,14 +48,16 @@ public class ThirdPartyAuditTask extends AntTask {
|
|||
private List<String> excludes = [];
|
||||
|
||||
/**
|
||||
* Input for the task. Set javadoc for {#link getJars} for more.
|
||||
* Input for the task. Set javadoc for {#link getJars} for more. Protected
|
||||
* so the afterEvaluate closure in the constructor can write it.
|
||||
*/
|
||||
private FileCollection jars;
|
||||
protected FileCollection jars;
|
||||
|
||||
/**
|
||||
* Classpath against which to run the third patty audit.
|
||||
* Classpath against which to run the third patty audit. Protected so the
|
||||
* afterEvaluate closure in the constructor can write it.
|
||||
*/
|
||||
private FileCollection classpath;
|
||||
protected FileCollection classpath;
|
||||
|
||||
/**
|
||||
* We use a simple "marker" file that we touch when the task succeeds
|
||||
|
@ -71,7 +73,6 @@ public class ThirdPartyAuditTask extends AntTask {
|
|||
dependsOn(project.configurations.testCompile);
|
||||
description = "Checks third party JAR bytecode for missing classes, use of internal APIs, and other horrors'";
|
||||
|
||||
|
||||
project.afterEvaluate {
|
||||
Configuration configuration = project.configurations.findByName('runtime');
|
||||
if (configuration == null) {
|
||||
|
@ -80,10 +81,10 @@ public class ThirdPartyAuditTask extends AntTask {
|
|||
configuration = project.configurations.findByName('testCompile');
|
||||
}
|
||||
assert configuration != null;
|
||||
setClasspath(configuration)
|
||||
classpath = configuration
|
||||
|
||||
// we only want third party dependencies.
|
||||
FileCollection jars = configuration.fileCollection({ dependency ->
|
||||
jars = configuration.fileCollection({ dependency ->
|
||||
dependency.group.startsWith("org.elasticsearch") == false
|
||||
});
|
||||
|
||||
|
@ -93,28 +94,11 @@ public class ThirdPartyAuditTask extends AntTask {
|
|||
if (provided != null) {
|
||||
jars -= provided
|
||||
}
|
||||
setJars(jars)
|
||||
inputs.files(jars)
|
||||
onlyIf { jars.isEmpty() == false }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the jars to process. This should only be called by the afterEvaluate
|
||||
* closure in the constructor.
|
||||
*/
|
||||
protected void setJars(FileCollection jars) {
|
||||
this.jars = jars
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the classpath against which to run the third party audit. This
|
||||
* should only be called by the afterEvaluate closure in the constructor.
|
||||
*/
|
||||
protected void setClasspath(FileCollection classpath) {
|
||||
this.classpath = classpath
|
||||
}
|
||||
|
||||
/**
|
||||
* classes that should be excluded from the scan,
|
||||
* e.g. because we know what sheisty stuff those particular classes are up to.
|
||||
|
|
Loading…
Reference in New Issue