I’ve been pulling my hair out on this for a few days, so any help will be greatly welcome.
I’ve written a plugin that runs some code after the “classes” task. I’m currently refactoring the plugin for gradle 6.7, and rewriting it in Java. After reading the docu on lazy loading and task configuration avoidance, I made the necessary changes to the plugin configuration, and it broke everything.
Goal:
Have my BuildServiceInfoTask always run after the java “classes” task.
Here’s what I tried, and I’ve tried a lot more. I want to use classestask.dependsOn, but when you do this:
project.getTasks().named("classes")
The object you get back doesn’t have the “dependsOn” method. The “mustRunAfter” I’m using doesn’t work, so how do I get to my goal?
Can anyone shed some light on what I’m doing wrong or what concept I’ve missed?
public class ServiceInfoPlugin implements Plugin<Project> {
public static final String EXT_NAME = "serviceinfo";
@Override
public void apply(Project project) {
project.getExtensions().create(EXT_NAME, XspCoreServiceInfoExtension.class);
project.getTasks().register(DependencyListingTask.TASK_NAME,DependencyListingTask.class);
project.getTasks().register(BuildServiceInfoTask.TASK_NAME,BuildServiceInfoTask.class,buildServiceInfoTask -> {
buildServiceInfoTask.mustRunAfter(project.getRootProject().getTasks().named("classes"));
});
project.getLogger().info("ServiceInfoPlugin loaded.");
}
}