Is there a way to set a list of allowed command line property names (-P) for a project to prevent a typo in a property causing confusion?

I could iterate through all the project.ext.properties and check the keys against an “allowed” list, but this would have to include all the ext properties that might be set in the project, which would be cumbersome to maintain. Seems like it would not be hard to implement and it has a similar reason for existence to the ext object, but I could not find a way to do this simply.

You could probably iterate over the project properties which are accessible through the start parameters of the Gradle invocation.

gradle.startParameter.projectProperties.each { key, value ->
    // validate
}
1 Like