Is it possible to use project.setPropertiy for a property, which is not declared in

Hello everyone, i migrated ftom gradle 1.8 to 2.3 and now had a problem. I had in project different property files, which i loaded in gradle in runtime by using:

props.each { String name, value ->
  project.setProperty(name, value)

Now i have a error: No such property: prop_name for class: org.gradle.api.internal.project.DefaultProject_Decorated

Do i have to create now huge gradle.propertiy with null values of all possible properties to prevent this error or there is a better solution?

Best regards, ILIA

This has to do with something that changed with Gradle 2.0. We no longer allow the creation of new properties on Project.

If you want to still do this, you have to use the extension container:

props.each { String name, value ->
        project.ext.setProperty(name, value)

It should look basically the same to users (project.someProp still works, you don’t have to go through project.ext).

If you find yourself setting lots of properties, it might make sense to package your properties into an extension object vs dumping them all in the project namespace.


Just to clarify, ‘project.ext’ refers to the ‘extraProperties’ extension, not the extension container itself. This is a special extension that is added to any domain objects that are ‘ExtensionAware’: