You can use the copy task “directly”:
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?
You can use the copy task “directly”:
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?
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.
Thank you, I’ll investigate that.
Worked perfectly. Thanks, James!