api / org.gradle.api.plugins / ExtraPropertiesExtension / get

get

abstract fun get(name: String): Any

Returns the value for the registered property with the given name. When using an extra properties extension from Groovy, you can also get properties via Groovy's property syntax. All of the following lines of code are equivalent.

 project.ext { foo = "bar" } assert project.ext.get("foo") == "bar" assert project.ext.foo == "bar" assert project.ext["foo"] == "bar" assert project.foo == "bar" assert project["foo"] == "bar" 
When using the first form, an UnknownPropertyException exception will be thrown if the extension does not have a property called “foo”. When using the second forms (i.e. Groovy notation), Groovy's groovy.lang.MissingPropertyException will be thrown instead.

Parameters

name - The name of the property to get the value of

Exceptions

UnknownPropertyException - if there is no property registered with the given name

Return
The value for the property with the given name.