forked from CodelyTV/kotlin-api-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
180 lines (148 loc) · 5.55 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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
175
176
177
178
179
180
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.9.24"
id("com.diffplug.spotless") version "6.18.0"
id("com.google.cloud.tools.jib") version "3.4.3"
id("org.springframework.boot") version "3.1.5"
id("io.spring.dependency-management") version "1.0.12.RELEASE"
id("idea")
kotlin("plugin.spring") version "1.9.0"
id("java-test-fixtures")
application
jacoco
}
group = "com.codely"
version = "0.0.1"
java.sourceCompatibility = JavaVersion.VERSION_21
repositories {
mavenCentral()
}
sourceSets {
create("test-integration") {
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
}
}
val testIntegrationImplementation: Configuration by configurations.getting {
extendsFrom(configurations.testImplementation.get())
}
configurations["testIntegrationRuntimeOnly"].extendsFrom(configurations.testRuntimeOnly.get())
val integrationTest = task<Test>("integrationTest") {
description = "Runs integration tests."
group = "verification"
testClassesDirs = sourceSets["test-integration"].output.classesDirs
classpath = sourceSets["test-integration"].runtimeClasspath
useJUnitPlatform()
shouldRunAfter("test")
}
tasks.withType<Test> {
testLogging {
showStandardStreams = false
events("skipped", "failed")
showExceptions = true
showCauses = true
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
afterSuite(printTestResult)
}
useJUnitPlatform()
}
val printTestResult: KotlinClosure2<TestDescriptor, TestResult, Void>
get() = KotlinClosure2({ desc, result ->
if (desc.parent == null) { // will match the outermost suite
println("------")
println(
"Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} " +
"successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
)
println(
"Tests took: ${result.endTime - result.startTime} ms."
)
println("------")
}
null
})
jacoco {
toolVersion = "0.8.7"
}
tasks.jacocoTestReport {
reports {
xml.required.set(true)
html.required.set(true)
}
dependsOn(tasks.test)
}
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("io.github.microutils:kotlin-logging:1.7.8")
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.9.0")
// Reactive spring boot
implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
// Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactive")
// KotlinX
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
// Password Encryption
implementation("org.mindrot:jbcrypt:0.4")
// Functional Programming
implementation("io.arrow-kt:arrow-core:1.2.0")
implementation("io.arrow-kt:arrow-fx-coroutines:1.1.2")
// PDF to TEXT
implementation("org.apache.pdfbox:pdfbox:2.0.7")
// Testing
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.boot:spring-boot-test:2.7.2")
testImplementation("io.kotest:kotest-runner-junit5:5.7.0")
testImplementation("io.kotest:kotest-assertions-core:5.7.0")
testImplementation("io.kotest:kotest-property:5.7.0")
testImplementation("io.kotest.extensions:kotest-assertions-arrow:1.3.0") {
because("provides good testing for arrow")
}
testImplementation("in.rcard:assertj-arrow-core:0.2.0")
// Coroutines
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")
// test fixtures dependencies
testFixturesImplementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf(
"-Xjsr305=strict",
"-Xcontext-receivers",
"-Xms256m",
"-Xmx256m",
"-Xss256k",
"-XX:MaxMetaspaceSize=128m",
"-XX:+UseG1GC", // Default GC: G1GC
"-XX:MaxGCPauseMillis=200", // Reduce pause times during GC
"-XX:+ExplicitGCInvokesConcurrent", // Enable concurrent explicit GC
"-XX:MaxRAMPercentage=50.0", // Limit JVM heap to 50% of available memory
"-XX:+UseContainerSupport", // Enable container awareness
"-XX:InitialRAMPercentage=25.0", // Start with 25% of available memory
"-XX:MaxMetaspaceSize=128m" // Limit metaspace memory usage
)
jvmTarget = "21"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
spotless {
kotlin {
ktlint().setEditorConfigPath("$rootDir/.editorconfig")
}
kotlinGradle {
ktlint().setEditorConfigPath("$rootDir/.editorconfig")
}
}
tasks.check {
dependsOn(integrationTest)
dependsOn(tasks.spotlessCheck)
}