From 211999271a1d57891d3e168f32853ee52e17f676 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 1 Oct 2026 19:35:20 +0000 Subject: [PATCH] fix: log debug message when root directory is unavailable in fast clean fallback When session.getRootDirectory() throws IllegalStateException (embedded usage), log a debug message before falling back to the system temp directory. Also initialise rootDir to null explicitly for clarity. Addresses review feedback from @desruisseaux on #362. --- src/main/java/org/apache/maven/plugins/clean/CleanMojo.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/clean/CleanMojo.java b/src/main/java/org/apache/maven/plugins/clean/CleanMojo.java index 0db1b3f..89cad6b 100644 --- a/src/main/java/org/apache/maven/plugins/clean/CleanMojo.java +++ b/src/main/java/org/apache/maven/plugins/clean/CleanMojo.java @@ -283,11 +283,12 @@ public void execute() { if (fast && session != null) { Path tmpDir = fastDir; if (tmpDir == null) { - Path rootDir; + Path rootDir = null; try { rootDir = session.getRootDirectory(); } catch (IllegalStateException e) { - rootDir = null; + // Embedded usage where no root directory is available — fall through to fallback. + logger.debug("Missing root directory, falling back to system temp directory.", e); } tmpDir = rootDir != null ? rootDir.resolve(".mvn").resolve("target").resolve("clean")