Skip to content

Commit 1620e1e

Browse files
authored
Replace Plexus dependency by more extensive usage of java.nio (#243)
Remove the dependency to Plexus, replaced by more reliance on `java.nio`. This commit contains the following work items: * Replacement of Plexus includes/excludes filters by `java.nio.file.PathMatcher`. * Use `java.nio.file.FileVisitor` for walking over files and directory trees. * Changes in some logging messages and exceptions. * The `IOException` throws by Java is no longer wrapped in another `IOException`. Pull request: #243
1 parent e734c70 commit 1620e1e

File tree

8 files changed

+749
-421
lines changed

8 files changed

+749
-421
lines changed

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ under the License.
9999
<scope>provided</scope>
100100
</dependency>
101101

102-
<dependency>
103-
<groupId>org.codehaus.plexus</groupId>
104-
<artifactId>plexus-utils</artifactId>
105-
</dependency>
106-
107102
<!-- Test -->
108103
<dependency>
109104
<groupId>org.apache.maven.plugin-testing</groupId>

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

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public class CleanMojo implements org.apache.maven.api.plugin.Mojo {
222222
@Override
223223
public void execute() {
224224
if (skip) {
225-
getLog().info("Clean is skipped.");
225+
logger.info("Clean is skipped.");
226226
return;
227227
}
228228

@@ -236,7 +236,7 @@ public void execute() {
236236
} else {
237237
fastDir = null;
238238
if (fast) {
239-
getLog().warn("Fast clean requires maven 3.3.1 or newer, "
239+
logger.warn("Fast clean requires maven 3.3.1 or newer, "
240240
+ "or an explicit directory to be specified with the 'fastDir' configuration of "
241241
+ "this plugin, or the 'maven.clean.fastDir' user property to be set.");
242242
}
@@ -248,37 +248,22 @@ public void execute() {
248248
throw new IllegalArgumentException("Illegal value '" + fastMode + "' for fastMode. Allowed values are '"
249249
+ FAST_MODE_BACKGROUND + "', '" + FAST_MODE_AT_END + "' and '" + FAST_MODE_DEFER + "'.");
250250
}
251-
252-
Cleaner cleaner = new Cleaner(session, getLog(), isVerbose(), fastDir, fastMode);
253-
251+
final var cleaner =
252+
new Cleaner(session, logger, isVerbose(), fastDir, fastMode, followSymLinks, failOnError, retryOnError);
254253
try {
255254
for (Path directoryItem : getDirectories()) {
256255
if (directoryItem != null) {
257-
cleaner.delete(directoryItem, null, followSymLinks, failOnError, retryOnError);
256+
cleaner.delete(directoryItem);
258257
}
259258
}
260-
261259
if (filesets != null) {
262260
for (Fileset fileset : filesets) {
263261
if (fileset.getDirectory() == null) {
264262
throw new MojoException("Missing base directory for " + fileset);
265263
}
266-
final String[] includes = fileset.getIncludes();
267-
final String[] excludes = fileset.getExcludes();
268-
final boolean useDefaultExcludes = fileset.isUseDefaultExcludes();
269-
final GlobSelector selector;
270-
if ((includes != null && includes.length != 0)
271-
|| (excludes != null && excludes.length != 0)
272-
|| useDefaultExcludes) {
273-
selector = new GlobSelector(includes, excludes, useDefaultExcludes);
274-
} else {
275-
selector = null;
276-
}
277-
cleaner.delete(
278-
fileset.getDirectory(), selector, fileset.isFollowSymlinks(), failOnError, retryOnError);
264+
cleaner.delete(fileset);
279265
}
280266
}
281-
282267
} catch (IOException e) {
283268
throw new MojoException("Failed to clean project: " + e.getMessage(), e);
284269
}
@@ -290,7 +275,7 @@ public void execute() {
290275
* @return <code>true</code> if verbose output is enabled, <code>false</code> otherwise.
291276
*/
292277
private boolean isVerbose() {
293-
return (verbose != null) ? verbose : getLog().isDebugEnabled();
278+
return (verbose != null) ? verbose : logger.isDebugEnabled();
294279
}
295280

296281
/**
@@ -307,8 +292,4 @@ private Path[] getDirectories() {
307292
}
308293
return directories;
309294
}
310-
311-
private Log getLog() {
312-
return logger;
313-
}
314295
}

0 commit comments

Comments
 (0)