Newer
Older
import java.time.LocalDateTime
import java.time.temporal.ChronoUnit
plugins {
id 'java'
id 'jacoco'
id "com.diffplug.spotless" version "6.20.0"
id "com.github.vlsi.jandex" version "1.90"
id 'com.github.johnrengelman.shadow' version '7.1.2'
}
apply from: rootProject.file('gradle/install-git-hooks.gradle')
allprojects {
version = project.version + "-" + getCheckedOutGitCommitHash()
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-resteasy-jackson'
implementation 'io.quarkus:quarkus-hibernate-validator'
implementation 'io.quarkus:quarkus-resteasy-multipart'
implementation 'io.quarkus:quarkus-smallrye-openapi'
// Utils
implementation 'commons-io:commons-io:2.11.0'
implementation 'org.apache.commons:commons-lang3:3.13.0'
implementation 'org.projectlombok:lombok:1.18.22'
implementation 'com.jcabi:jcabi-xml:0.29.0'
implementation 'com.helger.schematron:ph-schematron-pure:6.3.4'
implementation 'com.github.vladimir-bukhtoyarov:bucket4j-core:7.6.0'
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.15.2'
implementation('org.yaml:snakeyaml:2.0') {
because 'version 1.33 is vulnerable to CVE-2022-1471'
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << '-parameters'
}
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 =
"""{
"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}"
}
}
}
"""
}
}
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"
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
}
}
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
}
shadowJar {
archiveClassifier.set('fat')
configurations = [project.configurations.runtimeClasspath]
}