You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if there could be a convenient replacement for Project.findProperty(String) that is compatible with project isolation by not checking parent projects and still returns null if the property is not found.
Maybe this could be one method that checks all of the same places as findProperty() (project properties, extensions, conventions, extra properties, tasks) or maybe it could be a separate method for each individual place like ExtraPropertiesExtension.getOrNull()
If that already exists and I just wasn't able to find it, it could be nice to link to it from the documentation of findProperty()
Current Behavior (optional)
No response
Context
AndroidX is addressing more project isolation violations.
It feels a little bit verbose to replace things that look like project.findProperty(STUDIO_TYPE) with things that look like if (project.hasProperty(STUDIO_TYPE)) project.property(STUDIO_TYPE) else null
I tried project.providers.gradleProperty(STUDIO_TYPE).getOrNull() but that returns null because the property was set via project.extensions.extraProperties and I don't seem to be able to do project.extensions.extraProperties.getOrNull(String) either.
Thanks!
The text was updated successfully, but these errors were encountered:
Also related is #23572 where it can be a little bit tricky to determine an appropriate replacement for findProperty since providers.gradleProperty() (which was what I expected to be the best replacement) doesn't check all of the places I'd expected
Also potentially relevant, what we ended up going with for now was making our own function extraPropertyOrNull:
fun Project.extraPropertyOrNull(key: String): Any? {
val container = project.extensions.extraProperties
var result: Any? = null
if (container.has(key))
result = container.get(key)
return result
}
Expected Behavior
It would be nice if there could be a convenient replacement for
Project.findProperty(String)
that is compatible with project isolation by not checking parent projects and still returnsnull
if the property is not found.Maybe this could be one method that checks all of the same places as
findProperty()
(project properties, extensions, conventions, extra properties, tasks) or maybe it could be a separate method for each individual place likeExtraPropertiesExtension.getOrNull()
If that already exists and I just wasn't able to find it, it could be nice to link to it from the documentation of
findProperty()
Current Behavior (optional)
No response
Context
AndroidX is addressing more project isolation violations.
It feels a little bit verbose to replace things that look like
project.findProperty(STUDIO_TYPE)
with things that look likeif (project.hasProperty(STUDIO_TYPE)) project.property(STUDIO_TYPE) else null
I tried
project.providers.gradleProperty(STUDIO_TYPE).getOrNull()
but that returns null because the property was set viaproject.extensions.extraProperties
and I don't seem to be able to doproject.extensions.extraProperties.getOrNull(String)
either.Thanks!
The text was updated successfully, but these errors were encountered: