plugins.apply('pmd')

pmd {
    toolVersion = '5.4.1'
}

task pmd(type: Pmd) {
    ignoreFailures = false // Fail early.
    ruleSetFiles = files("${project.rootDir}/code_quality_tools/pmd.xml")
    ruleSets = []

    source = fileTree('src/main/java')
}

plugins.apply('findbugs')

task findbugs(type: FindBugs) {
    ignoreFailures = false // Fail early.
    effort = 'max'
    reportLevel = 'low' // Report even low priority problems.

    reports {
        html.enabled = true
        xml.enabled = false
    }

    classes = files("${project.projectDir}/build/intermediates/classes")
    source = fileTree('src/main/java')

    // If somebody has an idea how to make this work with support libraries -> open a PR please.
    classpath = files()

    excludeFilter = new File("${project.rootDir}/code_quality_tools/findbugs-filter.xml")
}

plugins.apply('checkstyle')

checkstyle {
    toolVersion = '6.16.1'
}

task checkstyle(type: Checkstyle) {
    configFile rootProject.file('checkstyle.xml')
    configFile file("${project.rootDir}/code_quality_tools/checkstyle.xml")

    ignoreFailures false // Fail early.
    showViolations true

    source 'src'
    include '**/*.java'

    classpath = files()
}