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

**URL:** <https://discuss.gradle.org/t/how-to-add-a-task-of-a-certain-type-in-a-custom-plugin/3214>\
**Category:** Old Forum Archive\
**Created:** [December 7, 2011, 7:04am UTC](https://discuss.gradle.org/t/how-to-add-a-task-of-a-certain-type-in-a-custom-plugin/3214 "2011-12-07T07:04:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![atzbert](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@atzbert](https://discuss.gradle.org/u/atzbert)\
**Post date:** [December 7, 2011, 7:04am UTC](https://discuss.gradle.org/t/how-to-add-a-task-of-a-certain-type-in-a-custom-plugin/3214/1 "2011-12-07T07:04:00Z")

</div>

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

```gradle
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:

```gradle
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 {
                from(warTask.archivePath)
                into(tomcatDir)
            }
            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…

---

<div class="post-metadata">

**Author:** ![atzbert](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@atzbert](https://discuss.gradle.org/u/atzbert)\
**Post date:** [December 7, 2011, 7:40am UTC](https://discuss.gradle.org/t/how-to-add-a-task-of-a-certain-type-in-a-custom-plugin/3214/2 "2011-12-07T07:40:00Z")

</div>

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

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

```
