Using AsciiDependencyReportRenderer in Gradle 6.8 and 7.x

I’m currently migrate a gradle multiproject build system from 5.x to 7.x. In Gradle 6.8.3 the class AsciiDependencyReportRenderer has changed the signature of function startProject(Project) to startProject(ProjectDetails).

I used this class in another task to generate the dependency ascii tree into an StringBuffer:

		// check if this is the project that runs the task we need
		Boolean ignore=true
		factsToAcknowledge.keySet().each {
			if (it.startsWith(":${project.name}")) ignore=false
		}
		if (ignore) return
		// Create a AsciiDependencyReportRenderer 
		AsciiDependencyReportRenderer renderer = new AsciiDependencyReportRenderer()
		// Set as output a StringBuilder reference (implements Appendable)
		StringBuilder sb = new StringBuilder()
		StreamingStyledTextOutputFactory f = new StreamingStyledTextOutputFactory(sb)
		renderer.setOutput(f.create(getClass(),null))
		// create a legend renderer and start the project
		renderer.startProject(project);
		// sort all dependencies
		SortedSet<Configuration> sortedConfigurations = new TreeSet<Configuration>(new Comparator<Configuration>() {
			public int compare(Configuration conf1, Configuration conf2) {
				return conf1.getName().compareTo(conf2.getName());
			}
		});
		Configuration configuration = project.configurations.compile
		renderer.startConfiguration(configuration);
		renderer.render(configuration);
		renderer.completeConfiguration(configuration);
		// finish the whole processing
		renderer.completeProject(project);
		// print dependency tree into console
		//println(sb)
		// but also put it into the UI to ask the user
		configurationDump=sb.toString()

Since Gradle 6.8.3 the code fails at renderer.startProject( ... ):

> Cannot cast object 'project ':solr-plugin'' with class 'org.gradle.api.internal.project.DefaultProject_Decorated' to class 'org.gradle.api.tasks.diagnostics.internal.ProjectDetails'

How can I get the ProjectDetails from my project reference I have in a running task? Or is there a better way to get the dependency tree?

We use the dependency tree to display it in some UI text field. We build fatjars and want to make sure that all dependencies are included/excluded as expected before pushing a build to maven.

Found the solution myself when I read this source code:

		// create a legend renderer and start the project
		ProjectDetails projectDetails = ProjectDetails.of(project)