From 2a4cf10937713843d94b201d13135f96b8b67420 Mon Sep 17 00:00:00 2001 From: Jonathan Bluett-Duncan Date: Wed, 6 Sep 2023 23:26:33 +0100 Subject: [PATCH] Fix another config cache problem w/ RewriteDryRunTask --- .../openrewrite/gradle/RewriteDryRunTask.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugin/src/main/java/org/openrewrite/gradle/RewriteDryRunTask.java b/plugin/src/main/java/org/openrewrite/gradle/RewriteDryRunTask.java index b8eec3f16..2592bc39d 100644 --- a/plugin/src/main/java/org/openrewrite/gradle/RewriteDryRunTask.java +++ b/plugin/src/main/java/org/openrewrite/gradle/RewriteDryRunTask.java @@ -15,6 +15,7 @@ */ package org.openrewrite.gradle; +import org.gradle.api.file.ProjectLayout; import org.gradle.api.logging.Logger; import org.gradle.api.logging.Logging; import org.gradle.api.specs.Specs; @@ -24,15 +25,26 @@ import javax.inject.Inject; import java.io.File; -public class RewriteDryRunTask extends AbstractRewriteTask { +public abstract class RewriteDryRunTask extends AbstractRewriteTask { private static final Logger logger = Logging.getLogger(RewriteDryRunTask.class); + @Inject + public abstract ProjectLayout getProjectLayout(); + // This must return File, rather than Path. // On Gradle 4.0 annotating something returning a Path with @OutputFile triggers a bug that deadlocks Gradle @OutputFile public File getReportPath() { - return getProject().getBuildDir().toPath().resolve("reports").resolve("rewrite").resolve("rewrite.patch").toFile(); + return getProjectLayout() + .getBuildDirectory() + .get() + .getAsFile() + .toPath() + .resolve("reports") + .resolve("rewrite") + .resolve("rewrite.patch") + .toFile(); } @Inject