Using `DirectoryProperty`

I have the following:

class JakartaTransformerConfig {
	@Inject
	@SuppressWarnings("UnstableApiUsage")
	public JakartaTransformerConfig(Configuration transformerDependencies, Project project) {
		this.transformerDependencies = transformerDependencies;
		this.project = project;

		this.outputDir = project.getObjects().directoryProperty();
		this.outputDir.convention( project.getLayout().getBuildDirectory().dir( "libs") );

		this.renameRules = project.getObjects().fileProperty();
		this.versionRules = project.getObjects().fileProperty();
		this.directRules = project.getObjects().fileProperty();
	}

	/**
	 * Where the transformed jars should be written
	 */
	public DirectoryProperty getOutputDir() {
		return outputDir;
	}
}

default class ShadowTransformationTask extends DefaultTask .. {
	...

	@OutputDirectory
	public Provider<Directory> getOutputDirectory() {
		// just trying stuff...
		//transformerConfig.getOutputDir().finalizeValue();

		return transformerConfig.getOutputDir()::get;
	}
}

If I define the output directory on the top-level DSL:

jakartaTransformation {
    ...
    outputDir ...
}

it works fine.

However, if I do not (expecting the convention/default to be used) it blows up:

Execution failed for task ':shadowTransformation'.
> Cannot convert the provided notation to a File or URI: org.hibernate.build.gradle.jakarta.ShadowTransformationTask$$Lambda$625/0x00000001006d3440@222efcb5.
  The following types/formats are supported:
    - A String or CharSequence path, for example 'src/main/java' or '/usr/include'.
    ...

What is it I am missing about convention()? Isn’t this the whole point of convention()?

Thanks!

Try removing this method reference in ShadowTransformationTask.getOutputDirectory().