AdamSkywalker
AdamSkywalker

Reputation: 11619

Add properties to project in Gradle plugin

I'm trying to add some properties to a project, which is configured with custom plugin.

class MyPlugin implements Plugin<Project> {
    @Override
    void apply(Project project) {
        project.properties.put("my_property", "123)
        println(project.properties.get("my_property"))
    }
}

I see null in output. What I am missing here?

Upvotes: 3

Views: 6814

Answers (1)

Opal
Opal

Reputation: 84854

Here's how extra properties should be set:

class MyPlugin implements Plugin<Project> {
    @Override
    void apply(Project project) {
        project.ext.my_property = 123
        println(project.my_property)
    }
}

And here You can find the whole section on how properties work with gradle.

Upvotes: 5

Related Questions