import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsTask

spotbugs {
    ignoreFailures = true
    effort = Effort.MAX
    reportLevel = Confidence.valueOf('MEDIUM')
}

tasks.withType(SpotBugsTask).configureEach { task ->
    String variantNameCap = task.name.replace("spotbugs", "")
    String variantName = variantNameCap.substring(0, 1).toLowerCase() + variantNameCap.substring(1)

    dependsOn "compile${variantNameCap}Sources"

    excludeFilter = file("${project.rootDir}/spotbugs-filter.xml")
    classes = fileTree(layout.buildDirectory.get().asFile.toString()+"/intermediates/javac/${variantName}/compile${variantNameCap}JavaWithJavac/classes/")
    reports {
        xml {
            required = true
        }
        html {
            required = true
            outputLocation = layout.buildDirectory.file("reports/spotbugs/spotbugs.html")
            stylesheet = 'fancy.xsl'
        }
    }
}

tasks.named("detekt").configure {
    reports {
        html.required.set(true)
        txt.required.set(true)
        xml.required.set(false)
        sarif.required.set(false)
        md.required.set(false)
    }
}

detekt {
    config.setFrom("../detekt.yml")
    source.setFrom("src/")
}
