Unit test plugin's afterEvaulate

Thanks for the answers.

configurations is a NamedDomainObjectContainer. Using

extension.getConfigurations().all((c) -> {
    registerApplyTask(aProject, c);
});

solves this issue.

Sadly I still need to use afterEvaluate for a second type of task that works on plain properties of the extension. I suppose the right way to solve this would be to make use of lazy-configuration and Property?! Actually I found the documentation on this is to be not very intuitive especially all the examples are in Groovy and Kotlin only (despite the recommendation to use Java or Kotlin for plugin development).

Maybe someone could explain how something like this would be done correctly using lazy-configruation:

public class MyExtension { 
  public String property = "value";
  private final NamedDomainObjectContainer<Configuration> configurations;

  @Inject
  public WorkspaceExtension(final ObjectFactory objectFactory) {
    configurations = objectFactory.domainObjectContainer(WorkspaceConfiguration.class);
  }
}

public abstract class MyTask extends DefaultTask {

  @Input
  private final String property = "value";

  public abstract void setProperty(final String aValue);
}

public class MyPlugin implements Plugin<Project> {

  @Override
  public void apply(final Project aProject) {
    aProject.afterEvaluate((p) -> {
      final MyExtension extension = aProject.getExtensions().create("extension", MyExtension.class);
      p.getTasks().register("myTask", MyTask.class).configure((t) -> {
        t.setProperty(workspaceExtension.property);
      });
    });
  }

I simplified the names in the code snippet. They are actually not that generic in the real plugin code…

TIA