I'm writing my own gradle plugin and want to define an additional Copy task. What I do is:
myPlugin {
scriptsDir = "otherDir"
}
class MyPluginExtension {
String scriptsDir = "scripts";
}
class MyPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.extensions.create("myPlugin", MyPluginExtension)
project.task("myDistCopy", type: Copy) {
.....
from(project.myPlugin.scriptDir) {
into('bin')
}
}
}
}
Unfortunately the files are still copied from the "scripts" folder instead of "otherDir". It seems that the extension properties are not set at the evaluation phase. Do you have any ideas how can I refer to the myPlugin settings in the Copy task?
Thanks!
Actually the solution that worked for me turned out to be pretty simple:
project.task("myDistCopy", type: Copy) {
.....
project.afterEvaluate {
from(project.myPlugin.scriptDir) {
into('bin')
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With