Making custom task run after java built-in task with configuration avoidance

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.

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:
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";

    public void apply(Project project) {
        project.getExtensions().create(EXT_NAME, XspCoreServiceInfoExtension.class);
        project.getTasks().register(BuildServiceInfoTask.TASK_NAME,BuildServiceInfoTask.class,buildServiceInfoTask -> {
        project.getLogger().info("ServiceInfoPlugin loaded.");
1 Like