I can do it this reasonably terrible way, of cours...
# gradle
a
I can do it this reasonably terrible way, of course, by insert this into
settings.gradle.kts
Copy code
operator fun Settings.get(key: String): String {
            return javaClass.getMethod("getProperty", String::class.java).invoke(this, key) as String
        }
and then referring to
settings["property"]
for example
c
in build.gradle.kts declare
val yourPropertyName by project
or you can access it without declaring if you want using
project.findProperty("yourPropertyName")
Note, that it will be of type
Any?
and the only way to make it of some specific type is casting it, at least until this feature is implemented: https://github.com/gradle/kotlin-dsl/issues/626
a
I was asking specifically about in
settings.gradle.kts
, which is run before any of the build files - I didn't find a delegate to use there
c
in settings.gradle.kts you have to access startParameter.projectProperties for that.
Copy code
val yourParamName by startParameter.projectProperties
//or
startParameter.projectProperties["yourParamName"]
a
ah-ha, thank you. Although this differs a bit from the dynamic properties of Settings which are merged from
gradle.properties
too -- it turns out, that's what I need to do here as well
c
Yeah, all this is because there are no and there can't be dynamic properties in Kotlin.