How can I make use of a Copy task in a Plugin?

plugins

(John Mercier) #1

Hello everyone, I have been messing with gradle at work and we are convinced we can replace ant with gradle while still maintaining our current dist directories. I am running into a problem adding copy tasks to through a plugin.

I have asked this question on stackoverflow but maybe it should be here. I’m looking for any leads to help figure this out.

I need to be able to configure the from, include, exclude, and into methods from inside a plugin using values from an extension. Has anyone tried this? I have’t been able to find very many examples of this. I believe my problem is when I use a gstring the value is not being set lazily.

Thanks!


(Stefan Oehme) #2

If you want to go with an extension, you’ll have to wrap the code that accesses the extension to configure the task in a project.afterEvaluate block.

But if you only have one dist task, then having an extension is overkill. Just let the user configure the task directly in that case.


(John Mercier) #3

Thanks for the info. The example was a simple version. I do have about 5 tasks for this. I discovered project.copy and decided to use that 5 times in the execution of a task instead. This way there is only one task for the user and it is configured from the extension. It seems to be working well.