There are so many things in Gradle that depend on how you do them (e.g. how you create a task). If you do it through Groovy, there's plenty of magic going on which results in behaviour that is different from what you get by using the API through Java