com.danielsomerfield.cvecheck.gradle.CVECheckExtension.groovy Maven / Gradle / Ivy
package com.danielsomerfield.cvecheck.gradle
import com.danielsomerfield.cvecheck.ScanResultHandler
import com.danielsomerfield.cvecheck.gradle.handlers.BuildRulesScanResultHandler
import com.danielsomerfield.cvecheck.gradle.handlers.buildRules.BuildRule
import com.danielsomerfield.cvecheck.gradle.handlers.buildRules.BuildRuleBuilder
import com.danielsomerfield.cvecheck.gradle.handlers.buildRules.BuildRules
import com.danielsomerfield.cvecheck.gradle.handlers.buildRules.ListBackedBuildRules
class CVECheckExtension {
private final BuildRuleBuilder buildRuleBuilder
private final BuildRules buildRules
CVECheckExtension(
final BuildRuleBuilder buildRuleBuilder,
final List defaultBuildRules
) {
this.buildRuleBuilder = buildRuleBuilder
this.buildRules = new ListBackedBuildRules(defaultBuildRules)
}
/* Configuration properties */
private ScanResultHandler scanResultHandler
def long refreshAfter = 86400 /** Seconds **/
def ScanResultHandler getScanResultHandler(){
if (this.scanResultHandler == null) {
this.scanResultHandler = new BuildRulesScanResultHandler(buildRules)
}
};
def void setScanResultHandler(ScanResultHandler scanResultHandler) {
this.scanResultHandler = scanResultHandler
}
def buildRule(Closure ruleConfigClosure) {
ruleConfigClosure.resolveStrategy = Closure.DELEGATE_FIRST
ruleConfigClosure.delegate = buildRuleBuilder
ruleConfigClosure()
buildRules.addBuildRule(buildRuleBuilder.create().value)
}
public BuildRules getBuildRules() {
buildRules
}
}