Skip to content

Commit dc4e258

Browse files
committed
code formatter
1 parent 60b7173 commit dc4e258

File tree

2 files changed

+63
-15
lines changed

2 files changed

+63
-15
lines changed

.editorconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
max_line_length = 120
10+
tab_width = 4
11+
trim_trailing_whitespace = true
12+
13+
[*.{kt,kts}]
14+
max_line_length = 140
15+
indent_size = 4
16+
continuation_indent_size = 4
17+
18+
[*.md]
19+
max_line_length = off
20+
trim_trailing_whitespace = false
21+
22+
[*.{yml,yaml}]
23+
indent_size = 2

build.gradle.kts

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
kotlin("jvm") version "1.9.22"
55
application
66
id("com.github.davidmc24.gradle.plugin.avro") version "1.9.1"
7+
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
78
}
89

910
group = "com.dragos"
@@ -60,6 +61,20 @@ tasks.withType<KotlinCompile> {
6061

6162
tasks.withType<Test> {
6263
useJUnitPlatform()
64+
65+
// Set Docker socket for Testcontainers when using Colima
66+
val dockerSocket = "${System.getProperty("user.home")}/.colima/default/docker.sock"
67+
environment("DOCKER_HOST", "unix://$dockerSocket")
68+
environment("TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE", dockerSocket)
69+
70+
// IMPORTANT: Disable Ryuk for Colima compatibility
71+
environment("TESTCONTAINERS_RYUK_DISABLED", "true")
72+
73+
testLogging {
74+
events("passed", "skipped", "failed")
75+
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
76+
showStandardStreams = true
77+
}
6378
}
6479

6580
// Fat JAR configuration
@@ -78,20 +93,30 @@ avro {
7893
fieldVisibility.set("PRIVATE")
7994
}
8095

81-
tasks.withType<Test> {
82-
useJUnitPlatform()
83-
84-
// Set Docker socket for Testcontainers when using Colima
85-
val dockerSocket = "${System.getProperty("user.home")}/.colima/default/docker.sock"
86-
environment("DOCKER_HOST", "unix://$dockerSocket")
87-
environment("TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE", dockerSocket)
96+
// ktlint configuration
97+
ktlint {
98+
version.set("1.0.1")
99+
verbose.set(true)
100+
android.set(false)
101+
outputToConsole.set(true)
102+
ignoreFailures.set(false)
88103

89-
// IMPORTANT: Disable Ryuk for Colima compatibility
90-
environment("TESTCONTAINERS_RYUK_DISABLED", "true")
91-
92-
testLogging {
93-
events("passed", "skipped", "failed")
94-
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
95-
showStandardStreams = true
104+
filter {
105+
exclude("**/generated/**")
106+
include("**/kotlin/**")
96107
}
97-
}
108+
}
109+
110+
// Make build depend on ktlint checks
111+
tasks.named("check") {
112+
dependsOn("ktlintCheck")
113+
}
114+
115+
// Auto-format code before compiling
116+
tasks.named("compileKotlin") {
117+
dependsOn("ktlintFormat")
118+
}
119+
120+
tasks.named("compileTestKotlin") {
121+
dependsOn("ktlintFormat")
122+
}

0 commit comments

Comments
 (0)