How to add a task of a certain type in a custom plugin?

(Tino Nitze) #1

I am currently trying to move all the custom stuff that I normally import via

apply from: System.getenv()['GRADLE_HOME'] + '/config/gradle_std_include.gradle'

to a custom plugin which would basically do the same but much nicer.

Adding regular tasks of no specific type is easy:

private def addDeployTask(Project project) {
     project.task('deploy') << {
            def warTask = project.tasks.getByName('war')
            dependsOn warTask
            def tomcatDirName = project.getProperty('tomcat.deploy')
            println "Deploy folder is " + tomcatDirName
            tomcatDir = project.file(tomcatDirName)
            project.copy {
            println "Copied $warTask.archivePath to $tomcatDir"

But how would i make the added task of type “Copy” ? I can imagine this might be basic and trivial. But I spent already like half an hour on that - maybe it saves me some time when asking you guys…

(Tino Nitze) #2

Ok, it WAS indeed trivial. Found it here in the forums…:

project.task([type: Copy],'deploy') << {