Syntax understanding of ext {}

In build.gradle, some statements correspond to the method of a domain.
For example,
version = 0.01 corresponds to project.setVersion(0.01)

corresponds to closure delegation to project’s DependencyHandler

But what does “ext{ property = value}” correspond to?
and how about the question below?
sourceSets{ corresponds to closure deletation to SourceSetContainer
main{ corresponds to what?
java{ corresponds to closure delegation to SourceDirectorySet

I am quite new to Gradle, and maybe the quesiton is quite simple for some experts.

I’m not sure it’s allowed here, but I’ve written a blog post about properties in Gradle, where they come from and how they’re accessed/resolved –

As for your other question – what do main and java correspond to, these come from an object container. I happen to have written about reading Gradle scripts in general as well –

I think these two posts will clear a lot of your confusion (you may want to start with the second one). I’ll happily answer any questions you might have (if I can)

1 Like