Skip to content

Commit dd1b2d8

Browse files
committed
feat: add .env support for the examples
1 parent fd779d9 commit dd1b2d8

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

examples/examples.gradle.kts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,30 @@ sourceSets {
2525
}
2626
}
2727

28+
fun loadEnv(): Map<String, String> {
29+
val envFile = rootProject.file(".env")
30+
val envMap = mutableMapOf<String, String>()
31+
32+
if (envFile.exists()) {
33+
envFile.forEachLine { line ->
34+
val trimmedLine = line.trim()
35+
if (trimmedLine.isNotEmpty() && !trimmedLine.startsWith("#") && trimmedLine.contains("=")) {
36+
val (key, value) = trimmedLine.split("=", limit = 2)
37+
envMap[key.trim()] = value.trim()
38+
}
39+
}
40+
}
41+
return envMap
42+
}
43+
2844
tasks.register<JavaExec>("runFunctionalTests") {
2945
group = "execute"
3046
description = "Run the Functional Tests"
3147
mainClass = "com.fingerprint.example.FunctionalTests"
3248
classpath = sourceSets["main"].runtimeClasspath
49+
environment(loadEnv())
3350
}
3451

3552
tasks.named("runFunctionalTests") {
3653
dependsOn("build")
37-
}
54+
}

0 commit comments

Comments
 (0)