diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..b678d52 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,127 @@ +import org.springframework.boot.gradle.tasks.bundling.BootBuildImage + +plugins { + java + id("org.springframework.boot") version "3.1.2" + id("io.spring.dependency-management") version "1.1.2" + id("org.sonarqube") version "4.3.0.3225" + pmd + checkstyle + jacoco +} + +group = "com.knecon.fforesight" +java.sourceCompatibility = JavaVersion.VERSION_17 + +configurations { + compileOnly { + extendsFrom(configurations.annotationProcessor.get()) + } +} + +tasks.pmdMain{ + pmd.ruleSetFiles = files("${projectDir}/config/pmd/pmd.xml") +} + +tasks.pmdTest { + pmd.ruleSetFiles = files("${projectDir}/config/pmd/test_pmd.xml") +} + +tasks.jacocoTestReport { + reports { + xml.required.set(false) + csv.required.set(false) + html.outputLocation.set(layout.buildDirectory.dir("jacocoHtml")) + } + } + +repositories { + mavenLocal() + mavenCentral() + maven { + url = uri("https://nexus.knecon.com/repository/gindev/"); + credentials { + username = providers.gradleProperty("mavenUser").getOrNull(); + password = providers.gradleProperty("mavenPassword").getOrNull(); + } + } +} + +tasks.named("bootBuildImage") { + imageName.set("nexus.knecon.com:5001/ff/${project.name}:${project.version}") + if (project.hasProperty("buildbootDockerHostNetwork")) { + network.set("host") + } + docker { + if (project.hasProperty("buildbootDockerHostNetwork")) { + bindHostToBuilder.set(true) + } + verboseLogging.set(true) + + publishRegistry { + username.set(providers.gradleProperty("mavenUser").getOrNull()) + password.set(providers.gradleProperty("mavenPassword").getOrNull()) + email.set(providers.gradleProperty("mavenEmail").getOrNull()) + url.set("https://nexus.knecon.com:5001/") + } + } +} + +extra["springCloudVersion"] = "2022.0.4" +extra["testcontainersVersion"] = "1.18.3" + +dependencies { + implementation("jakarta.json:jakarta.json-api:2.1.2") + implementation("co.elastic.clients:elasticsearch-java:8.6.2") + implementation("org.springframework.boot:spring-boot-starter-actuator") + implementation("org.springframework.boot:spring-boot-starter-amqp") + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.cloud:spring-cloud-starter-openfeign") + implementation("com.iqser.red.commons:storage-commons:2.15.0") + implementation("com.knecon.fforesight:keycloak-commons:0.18.0") + implementation("com.knecon.fforesight:swagger-commons:0.5.0") + compileOnly("org.projectlombok:lombok") + developmentOnly("org.springframework.boot:spring-boot-devtools") + annotationProcessor("org.springframework.boot:spring-boot-configuration-processor") + annotationProcessor("org.projectlombok:lombok") + testImplementation("org.springframework.boot:spring-boot-starter-test") + testImplementation("org.springframework.amqp:spring-rabbit-test") + testImplementation("org.testcontainers:elasticsearch:1.18.3") + testAnnotationProcessor("org.projectlombok:lombok") + + +} + + + +dependencyManagement { + imports { + mavenBom("org.testcontainers:testcontainers-bom:${property("testcontainersVersion")}") + mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}") + } +} + +tasks.withType { + useJUnitPlatform() + reports { + junitXml.outputLocation.set(layout.buildDirectory.dir("reports/junit")) + } +} + +sonarqube { + properties { + providers.gradleProperty("sonarToken").getOrNull()?.let { property("sonar.login", it) } + property("sonar.host.url", "https://sonarqube.knecon.com") + } +} + +tasks.test { + finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run +} +tasks.jacocoTestReport { + dependsOn(tasks.test) // tests are required to run before generating the report + reports { + xml.required.set(true) + csv.required.set(false) + } +}