Skip to content

Commit 90ab0cf

Browse files
committed
Replace the resolution of targetPath by the method now available in Maven core.
1 parent 00107cb commit 90ab0cf

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

src/main/java/org/apache/maven/plugins/clean/CleanMojo.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@
2626
import java.util.Objects;
2727

2828
import org.apache.maven.api.Project;
29-
import org.apache.maven.api.ProjectScope;
3029
import org.apache.maven.api.Session;
3130
import org.apache.maven.api.di.Inject;
32-
import org.apache.maven.api.model.Build;
3331
import org.apache.maven.api.plugin.Log;
3432
import org.apache.maven.api.plugin.MojoException;
3533
import org.apache.maven.api.plugin.annotations.Mojo;
@@ -344,20 +342,9 @@ private List<Path> getDirectories() {
344342
if (project != null && session != null) {
345343
ProjectManager projectManager = session.getService(ProjectManager.class);
346344
if (projectManager != null) {
347-
final Build build = project.getBuild();
348345
projectManager.getSourceRoots(project).forEach((source) -> {
349346
source.targetPath().ifPresent((targetPath) -> {
350-
// TODO: we can replace by `Project.getOutputDirectory(scope)` if MVN-11322 is merged.
351-
String base;
352-
ProjectScope scope = source.scope();
353-
if (scope == ProjectScope.MAIN) {
354-
base = build.getOutputDirectory();
355-
} else if (scope == ProjectScope.TEST) {
356-
base = build.getTestOutputDirectory();
357-
} else {
358-
base = build.getDirectory();
359-
}
360-
Path dir = project.getBasedir().resolve(base);
347+
Path dir = project.getOutputDirectory(source.scope());
361348
directories.add(dir.resolve(targetPath));
362349
});
363350
});

0 commit comments

Comments
 (0)