Skip to content
Snippets Groups Projects
build.gradle 4.49 KiB
Newer Older
Danel Rod's avatar
Danel Rod committed
import java.time.LocalDateTime
import java.time.temporal.ChronoUnit

plugins {
    id 'java'
    id 'jacoco'
    id 'io.quarkus'
    id 'org.sonarqube'
    id 'maven-publish'
Danel Rod's avatar
Danel Rod committed
    id 'org.ajoberstar.grgit' version '5.0.0'
    id "com.diffplug.spotless" version "6.19.0"
    id "com.github.vlsi.jandex" version "1.90"
Danel Rod's avatar
Danel Rod committed
}

apply from: rootProject.file('gradle/install-git-hooks.gradle')

allprojects {
    group = project.group
    version = project.version + "-" + getCheckedOutGitCommitHash()
Danel Rod's avatar
Danel Rod committed
}

DanelRod's avatar
DanelRod committed
repositories {
    mavenCentral()
    mavenLocal()
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }

    repositories {
        maven {
            name = "GitHubPackages"
            url = "https://maven.pkg.github.com/EFA-FHB/eforms-validator-core"
            credentials {
                username = System.getenv("GITHUB_ACTOR")
                password = System.getenv("GITHUB_TOKEN")
            }
        }
    }
}

dependencies {
    // Quarkus
    implementation(platform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))
    implementation 'io.quarkus:quarkus-arc'
    implementation 'io.quarkus:quarkus-resteasy'
    implementation 'io.quarkus:quarkus-hibernate-validator'
    implementation 'io.quarkus:quarkus-resteasy-multipart'
    // Utils
    implementation 'commons-io:commons-io:2.11.0'
    implementation 'org.apache.commons:commons-lang3:3.12.0'

    implementation 'org.projectlombok:lombok:1.18.22'
Danel Rod's avatar
Danel Rod committed

    implementation 'com.jcabi:jcabi-xml:0.21.3'
    implementation 'com.helger.schematron:ph-schematron-pure:6.3.3'
    implementation 'com.github.vladimir-bukhtoyarov:bucket4j-core:7.6.0'
Danel Rod's avatar
Danel Rod committed

    implementation files('libs/kosit-validator-patched.jar')
Danel Rod's avatar
Danel Rod committed

    compileOnly 'org.projectlombok:lombok:1.18.22'
Danel Rod's avatar
Danel Rod committed

    annotationProcessor 'org.projectlombok:lombok:1.18.22'

    testImplementation 'io.quarkus:quarkus-junit5'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'

    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}

compileJava {
    options.encoding = 'UTF-8'
    options.compilerArgs << '-parameters'
}
Danel Rod's avatar
Danel Rod committed

test {
    systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager"
    reports.html.required = false
    minHeapSize = "1024m" // initial heap size
    maxHeapSize = "7168m" // maximum heap size
}

compileTestJava {
    options.encoding = 'UTF-8'
}

tasks.register('buildInfo') {
    doLast {
        def commitId = System.getenv('GIT_SHA_REF') ?: grgit.head().getId()

        new File(sourceSets.main.output.resourcesDir, "build_info.json").text =
                """{
Danel Rod's avatar
Danel Rod committed
    "name" : "${rootProject.name}-${project.name}",
    "build" : {
        "version" : "${project.version}",
        "time" : "${LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS)}",
        "git" : {
            "sha" : "${commitId}",
            "repository_url" : "${grgit.remote.list().get(0).url}"
        }
    }
}
"""
    }
}

def getCheckedOutGitCommitHash() {
    grgit.head().abbreviatedId
}

sonarqube {
    String sonarHostUrl = System.getenv("SONAR_HOST_URL") ?: property("sonarHostUrl")
    String sonarLogin = System.getenv("SONAR_TOKEN") ?: property("sonarLogin")
    String sonarPassword = System.getenv("SONAR_TOKEN") ? "" : property("sonarPassword")
    properties {
        property 'sonar.host.url', sonarHostUrl
        property 'sonar.login', sonarLogin
        property 'sonar.password', sonarPassword
        property "sonar.projectKey", "EFA-FHB_eforms-validator-core"
        property "sonar.projectName", "eforms-validator-core"
        property "sonar.organization", "efa-fhb"
        property 'sonar.inclusions',  "**/efafhb/**"
    }
}

test.finalizedBy jacocoTestReport

jacocoTestReport {

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

    getExecutionData().setFrom(fileTree(buildDir).include("jacoco/*.exec"))

    afterEvaluate {
        classDirectories.setFrom(files(classDirectories.files.collect {
            fileTree(dir: it, exclude: ["**/build/generated/*"])
        }))
    }
    dependsOn processResources, quarkusGenerateCode, compileJava
}

tasks.named('sonarqube').configure {
    dependsOn jacocoTestReport
}

spotless {
    ratchetFrom 'origin/main'
    java {
        importOrder()
        removeUnusedImports()
        googleJavaFormat()
    }
}
tasks.named('compileJava').configure {
    dependsOn buildInfo
}
Danel Rod's avatar
Danel Rod committed