Instantly share code, notes, and snippets.

Embed
What would you like to do?

Gradle Notes

Links About the Gralde's task keyword

  1. TaskDefinitionScriptTransformer.java
  2. BuildScriptTransformer.java
  3. DefaultScriptPluginFactory.java#L117

--

  1. DefaultScriptCompilationHandler.java
  2. AbstractScriptTransformer.java

--

[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) {
}

https://github.com/gradle/gradle/blob/master/subprojects/core/src/main/groovy/org/gradle/api/internal/tasks/DefaultTaskContainer.java#L84

當這麼寫的時候,TaskContainer 會把 task 建成 SomeType 的 Task,而非 DefaultTask。這就叫 enhanced task !?

Convention vs Extension

http://forums.gradle.org/gradle/topics/whats_the_difference_between_plugin_conventions_vs_plugin_extensions

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment