Gradle/Groovy Custom plugin

I am new to Plugin development and Gradle.How do I include depends on option in Custom Plugin.
def localBuild(){
println" Local build started…"
copy {
println “configurations.runtime”+configurations.runtime

		from configurations.runtime
		into project.projectDir.toString() + "/src/main/webapp/WEB-INF/lib"


I suggest you start by reading, then maybe get copy of Idiomatic Gradle Vol 1. You can also clone this plugin workshop repo and then work through the exercises.

Now as to some detail of what you asked above:

  • @TaskAction defines the primary action to be invoked by the task. You cannot put any configuration items in there.
  • doLast is a way of adding more actions, put usually that code itself should be inside the primary task action. Idiomatically doLast and doFirst are reserved for build script authors to customise the behaviour of an existing task.
class MyTask extends DefaultTask {
    void localBuild() {
        println 'Local build started...'
        project.copy {
            // ... copy code goes here

class MyPlugin implements Plugin<Project> {
    void apply(Project project) {
        Task myTask = project.tasks.create( 'myTask', MyTask)
        myTask.dependsOn 'clean', 'classes'


Thank you very much. That helped a lot. I appreciate it.