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")