I am trying to implement my custom plugin, unfortunately not able to invoke the method closure which was invoked in afterEvalute of my custom task.
I have attached my code below.
class CustomPlugin implements Plugin<Project>{
Project project;
@Override
public void apply(Project argProject) {
this.project=argProject;
}
project.getGradle().projectsEvaluated {
def myTaskForFileGeneration = project.tasks.create("MyTask",MyCustomGradleTask ){
group "Custom Tasks"
baseName "MyCustomGradleTask"
}
myTaskForFileGeneration.dependsOn project.build
}
}
public class MyCustomGradleTask extends Zip {
public MyCustomGradleTask(){
MethodClosure doMyClosure= new MethodClosure(this, "generateMyFiles");
getProject().afterEvaluate(new Action<Project>() {
@Override
public void execute(Project arg0) {
doLast(doMyClosure);
}
});
}
public void generateMyFiles(){
System.out.println("File generation logic");
}
}
Any help is much appreciated. Thanks in advance.