Difference between task rule and rule

From the book Gradle beyond the basics, I find it hard to follow the terminology being used. On page 44, there is a mention of “task rule” and also of “rule”, what’s the differrence. My intuition tells me that the “task rule” is the result of having a rule… but I am not sure. Can someone help me understand please?

Also: Page 43, Example 3-7, shows a call to tasks.addRule(…), which is later referenced as “this class is already getting a little too long”, why say “this class”?

I think I understand… A Rule can be used to created different things, one of these could be a task. So a Task Rule is a task created from a Rule.

To clarify, “this class” is the Closure that’s being passed to [addRule()](http://gradle.org/docs/current/javadoc/org/gradle/api/NamedDomainObjectCollection.html#addRule(java.lang.String, groovy.lang.Closure)).

You’re on the right track. A rule is some code that runs when Gradle can’t find a given name in a NamedDomainObjectCollection. So a “task rule” is just a specialized Rule that runs when a Task cannot be found in the TaskContainer. The task rule can create tasks.