Skip to content

Commit bccb17a

Browse files
jakub-senohrabek-jbjakub-senohrabek
andauthored
Allow setting skiko properties using skiko.properties file inside jar (#994)
In order to use two different versions of skiko in one app (using multiple classloaders), it is required to use the unpacking strategy, as the skiko.library.path is a system property, which is same for all classloaders. This change will allow to use presigned natives shipped together with the app, while still being able to use multiple versions as the property skiko.library.path will be loaded from current classloader resources, with fallback to system property. Co-authored-by: Jakub Senohrabek <[email protected]>
1 parent dbc6bdb commit bccb17a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkikoProperties.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.jetbrains.skiko
22

3-
import java.lang.System.getProperty
3+
import java.util.*
44

55
// TODO maybe we can get rid of global properties, and pass SkiaLayerProperties to Window -> ComposeWindow -> SkiaLayer
66
@Suppress("SameParameterValue")
@@ -89,6 +89,19 @@ object SkikoProperties {
8989

9090
val macOsOpenGLEnabled: Boolean get() = getProperty("skiko.macos.opengl.enabled")?.toBoolean() ?: false
9191

92+
private val properties = run {
93+
val resourcePropertiesEnabled = System.getProperty("skiko.resource.properties.enabled")?.toBoolean() ?: false
94+
val resources = if (resourcePropertiesEnabled) {
95+
SkikoProperties::class.java.classLoader.getResourceAsStream("skiko.properties")
96+
} else {
97+
null
98+
}
99+
val systemProps = System.getProperties()
100+
if (resources == null) systemProps else Properties(systemProps).apply { load(resources) }
101+
}
102+
103+
private fun getProperty(key: String): String? = properties.getProperty(key)
104+
92105
internal fun parseRenderApi(text: String?): GraphicsApi {
93106
when(text) {
94107
"SOFTWARE_COMPAT" -> return GraphicsApi.SOFTWARE_COMPAT

0 commit comments

Comments
 (0)