How to write Gradle Plugins with Groovy for Android

Since Android Studio being released, I could always find that Google announce that Gradle is better than Maven and Ant. Especially it supports Groovy as script language natively. However I could not get chance to try it. Recently our project requires us to implement CI and something else. So I got chance to learn it more. Firstly I need to know how to create a customised Gradle Task using Groovy. I tried building some simple "Hello world " tasks inside of build.gradle file. They all work fine. But once I tried to implement some more complicated ones which needs importing some other libraries, it will complain can not import. So I recheck the doc from Gradle. There is another way to create a standalone plugin library. http://www.gradle.org/docs/current/userguide/custom_tasks.html So I followed the doc to create mine one. 1. Create Gradle project using Intellij 2. Add framework support -> Groovy 3. Create the source structure like this. 4. Change the bui...