Open yshrsmz opened 3 years ago
@yshrsmz do you have a plan to add multiplatform support for secrets-gradle-plugin
?
@PhilipDukhov I think I'm not going to "support" secrets-gradle-plugin, as it looks like an Android-specific plugin, but borrow some idea/implementation from it.
Do you have any idea or suggestion?
Ah I see. I think it could be done using same techniques moko-resources uses under the hood.
Thanks, will take a look!
In case it helps anyone I'm using BuildKonfig happily in conjunction with the SnakeYAML library, within Gradle (Kotlin DSL), like so:
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type
import org.yaml.snakeyaml.Yaml
...
buildkonfig {
packageName = "mypackage"
objectName = "MyConfig"
val configFilename: String = projectDir.toString() + File.separator + "MyConfig.yml"
val appConfigYaml: String = File(configFilename).readText()
val appConfigMap: Map<String, Any?> = Yaml().load(appConfigYaml)
defaultConfigs {
appConfigMap.forEach { (key, value) ->
val (fieldType: Type, fieldContent: String) = when (value) {
is Boolean -> Type.BOOLEAN to value.toString()
is String -> Type.STRING to value
is List<*> -> Type.STRING to value.joinToString(",") { it.toString() }
else -> Type.STRING to (value?.toString() ?: "")
}
buildConfigField(
type = fieldType,
name = key,
value = fieldContent
)
}
}
}
It seems like properties file is not suitable for BuildKonfig, as it's just a key-value map
Something like yaml or toml should be fine
Not sure the DSL below is possible, but something like this