@@ -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
910group = " com.dragos"
@@ -60,6 +61,20 @@ tasks.withType<KotlinCompile> {
6061
6162tasks.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