<@U4TTC4LGM> use a nullable type when querying for...
# gradle
e
@nikolaymetchev use a nullable type when querying for the property:
val answer: String? by project
n
@eskatos That's what I am trying to avoid. I want to specify a default value for when the property isn't in the properties file
e
There’s no builtin construct for this on Gradle properties using Kotlin property delegates. In a project script you can use the
Project
api as follows:
Copy code
buildscript {
    dependencies {
        val junitGradlePlugin = findProperty("junitGradlePlugin") as String? ?: "defaultValue"
        classpath(junitGradlePlugin)
    }
}
But there’s no such equivalent in settings scripts, the api is missing from the Java Gradle API. If you feel strongly about it, feel free to open an issue on
gradle/gradle
for the missing API.
n
@eskatos Thanks. Your snippet will do for now.