- TaskDefinitionScriptTransformer.java
- BuildScriptTransformer.java
- DefaultScriptPluginFactory.java#L117
--
--
[groovy CompilationUnit](http://groovy.codehaus.org/api/org/codehaus/groovy/control/CompilationUnit.html#addPhaseOperation\(org.codehaus.groovy.control.CompilationUnit.SourceUnitOperation, int))
--
task foo(type:SomeType) {
}
當這麼寫的時候,TaskContainer 會把 task 建成 SomeType 的 Task,而非 DefaultTask。這就叫 enhanced task !?
Extensions and conventions are similar (but not identical) ways to dynamically extend the build model. Extensions are the newer concept and have largely replaced conventions. In short, only use extensions, don't use conventions.
http://forums.gradle.org/gradle/topics/is_the_new_plugin_extension_approach_the_way_to_go
You should prefer the extension mechanism over the convention object mechanism. We will migrate the built-in plugins over time and new plugins will use the extension mechanism. The announce, ide, and c++ plugins all use extensions rather than convention objects.
However, the convention object mechanism is not going away any time soon. We will probably offer some migration mechanism, so that you can use both, and Gradle will warn the plugin users that they should use the new syntax for accessing the properties, rather than the new syntax.