boolivar/jdoc-test

View on GitHub
buildSrc/src/main/groovy/java-conventions.gradle

Summary

Maintainability
Test Coverage
plugins {
    id "java"
    id "jacoco"
    id "pmd"
    id "checkstyle"
    id "com.github.spotbugs"
    id "io.freefair.lombok"
}

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
    withJavadocJar()
    withSourcesJar()
}

compileJava {
    options.release = 8
}

javadoc {
    options.addBooleanOption("Xdoclint:none", true)
}

test {
    useJUnitPlatform()
    finalizedBy jacocoTestReport
}

jacocoTestReport {
    reports {
        xml.required = true
    }
}

jacocoTestCoverageVerification {
    dependsOn test
    violationRules {
        rule {
            limit {
                minimum = jacocoMinRatio as BigDecimal
            }
        }
    }
}

check.dependsOn jacocoTestCoverageVerification

jar.dependsOn check

checkstyle {
    configDirectory = file("$rootDir/gradle/config/checkstyle")
    toolVersion = "9.3"
}

pmd {
    consoleOutput = true
    ruleSets = ["ruleset.xml"]
}

tasks.withType(Pmd).configureEach {
    pmdClasspath += files("$rootDir/gradle/config/pmd")
}

spotbugs {
    omitVisitors = ["ConstructorThrow", "DoInsideDoPrivileged", "FindReturnRef"]
}

spotbugsTest {
    omitVisitors.addAll(["DumbMethodInvocations"])
}

repositories {
    mavenCentral()
    maven { url "https://jitpack.io" }
}

configurations {
    internalPlatform {
        visible = false
    }
    [compileClasspath, runtimeClasspath, testCompileClasspath, testRuntimeClasspath].each {
        it.extendsFrom internalPlatform
    }
}

dependencies {
    internalPlatform platform(project(":jdoc-platform"))

    testImplementation "org.assertj:assertj-core"
    testImplementation "org.junit.jupiter:junit-jupiter"
    testImplementation "org.junit.platform:junit-platform-suite"
    testImplementation "org.mockito:mockito-junit-jupiter"
}