desruisseaux opened a new pull request, #243:
URL: https://github.com/apache/maven-clean-plugin/pull/243

   (Copy of #242, which was accidentally merged. The merge has been immediately 
cancelled)
   Remove the dependency to Plexus, replaced by more reliance on `java.nio`.
   
   # Work items
   
   * Replacement of Plexus includes/excludes filters by 
`java.nio.file.PathMatcher`. A benefit is the support of different syntax, at 
least "glob" and "regex". If no syntax is specified, default to the "glob" 
syntax with modifications for reproducing the behavior of Plexus filters (see 
below).
   * Use `java.nio.file.FileVisitor` for walking over files and directory 
trees. Consequently, symbolic links are now followed by `FileVisitor` instead 
of by `maven-clean-plugin` itself. An advantage is that `FileVisitor` is safe 
against infinite loops when there is cycles. Also, file attributes (whether the 
file is regular, a directory or a link) are queried only once per file.    
   * Changes in some logging messages. The _"Deleting XYZ"_ message is replaced 
by either _"Deleted XYZ"_ if the deletion has been successful, or _"Failed to 
delete XYZ"_ in case of failure (i.e., _"XYZ"_ is not logged twice in case of 
failure).
   * The `IOException` throws by Java is no longer wrapped in another 
`IOException`, so that the callers can catch an exception of the specific 
sub-type if desired. The exception is also thrown earlier, before it causes 
another exception. The difference can be seen in the tests: a deletion fails 
because unauthorized, but the error that was reported to the user was not the 
`AccessDeniedException`. Instead, it was a `DirectoryNotEmptyException` thrown 
when the plugin tried to delete the directory that contains the file that the 
plugin failed to delete. After this commit, the exception thrown is the 
original `AccessDeniedException`.
   
   # Matcher syntax
   The "glob" syntax of `java.nio.file.PathMatcher` seems to have slightly 
different rules than Plexus. In particular, the tests suggest that the `**` 
pattern means "0 or more directories" in Maven 3 whereas the "glob" syntax of 
`PathMatcher` seems to understand `**` as "1 or more directories". This commit 
applies the following rules:
   
   * If the "glob" syntax or any other syntax was explicitly specified, use the 
pattern verbatim. No modification applied.
   * Otherwise, modify the pattern as below:
     * Replace all occurrences of the OS-specific separator by `/` (the 
standardized separator expected by `PathMatcher`).
     * For every occurrence of `**`, generate new patterns without the `**` in 
order to simulate the case of 0 directory.
     * Prepend `glob:` to the resulting pattern.
   
   # Risk
   This commit is a significant changes. While the JUnir and integration tests 
pass, there is still a risk for some unforeseen behavioural changes. 
Differences compared to the previous version will be addressed as they are 
reported. There is also non-trivial optimizations for deciding whether to skip 
and entire directory (those optimizations were already present in the previous 
version, but behind Plexus).
   
   # Future work
   If experience shows that the new version is working well, maybe we should 
move the `Selector` class and an abstract `FileVisitor` base class to Maven 
core for allowing other plugins, such as `maven-compiler-plugin`, to use it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to