/*
 * Copyright (C) 2017-2021 HERE Europe B.V.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'com.github.spotbugs'

check.dependsOn 'checkstyle', 'pmd', 'lint'

checkstyle {
    toolVersion '8.12'
    ignoreFailures = false
    maxErrors = 0
    maxWarnings = 0
    configFile file("${project.rootDir}/quality/checkstyle/checkstyle.xml")
    configProperties.checkstyleSuppressionFilterPath = file(
            "${project.rootDir}/quality/checkstyle/suppressions.xml")
            .absolutePath
}

task checkstyle(type: Checkstyle, dependsOn: "assemble", group: 'verification') {
    source 'src'
    include '**/*.java'
    exclude '**/gen/**'
    exclude '**/R.java'
    exclude '**/BuildConfig.java'
    classpath = files()
}

pmd {
    toolVersion = '6.7.0'
    ignoreFailures = false
    ruleSets = []
    ruleSetFiles = files("${project.rootDir}/quality/pmd/pmd-ruleset.xml")
}

task pmd(type: Pmd, dependsOn: "assemble", group: 'verification') {
    source 'src'
    include '**/*.java'
    exclude('**/gen/**', '**/debug/**')

    reports {
        xml {
            enabled = true
            destination file("$projectDir.absolutePath/build/reports/pmd/pmd.xml")
        }
        html {
            enabled = true
            destination file("$projectDir.absolutePath/build/reports/pmd/pmd.html")
        }
    }
}

spotbugs {
    ignoreFailures = false
    effort = "max"
    reportLevel = "low"
    excludeFilter = file("${project.rootDir}/quality/spotbugs/spotbugs-filter.xml")
}
