Skip to content

Commit 755b5fc

Browse files
authored
Load system properties (#6)
1 parent aa1155c commit 755b5fc

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

chat-server/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.kotlin
33
.gradle
44
.ollama
5-
build
5+
build
6+
system.properties

chat-server/build.gradle.kts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
22
import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
33
import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED
4+
import java.util.Properties
45

56
plugins {
67
val kotlinVersion = "2.1.20"
@@ -73,4 +74,22 @@ tasks.withType<Test> {
7374
testLogging {
7475
events(PASSED, SKIPPED, FAILED)
7576
}
77+
setSystemProperties { systemProperty(it.first, it.second) }
78+
}
79+
80+
tasks.withType<JavaExec> {
81+
setSystemProperties { systemProperty(it.first, it.second) }
82+
}
83+
84+
private fun setSystemProperties(setSystemProperty: (Pair<String, Any>) -> Unit) {
85+
val systemPropertiesFile = project.rootProject.file("system.properties")
86+
if (systemPropertiesFile.exists()) {
87+
systemPropertiesFile.inputStream().use { inputStream ->
88+
Properties().apply {
89+
load(inputStream)
90+
}.forEach {
91+
setSystemProperty(it.key.toString() to it.value)
92+
}
93+
}
94+
}
7695
}

0 commit comments

Comments
 (0)