-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
95 lines (79 loc) · 3.65 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
val group: String by project
val version: String by project
java.sourceCompatibility = JavaVersion.VERSION_21
val dockerRegistry = "goafabric"
val nativeBuilder = "paketobuildpacks/java-native-image:9.5.0"
val baseImage = "ibm-semeru-runtimes:open-21.0.3_9-jre-focal@sha256:5cb19afa9ee0daeecb7c31be8253fecbbf6b5f6dcfb06883c41f045cb893bcec"
plugins {
java
jacoco
id("org.springframework.boot") version "3.3.3"
id("io.spring.dependency-management") version "1.1.6"
id("org.graalvm.buildtools.native") version "0.10.2"
id("com.google.cloud.tools.jib") version "3.4.3"
id("net.researchgate.release") version "3.0.2"
id("org.sonarqube") version "5.0.0.4638"
id("org.cyclonedx.bom") version "1.8.2"
}
repositories {
mavenCentral()
maven { url = uri("https://repo.spring.io/milestone") }
maven { url = uri("https://repo.spring.io/snapshot") }
}
dependencies {
constraints {
annotationProcessor("org.mapstruct:mapstruct-processor:1.5.5.Final")
implementation("org.mapstruct:mapstruct:1.5.5.Final")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0")
implementation("io.github.resilience4j:resilience4j-spring-boot3:2.1.0")
implementation("net.ttddyy.observation:datasource-micrometer-spring-boot:1.0.3")
testImplementation("com.tngtech.archunit:archunit-junit5:1.2.1")
}
}
dependencies {
//web
implementation("org.springframework.boot:spring-boot-starter-web")
//security
implementation("org.springframework.boot:spring-boot-starter-security")
//monitoring
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("io.micrometer:micrometer-registry-prometheus")
implementation("io.micrometer:micrometer-tracing-bridge-otel")
implementation("io.opentelemetry:opentelemetry-exporter-otlp")
//openapi
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui")
//test
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.github.resilience4j:resilience4j-spring-boot3")
testImplementation("com.tngtech.archunit:archunit-junit5")
}
tasks.withType<Test> {
useJUnitPlatform()
exclude("**/*NRIT*")
finalizedBy("jacocoTestReport")
}
tasks.jacocoTestReport { reports {csv.required.set(true); xml.required.set(true) } }
jib {
val amd64 = com.google.cloud.tools.jib.gradle.PlatformParameters(); amd64.os = "linux"; amd64.architecture = "amd64"; val arm64 = com.google.cloud.tools.jib.gradle.PlatformParameters(); arm64.os = "linux"; arm64.architecture = "arm64"
from.image = baseImage
to.image = "${dockerRegistry}/${project.name}:${project.version}"
container.jvmFlags = listOf("-Xms256m", "-Xmx256m")
from.platforms.set(listOf(amd64, arm64))
}
tasks.register("dockerImageNative") { description= "Native Image"; group = "build"; dependsOn("bootBuildImage") }
tasks.named<BootBuildImage>("bootBuildImage") {
val nativeImageName = "${dockerRegistry}/${project.name}-native" + (if (System.getProperty("os.arch").equals("aarch64")) "-arm64v8" else "") + ":${project.version}"
builder.set("paketobuildpacks/builder-jammy-buildpackless-tiny")
buildpacks.add(nativeBuilder)
imageName.set(nativeImageName)
environment.set(mapOf("BP_NATIVE_IMAGE" to "true", "BP_JVM_VERSION" to "21", "BP_NATIVE_IMAGE_BUILD_ARGUMENTS" to "-J-Xmx5000m -march=compatibility"))
doLast {
exec { commandLine("/bin/sh", "-c", "docker run --rm $nativeImageName -check-integrity") }
exec { commandLine("/bin/sh", "-c", "docker push $nativeImageName") }
}
}
configure<net.researchgate.release.ReleaseExtension> {
buildTasks.set(listOf("build", "test", "jib", "dockerImageNative"))
tagTemplate.set("v${version}".replace("-SNAPSHOT", ""))
}