All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.danielsomerfield.cvecheck.gradle.CVECheckExtension.groovy Maven / Gradle / Ivy

There is a newer version: 0.6.2-100
Show newest version
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
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy