This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-clean-plugin.git
commit 90ab0cf0fd6720ea8b1a5ce3fe515ca3ab1ab827 Author: Martin Desruisseaux <[email protected]> AuthorDate: Sun Oct 26 18:34:37 2025 +0100 Replace the resolution of `targetPath` by the method now available in Maven core. --- .../java/org/apache/maven/plugins/clean/CleanMojo.java | 15 +-------------- 1 file changed, 1 insertion(+), 14 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 9ac88c4..2bea405 100644 --- a/src/main/java/org/apache/maven/plugins/clean/CleanMojo.java +++ b/src/main/java/org/apache/maven/plugins/clean/CleanMojo.java @@ -26,10 +26,8 @@ import java.util.List; import java.util.Objects; import org.apache.maven.api.Project; -import org.apache.maven.api.ProjectScope; import org.apache.maven.api.Session; import org.apache.maven.api.di.Inject; -import org.apache.maven.api.model.Build; import org.apache.maven.api.plugin.Log; import org.apache.maven.api.plugin.MojoException; import org.apache.maven.api.plugin.annotations.Mojo; @@ -344,20 +342,9 @@ public class CleanMojo implements org.apache.maven.api.plugin.Mojo { if (project != null && session != null) { ProjectManager projectManager = session.getService(ProjectManager.class); if (projectManager != null) { - final Build build = project.getBuild(); projectManager.getSourceRoots(project).forEach((source) -> { source.targetPath().ifPresent((targetPath) -> { - // TODO: we can replace by `Project.getOutputDirectory(scope)` if MVN-11322 is merged. - String base; - ProjectScope scope = source.scope(); - if (scope == ProjectScope.MAIN) { - base = build.getOutputDirectory(); - } else if (scope == ProjectScope.TEST) { - base = build.getTestOutputDirectory(); - } else { - base = build.getDirectory(); - } - Path dir = project.getBasedir().resolve(base); + Path dir = project.getOutputDirectory(source.scope()); directories.add(dir.resolve(targetPath)); }); });
