# Copy and some other tasks can be used "directly", what's the interface for that?

**URL:** <https://discuss.gradle.org/t/copy-and-some-other-tasks-can-be-used-directly-whats-the-interface-for-that/40221>\
**Category:** Help/Discuss\
**Created:** [June 13, 2021, 3:57pm UTC](https://discuss.gradle.org/t/copy-and-some-other-tasks-can-be-used-directly-whats-the-interface-for-that/40221 "2021-06-13T15:57:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Norm](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/norm/32/1096_2.png) [@Norm](https://discuss.gradle.org/u/Norm)\
**Post date:** [June 13, 2021, 3:57pm UTC](https://discuss.gradle.org/t/copy-and-some-other-tasks-can-be-used-directly-whats-the-interface-for-that/40221/1 "2021-06-13T15:57:07Z")

</div>

You can use the copy task “directly”:

```gradle
task whatever() {
  doFirst {
    println("Hello, world.")
  }
  doLast {
    copy {
      // copy details go here
    }
  }
}

```

What do I have to implement to allow my plugin to be used like that?

---

<div class="post-metadata">

**Author:** ![jjustinic](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jjustinic/32/9005_2.png) [@jjustinic](https://discuss.gradle.org/u/jjustinic)\
**Post date:** [June 14, 2021, 1:29pm UTC](https://discuss.gradle.org/t/copy-and-some-other-tasks-can-be-used-directly-whats-the-interface-for-that/40221/2 "2021-06-14T13:29:42Z")

</div>

This is not using the `Copy` task directly. Gradle provides a `copy` method on the `Project` which allows you to copy files. It also provides a `Copy` task. Both implement the same `CopySpec` interface, so they look similar in usage, but the `copy` code in your post doesn’t involve the `Copy` task at all. The task and the method are separate entry points.

You don’t need to implement anything special, but you should break up your logic so that you can call the same logic without needing the task itself. The method can be added on to the `Project` via the `ExtraPropertiesExtension` that is available on many Gradle types.

---

<div class="post-metadata">

**Author:** ![Norm](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/norm/32/1096_2.png) [@Norm](https://discuss.gradle.org/u/Norm)\
**Post date:** [June 14, 2021, 1:30pm UTC](https://discuss.gradle.org/t/copy-and-some-other-tasks-can-be-used-directly-whats-the-interface-for-that/40221/3 "2021-06-14T13:30:44Z")

</div>

Thank you, I’ll investigate that.

---

<div class="post-metadata">

**Author:** ![Norm](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/norm/32/1096_2.png) [@Norm](https://discuss.gradle.org/u/Norm)\
**Post date:** [June 18, 2021, 2:13pm UTC](https://discuss.gradle.org/t/copy-and-some-other-tasks-can-be-used-directly-whats-the-interface-for-that/40221/4 "2021-06-18T14:13:00Z")

</div>

Worked perfectly. Thanks, James!
