[Git][java-team/maven-clean-plugin][master] 6 commits: Standards-Version updated to 4.6.1

Emmanuel Bourg (@ebourg) gitlab at salsa.debian.org
Tue Sep 27 23:56:01 BST 2022



Emmanuel Bourg pushed to branch master at Debian Java Maintainers / maven-clean-plugin


Commits:
868bbe21 by Emmanuel Bourg at 2022-09-28T00:45:53+02:00
Standards-Version updated to 4.6.1

- - - - -
c58d091d by Emmanuel Bourg at 2022-09-28T00:46:06+02:00
Switch to debhelper level 13

- - - - -
3d6b339c by Emmanuel Bourg at 2022-09-28T00:46:55+02:00
New upstream version 3.2.0
- - - - -
93c08b92 by Emmanuel Bourg at 2022-09-28T00:46:56+02:00
Update upstream source from tag 'upstream/3.2.0'

Update to upstream version '3.2.0'
with Debian dir 2e62017055ed94f9d4fcb0af4afc9ec8c9acc292
- - - - -
45df93a6 by Emmanuel Bourg at 2022-09-28T00:54:47+02:00
Set the source/target level to Java 8

- - - - -
f48d816c by Emmanuel Bourg at 2022-09-28T00:54:59+02:00
Upload to unstable

- - - - -


23 changed files:

- + .asf.yaml
- + .github/dependabot.yml
- + .github/pull_request_template.md
- + .github/workflows/maven-verify.yml
- Jenkinsfile
- + README.md
- debian/changelog
- − debian/compat
- debian/control
- debian/maven.properties
- pom.xml
- src/main/java/org/apache/maven/plugins/clean/CleanMojo.java
- src/main/java/org/apache/maven/plugins/clean/Cleaner.java
- src/main/java/org/apache/maven/plugins/clean/Fileset.java
- src/site/apt/examples/delete_additional_files.apt.vm
- src/site/apt/examples/ignoring-errors.apt.vm
- src/site/apt/examples/skipping-clean.apt.vm
- src/site/apt/index.apt.vm
- src/site/apt/usage.apt.vm
- src/site/site.xml
- src/site/xdoc/download.xml.vm
- src/test/java/org/apache/maven/plugins/clean/CleanMojoTest.java
- src/test/java/org/apache/maven/plugins/clean/Utils.java


Changes:

=====================================
.asf.yaml
=====================================
@@ -0,0 +1,26 @@
+# 
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#  contributor license agreements.  See the NOTICE file distributed with
+#  this work for additional information regarding copyright ownership.
+#  The ASF licenses this file to You under the Apache License, Version 2.0
+#  (the "License"); you may not use this file except in compliance with
+#  the License.  You may obtain a copy of the License at
+# 
+#       http://www.apache.org/licenses/LICENSE-2.0
+# 
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+# see https://s.apache.org/asfyaml
+github:
+  description: "Apache Maven Clean Plugin"
+  homepage: https://maven.apache.org/plugins/maven-clean-plugin/
+  labels:
+    - java
+    - build-management
+    - maven-plugins
+    - maven-clean-plugin
+    - maven


=====================================
.github/dependabot.yml
=====================================
@@ -0,0 +1,27 @@
+#
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#  contributor license agreements.  See the NOTICE file distributed with
+#  this work for additional information regarding copyright ownership.
+#  The ASF licenses this file to You under the Apache License, Version 2.0
+#  (the "License"); you may not use this file except in compliance with
+#  the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+version: 2
+updates:
+  - package-ecosystem: "maven"
+    directory: "/"
+    schedule:
+      interval: "daily"
+  - package-ecosystem: "github-actions"
+    directory: "/"
+    schedule:
+      interval: "daily"
+


=====================================
.github/pull_request_template.md
=====================================
@@ -0,0 +1,29 @@
+Following this checklist to help us incorporate your 
+contribution quickly and easily:
+
+ - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MCLEAN) filed 
+       for the change (usually before you start working on it).  Trivial changes like typos do not 
+       require a JIRA issue.  Your pull request should address just this issue, without 
+       pulling in other changes.
+ - [ ] Each commit in the pull request should have a meaningful subject line and body.
+ - [ ] Format the pull request title like `[MCLEAN-XXX] - Fixes bug in ApproximateQuantiles`,
+       where you replace `MCLEAN-XXX` with the appropriate JIRA issue. Best practice
+       is to use the JIRA issue title in the pull request title and in the first line of the 
+       commit message.
+ - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
+ - [ ] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will 
+       be performed on your pull request automatically.
+ - [ ] You have run the integration tests successfully (`mvn -Prun-its clean verify`).
+
+If your pull request is about ~20 lines of code you don't need to sign an
+[Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
+please ask on the developers list.
+
+To make clear that you license your contribution under 
+the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
+you have to acknowledge this by using the following check-box.
+
+ - [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
+
+ - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
+


=====================================
.github/workflows/maven-verify.yml
=====================================
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Verify
+
+on:
+  push:
+  pull_request:
+
+jobs:
+  build:
+    name: Verify
+    uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml at v2


=====================================
Jenkinsfile
=====================================
@@ -17,4 +17,4 @@
  * under the License.
  */
 
-asfMavenTlpStdBuild()
+asfMavenTlpPlgnBuild()


=====================================
README.md
=====================================
@@ -0,0 +1,99 @@
+<!---
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied..
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+Contributing to [Apache Maven Clean Plugin](https://maven.apache.org/plugins/maven-clean-plugin/)
+======================
+
+[![ASF Jira](https://img.shields.io/endpoint?url=https%3A%2F%2Fmaven.apache.org%2Fbadges%2Fasf_jira-MCLEAN.json)][jira]
+[![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license]
+[![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-clean-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.apache.maven.plugins/maven-clean-plugin)
+[![Jenkins Status](https://img.shields.io/jenkins/s/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-clean-plugin/job/master.svg?)][build]
+[![Jenkins tests](https://img.shields.io/jenkins/t/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-clean-plugin/job/master.svg?)][test-results]
+
+
+You have found a bug or you have an idea for a cool new feature? Contributing
+code is a great way to give something back to the open source community. Before
+you dig right into the code, there are a few guidelines that we need
+contributors to follow so that we can have a chance of keeping on top of
+things.
+
+Getting Started
+---------------
+
++ Make sure you have a [JIRA account](https://issues.apache.org/jira/).
++ Make sure you have a [GitHub account](https://github.com/signup/free).
++ If you're planning to implement a new feature, it makes sense to discuss your changes 
+  on the [dev list][ml-list] first. 
+  This way you can make sure you're not wasting your time on something that isn't 
+  considered to be in Apache Maven's scope.
++ Submit a ticket for your issue, assuming one does not already exist.
+  + Clearly describe the issue, including steps to reproduce when it is a bug.
+  + Make sure you fill in the earliest version that you know has the issue.
++ Fork the repository on GitHub.
+
+Making and Submitting Changes
+--------------
+
+We accept Pull Requests via GitHub. The [developer mailing list][ml-list] is the
+main channel of communication for contributors.  
+There are some guidelines which will make applying PRs easier for us:
++ Create a topic branch from where you want to base your work (this is usually the master branch).
+  Push your changes to a topic branch in your fork of the repository.
++ Make commits of logical units.
++ Respect the original code style: by using the same [codestyle][code-style],
+  patches should only highlight the actual difference, not being disturbed by any formatting issues:
+  + Only use spaces for indentation.
+  + Create minimal diffs - disable on save actions like reformat source code or organize imports. 
+    If you feel the source code should be reformatted, create a separate PR for this change.
+  + Check for unnecessary whitespace with `git diff --check` before committing.
++ Make sure your commit messages are in the proper format. Your commit message should contain the key of the JIRA issue.
+```
+[MCLEAN-XXX] - Subject of the JIRA Ticket
+ Optional supplemental description.
+```
++ Make sure you have added the necessary tests (JUnit/IT) for your changes.
++ Run all the tests with `mvn -Prun-its verify` to assure nothing else was accidentally broken.
++ Submit a pull request to the repository in the Apache organization.
++ Update your JIRA ticket and include a link to the pull request in the ticket.
+
+If you plan to contribute on a regular basis, please consider filing a [contributor license agreement][cla].
+
+Making Trivial Changes
+----------------------
+
+For changes of a trivial nature to comments and documentation, it is not always
+necessary to create a new ticket in JIRA.  In this case, it is appropriate to
+start the first line of a commit with '(doc)' instead of a ticket number..
+
+Additional Resources
+--------------------
+
++ [Contributing patches](https://maven.apache.org/guides/development/guide-maven-development.html#Creating_and_submitting_a_patch)
++ [Apache Maven Clean JIRA project page][jira]
++ [Contributor License Agreement][cla]
++ [General GitHub documentation](https://help.github.com/)
++ [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
++ [Apache Maven Twitter Account](https://twitter.com/ASFMavenProject)
++ #Maven IRC channel on freenode.org
+
+[jira]: https://issues.apache.org/jira/projects/MCLEAN/
+[license]: https://www.apache.org/licenses/LICENSE-2.0
+[ml-list]: https://maven.apache.org/mailing-lists.html
+[code-style]: https://maven.apache.org/developers/conventions/code.html
+[cla]: https://www.apache.org/licenses/#clas
+[maven-wiki]: https://cwiki.apache.org/confluence/display/MAVEN/Index
+[test-results]: https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven-clean-plugin/job/master/lastCompletedBuild/testReport/
+[build]: https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven-clean-plugin/job/master/


=====================================
debian/changelog
=====================================
@@ -1,3 +1,12 @@
+maven-clean-plugin (3.2.0-1) unstable; urgency=medium
+
+  * New upstream release
+    - Set the source/target level to Java 8
+  * Standards-Version updated to 4.6.1
+  * Switch to debhelper level 13
+
+ -- Emmanuel Bourg <ebourg at apache.org>  Wed, 28 Sep 2022 00:54:53 +0200
+
 maven-clean-plugin (3.1.0-1) unstable; urgency=medium
 
   * New upstream release


=====================================
debian/compat deleted
=====================================
@@ -1 +0,0 @@
-11


=====================================
debian/control
=====================================
@@ -7,7 +7,7 @@ Uploaders:
  Ludovic Claude <ludovic.claude at laposte.net>,
  Emmanuel Bourg <ebourg at apache.org>
 Build-Depends:
- debhelper (>= 11~),
+ debhelper-compat (= 13),
  default-jdk,
  junit4,
  libmaven-file-management-java,
@@ -16,7 +16,7 @@ Build-Depends:
  libmaven3-core-java,
  libplexus-utils-java,
  maven-debian-helper (>= 2.2)
-Standards-Version: 4.1.5
+Standards-Version: 4.6.1
 Vcs-Git: https://salsa.debian.org/java-team/maven-clean-plugin.git
 Vcs-Browser: https://salsa.debian.org/java-team/maven-clean-plugin
 Homepage: http://maven.apache.org/plugins/maven-clean-plugin/


=====================================
debian/maven.properties
=====================================
@@ -2,3 +2,5 @@
 # For example:
 # maven.test.skip=true
 
+maven.compiler.source=8
+maven.compiler.target=8


=====================================
pom.xml
=====================================
@@ -25,12 +25,12 @@ under the License.
   <parent>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-plugins</artifactId>
-    <version>31</version>
-    <relativePath>../../pom/maven/maven-plugins/pom.xml</relativePath>
+    <version>35</version>
+    <relativePath />
   </parent>
 
   <artifactId>maven-clean-plugin</artifactId>
-  <version>3.1.0</version>
+  <version>3.2.0</version>
   <packaging>maven-plugin</packaging>
 
   <name>Apache Maven Clean Plugin</name>
@@ -47,7 +47,7 @@ under the License.
     <connection>scm:git:https://gitbox.apache.org/repos/asf/maven-clean-plugin.git</connection>
     <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-clean-plugin.git</developerConnection>
     <url>https://github.com/apache/maven-clean-plugin/tree/${project.scm.tag}</url>
-    <tag>maven-clean-plugin-3.1.0</tag>
+    <tag>maven-clean-plugin-3.2.0</tag>
   </scm>
   <issueManagement>
     <system>JIRA</system>
@@ -55,19 +55,21 @@ under the License.
   </issueManagement>
   <ciManagement>
     <system>Jenkins</system>
-    <url>https://builds.apache.org/job/maven-box/job/maven-clean-plugin/</url>
+    <url>https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-clean-plugin/</url>
   </ciManagement>
   <distributionManagement>
     <site>
       <id>apache.website</id>
-      <url>scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/components/${maven.site.path}</url>
+      <url>scm:svn:https://svn.apache.org/repos/asf/maven/website/components/${maven.site.path}</url>
     </site>
   </distributionManagement>
 
   <properties>
-    <mavenVersion>3.0</mavenVersion>
-    <surefire.version>2.21.0</surefire.version>
-    <javaVersion>7</javaVersion>
+    <mavenVersion>3.2.5</mavenVersion>
+    <javaVersion>8</javaVersion>
+    <surefire.version>2.22.2</surefire.version>
+    <mavenPluginToolsVersion>3.6.4</mavenPluginToolsVersion>
+    <project.build.outputTimestamp>2022-04-01T21:20:29Z</project.build.outputTimestamp>
   </properties>
 
   <dependencies>
@@ -75,11 +77,12 @@ under the License.
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
       <version>${mavenVersion}</version>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-shared-utils</artifactId>
-      <version>3.2.1</version>
+      <version>3.3.4</version>
     </dependency>
 
     <!-- dependencies to annotations -->
@@ -93,7 +96,7 @@ under the License.
     <dependency>
       <groupId>org.apache.maven.plugin-testing</groupId>
       <artifactId>maven-plugin-testing-harness</artifactId>
-      <version>2.1</version>
+      <version>3.3.0</version>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -106,12 +109,12 @@ under the License.
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-core</artifactId>
       <version>${mavenVersion}</version>
-      <scope>test</scope>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>4.12</version>
+      <version>4.13.2</version>
       <scope>test</scope>
     </dependency>
   </dependencies>


=====================================
src/main/java/org/apache/maven/plugins/clean/CleanMojo.java
=====================================
@@ -19,6 +19,7 @@ package org.apache.maven.plugins.clean;
  * under the License.
  */
 
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.Mojo;
@@ -40,7 +41,6 @@ import java.io.IOException;
  * </p>
  *
  * @author <a href="mailto:evenisse at maven.org">Emmanuel Venisse</a>
- * @version $Id$
  * @see org.apache.maven.plugins.clean.Fileset
  * @since 2.0
  */
@@ -49,6 +49,12 @@ public class CleanMojo
     extends AbstractMojo
 {
 
+    public static final String FAST_MODE_BACKGROUND = "background";
+
+    public static final String FAST_MODE_AT_END = "at-end";
+
+    public static final String FAST_MODE_DEFER = "defer";
+
     /**
      * This is where build results go.
      */
@@ -162,6 +168,49 @@ public class CleanMojo
     @Parameter( property = "maven.clean.excludeDefaultDirectories", defaultValue = "false" )
     private boolean excludeDefaultDirectories;
 
+    /**
+     * Enables fast clean if possible. If set to <code>true</code>, when the plugin is executed, a directory to
+     * be deleted will be atomically moved inside the <code>maven.clean.fastDir</code> directory and a thread will
+     * be launched to delete the needed files in the background.  When the build is completed, maven will wait
+     * until all the files have been deleted.  If any problem occurs during the atomic move of the directories,
+     * the plugin will default to the traditional deletion mechanism.
+     *
+     * @since 3.2
+     */
+    @Parameter( property = "maven.clean.fast", defaultValue = "false" )
+    private boolean fast;
+
+    /**
+     * When fast clean is specified, the <code>fastDir</code> property will be used as the location where directories
+     * to be deleted will be moved prior to background deletion.  If not specified, the
+     * <code>${maven.multiModuleProjectDirectory}/target/.clean</code> directory will be used.  If the
+     * <code>${build.directory}</code> has been modified, you'll have to adjust this property explicitly.
+     * In order for fast clean to work correctly, this directory and the various directories that will be deleted
+     * should usually reside on the same volume. The exact conditions are system dependant though, but if an atomic
+     * move is not supported, the standard deletion mechanism will be used.
+     *
+     * @since 3.2
+     * @see #fast
+     */
+    @Parameter( property = "maven.clean.fastDir" )
+    private File fastDir;
+
+    /**
+     * Mode to use when using fast clean.  Values are: <code>background</code> to start deletion immediately and
+     * waiting for all files to be deleted when the session ends, <code>at-end</code> to indicate that the actual
+     * deletion should be performed synchronously when the session ends, or <code>defer</code> to specify that
+     * the actual file deletion should be started in the background when the session ends (this should only be used
+     * when maven is embedded in a long running process).
+     *
+     * @since 3.2
+     * @see #fast
+     */
+    @Parameter( property = "maven.clean.fastMode", defaultValue = FAST_MODE_BACKGROUND )
+    private String fastMode;
+
+    @Parameter( defaultValue = "${session}", readonly = true )
+    private MavenSession session;
+
     /**
      * Deletes file-sets in the following project build directory order: (source) directory, output directory, test
      * directory, report directory, and then the additional file-sets.
@@ -178,7 +227,36 @@ public class CleanMojo
             return;
         }
 
-        Cleaner cleaner = new Cleaner( getLog(), isVerbose() );
+        String multiModuleProjectDirectory = session != null
+                ? session.getSystemProperties().getProperty( "maven.multiModuleProjectDirectory" ) : null;
+        File fastDir;
+        if ( fast && this.fastDir != null )
+        {
+            fastDir = this.fastDir;
+        }
+        else if ( fast && multiModuleProjectDirectory != null )
+        {
+            fastDir = new File( multiModuleProjectDirectory, "target/.clean" );
+        }
+        else
+        {
+            fastDir = null;
+            if ( fast )
+            {
+                getLog().warn( "Fast clean requires maven 3.3.1 or newer, "
+                        + "or an explicit directory to be specified with the 'fastDir' configuration of "
+                        + "this plugin, or the 'maven.clean.fastDir' user property to be set." );
+            }
+        }
+        if ( fast && !FAST_MODE_BACKGROUND.equals( fastMode )
+                  && !FAST_MODE_AT_END.equals( fastMode )
+                  && !FAST_MODE_DEFER.equals( fastMode ) )
+        {
+            throw new IllegalArgumentException( "Illegal value '" + fastMode + "' for fastMode. Allowed values are '"
+                    + FAST_MODE_BACKGROUND + "', '" + FAST_MODE_AT_END + "' and '" + FAST_MODE_DEFER + "'." );
+        }
+
+        Cleaner cleaner = new Cleaner( session, getLog(), isVerbose(), fastDir, fastMode );
 
         try
         {


=====================================
src/main/java/org/apache/maven/plugins/clean/Cleaner.java
=====================================
@@ -21,10 +21,23 @@ package org.apache.maven.plugins.clean;
 
 import java.io.File;
 import java.io.IOException;
-
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayDeque;
+import java.util.Deque;
+
+import org.apache.maven.execution.ExecutionListener;
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.shared.utils.Os;
-import org.apache.maven.shared.utils.io.FileUtils;
+import org.eclipse.aether.SessionData;
+
+import static org.apache.maven.plugins.clean.CleanMojo.FAST_MODE_BACKGROUND;
+import static org.apache.maven.plugins.clean.CleanMojo.FAST_MODE_DEFER;
 
 /**
  * Cleans directories.
@@ -36,6 +49,13 @@ class Cleaner
 
     private static final boolean ON_WINDOWS = Os.isFamily( Os.FAMILY_WINDOWS );
 
+    private static final String LAST_DIRECTORY_TO_DELETE = Cleaner.class.getName() + ".lastDirectoryToDelete";
+
+    /**
+     * The maven session.  This is typically non-null in a real run, but it can be during unit tests.
+     */
+    private final MavenSession session;
+
     private final Logger logDebug;
 
     private final Logger logInfo;
@@ -44,39 +64,29 @@ class Cleaner
 
     private final Logger logWarn;
 
+    private final File fastDir;
+
+    private final String fastMode;
+
     /**
      * Creates a new cleaner.
-     * 
      * @param log The logger to use, may be <code>null</code> to disable logging.
      * @param verbose Whether to perform verbose logging.
+     * @param fastMode The fast deletion mode
      */
-    Cleaner( final Log log, boolean verbose )
+    Cleaner( MavenSession session, final Log log, boolean verbose, File fastDir, String fastMode )
     {
-        logDebug = ( log == null || !log.isDebugEnabled() ) ? null : new Logger()
-        {
-            public void log( CharSequence message )
-            {
-                log.debug( message );
-            }
-        };
+        logDebug = ( log == null || !log.isDebugEnabled() ) ? null : log::debug;
 
-        logInfo = ( log == null || !log.isInfoEnabled() ) ? null : new Logger()
-        {
-            public void log( CharSequence message )
-            {
-                log.info( message );
-            }
-        };
+        logInfo = ( log == null || !log.isInfoEnabled() ) ? null : log::info;
 
-        logWarn = ( log == null || !log.isWarnEnabled() ) ? null : new Logger()
-        {
-            public void log( CharSequence message )
-            {
-                log.warn( message );
-            }
-        };
+        logWarn = ( log == null || !log.isWarnEnabled() ) ? null : log::warn;
 
         logVerbose = verbose ? logInfo : logDebug;
+
+        this.session = session;
+        this.fastDir = fastDir;
+        this.fastMode = fastMode;
     }
 
     /**
@@ -115,9 +125,96 @@ class Cleaner
 
         File file = followSymlinks ? basedir : basedir.getCanonicalFile();
 
+        if ( selector == null && !followSymlinks && fastDir != null && session != null )
+        {
+            // If anything wrong happens, we'll just use the usual deletion mechanism
+            if ( fastDelete( file ) )
+            {
+                return;
+            }
+        }
+
         delete( file, "", selector, followSymlinks, failOnError, retryOnError );
     }
 
+    private boolean fastDelete( File baseDirFile )
+    {
+        Path baseDir = baseDirFile.toPath();
+        Path fastDir = this.fastDir.toPath();
+        // Handle the case where we use ${maven.multiModuleProjectDirectory}/target/.clean for example
+        if ( fastDir.toAbsolutePath().startsWith( baseDir.toAbsolutePath() ) )
+        {
+            try
+            {
+                String prefix = baseDir.getFileName().toString() + ".";
+                Path tmpDir = Files.createTempDirectory( baseDir.getParent(), prefix );
+                try
+                {
+                    Files.move( baseDir, tmpDir, StandardCopyOption.REPLACE_EXISTING );
+                    if ( session != null )
+                    {
+                        session.getRepositorySession().getData().set( LAST_DIRECTORY_TO_DELETE, baseDir.toFile() );
+                    }
+                    baseDir = tmpDir;
+                }
+                catch ( IOException e )
+                {
+                    Files.delete( tmpDir );
+                    throw e;
+                }
+            }
+            catch ( IOException e )
+            {
+                if ( logDebug != null )
+                {
+                    // TODO: this Logger interface cannot log exceptions and needs refactoring
+                    logDebug.log( "Unable to fast delete directory: " + e );
+                }
+                return false;
+            }
+        }
+        // Create fastDir and the needed parents if needed
+        try
+        {
+            if ( !Files.isDirectory( fastDir ) )
+            {
+                Files.createDirectories( fastDir );
+            }
+        }
+        catch ( IOException e )
+        {
+            if ( logDebug != null )
+            {
+                // TODO: this Logger interface cannot log exceptions and needs refactoring
+                logDebug.log( "Unable to fast delete directory as the path "
+                        + fastDir + " does not point to a directory or cannot be created: " + e );
+            }
+            return false;
+        }
+
+        try
+        {
+            Path tmpDir = Files.createTempDirectory( fastDir, "" );
+            Path dstDir = tmpDir.resolve( baseDir.getFileName() );
+            // Note that by specifying the ATOMIC_MOVE, we expect an exception to be thrown
+            // if the path leads to a directory on another mountpoint.  If this is the case
+            // or any other exception occurs, an exception will be thrown in which case
+            // the method will return false and the usual deletion will be performed.
+            Files.move( baseDir, dstDir, StandardCopyOption.ATOMIC_MOVE );
+            BackgroundCleaner.delete( this, tmpDir.toFile(), fastMode );
+            return true;
+        }
+        catch ( IOException e )
+        {
+            if ( logDebug != null )
+            {
+                // TODO: this Logger interface cannot log exceptions and needs refactoring
+                logDebug.log( "Unable to fast delete directory: " + e );
+            }
+            return false;
+        }
+    }
+
     /**
      * Deletes the specified file or directory.
      * 
@@ -145,7 +242,7 @@ class Cleaner
         {
             if ( selector == null || selector.couldHoldSelected( pathname ) )
             {
-                final boolean isSymlink = FileUtils.isSymbolicLink( file );
+                final boolean isSymlink = Files.isSymbolicLink( file.toPath() );
                 File canonical = followSymlinks ? file : file.getCanonicalFile();
                 if ( followSymlinks || !isSymlink )
                 {
@@ -286,4 +383,200 @@ class Cleaner
 
     }
 
+    private static class BackgroundCleaner extends Thread
+    {
+
+        private static BackgroundCleaner instance;
+
+        private final Deque<File> filesToDelete = new ArrayDeque<>();
+
+        private final Cleaner cleaner;
+
+        private final String fastMode;
+
+        private static final int NEW = 0;
+        private static final int RUNNING = 1;
+        private static final int STOPPED = 2;
+
+        private int status = NEW;
+
+        public static void delete( Cleaner cleaner, File dir, String fastMode )
+        {
+            synchronized ( BackgroundCleaner.class )
+            {
+                if ( instance == null || !instance.doDelete( dir ) )
+                {
+                    instance = new BackgroundCleaner( cleaner, dir, fastMode );
+                }
+            }
+        }
+
+        static void sessionEnd()
+        {
+            synchronized ( BackgroundCleaner.class )
+            {
+                if ( instance != null )
+                {
+                    instance.doSessionEnd();
+                }
+            }
+        }
+
+        private BackgroundCleaner( Cleaner cleaner, File dir, String fastMode )
+        {
+            super( "mvn-background-cleaner" );
+            this.cleaner = cleaner;
+            this.fastMode = fastMode;
+            init( cleaner.fastDir, dir );
+        }
+
+        public void run()
+        {
+            while ( true )
+            {
+                File basedir = pollNext();
+                if ( basedir == null )
+                {
+                    break;
+                }
+                try
+                {
+                    cleaner.delete( basedir, "", null, false, false, true );
+                }
+                catch ( IOException e )
+                {
+                    // do not display errors
+                }
+            }
+        }
+
+        synchronized void init( File fastDir, File dir )
+        {
+            if ( fastDir.isDirectory() )
+            {
+                File[] children = fastDir.listFiles();
+                if ( children != null && children.length > 0 )
+                {
+                    for ( File child : children )
+                    {
+                        doDelete( child );
+                    }
+                }
+            }
+            doDelete( dir );
+        }
+
+        synchronized File pollNext()
+        {
+            File basedir = filesToDelete.poll();
+            if ( basedir == null )
+            {
+                if ( cleaner.session != null )
+                {
+                    SessionData data = cleaner.session.getRepositorySession().getData();
+                    File lastDir = ( File ) data.get( LAST_DIRECTORY_TO_DELETE );
+                    if ( lastDir != null )
+                    {
+                        data.set( LAST_DIRECTORY_TO_DELETE, null );
+                        return lastDir;
+                    }
+                }
+                status = STOPPED;
+                notifyAll();
+            }
+            return basedir;
+        }
+
+        synchronized boolean doDelete( File dir )
+        {
+            if ( status == STOPPED )
+            {
+                return false;
+            }
+            filesToDelete.add( dir );
+            if ( status == NEW && FAST_MODE_BACKGROUND.equals( fastMode ) )
+            {
+                status = RUNNING;
+                notifyAll();
+                start();
+            }
+            wrapExecutionListener();
+            return true;
+        }
+
+        /**
+         * If this has not been done already, we wrap the ExecutionListener inside a proxy
+         * which simply delegates call to the previous listener.  When the session ends, it will
+         * also call {@link BackgroundCleaner#sessionEnd()}.
+         * There's no clean API to do that properly as this is a very unusual use case for a plugin
+         * to outlive its main execution.
+         */
+        private void wrapExecutionListener()
+        {
+            ExecutionListener executionListener = cleaner.session.getRequest().getExecutionListener();
+            if ( executionListener == null
+                    || !Proxy.isProxyClass( executionListener.getClass() )
+                    || !( Proxy.getInvocationHandler( executionListener ) instanceof SpyInvocationHandler ) )
+            {
+                ExecutionListener listener = ( ExecutionListener ) Proxy.newProxyInstance(
+                        ExecutionListener.class.getClassLoader(),
+                        new Class[] { ExecutionListener.class },
+                        new SpyInvocationHandler( executionListener ) );
+                cleaner.session.getRequest().setExecutionListener( listener );
+            }
+        }
+
+        synchronized void doSessionEnd()
+        {
+            if ( status != STOPPED )
+            {
+                if ( status == NEW )
+                {
+                    start();
+                }
+                if ( !FAST_MODE_DEFER.equals( fastMode ) )
+                {
+                    try
+                    {
+                        cleaner.logInfo.log( "Waiting for background file deletion" );
+                        while ( status != STOPPED )
+                        {
+                            wait();
+                        }
+                    }
+                    catch ( InterruptedException e )
+                    {
+                        // ignore
+                    }
+                }
+            }
+        }
+
+    }
+
+    static class SpyInvocationHandler implements InvocationHandler
+    {
+        private final ExecutionListener delegate;
+
+        SpyInvocationHandler( ExecutionListener delegate )
+        {
+            this.delegate = delegate;
+        }
+
+        @Override
+        public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
+        {
+            if ( "sessionEnded".equals( method.getName() ) )
+            {
+                BackgroundCleaner.sessionEnd();
+            }
+            if ( delegate != null )
+            {
+                return method.invoke( delegate, args );
+            }
+            return null;
+        }
+
+    }
+
 }


=====================================
src/main/java/org/apache/maven/plugins/clean/Fileset.java
=====================================
@@ -29,7 +29,6 @@ import java.util.Arrays;
  * <code>"file-set: <I>[directory]</I> (included: <I>[included files]</I>,
  * excluded: <I>[excluded files]</I>)"</code>
  *
- * @version $Id$
  * @since 2.1
  */
 public class Fileset


=====================================
src/site/apt/examples/delete_additional_files.apt.vm
=====================================
@@ -4,7 +4,7 @@
  Mike Perham
  <mperham at apache.org>
  ------
- November 2007
+ 2007-11-14
  ------
 
 ~~ Licensed to the Apache Software Foundation (ASF) under one


=====================================
src/site/apt/examples/ignoring-errors.apt.vm
=====================================
@@ -3,7 +3,7 @@
  ------
  Vincent Siveton
  ------
- 13 November 2007
+ 2007-11-13
  ------
 
 ~~ Licensed to the Apache Software Foundation (ASF) under one


=====================================
src/site/apt/examples/skipping-clean.apt.vm
=====================================
@@ -3,7 +3,7 @@
  ------
  Vincent Siveton
  ------
- 13 November 2007
+ 2007-11-13
  ------
 
 ~~ Licensed to the Apache Software Foundation (ASF) under one


=====================================
src/site/apt/index.apt.vm
=====================================
@@ -48,17 +48,17 @@ ${project.name}
   specific use cases are described in the examples given below.
 
   In case you still have questions regarding the plugin's usage, please have a look at the {{{./faq.html}FAQ}} and feel
-  free to contact the {{{./mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could
+  free to contact the {{{./mailing-lists.html}user mailing list}}. The posts to the mailing list are archived and could
   already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching
-  the {{{./mail-lists.html}mail archive}}.
+  the {{{./mailing-lists.html}mail archive}}.
 
   If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our
-  {{{./issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your
+  {{{./issue-management.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your
   concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason,
   entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated.
   Of course, patches are welcome, too. Contributors can check out the project from our
-  {{{./source-repository.html}source repository}} and will find supplementary information in the
-  {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}.
+  {{{./scm.html}source repository}} and will find supplementary information in the
+  {{{https://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}.
 
 * Examples
 


=====================================
src/site/apt/usage.apt.vm
=====================================
@@ -3,7 +3,8 @@
  ------
  Edwin Punzalan
  ------
- June 29th, 2006
+ 2006-06-29
+ ------
 
 ~~ Licensed to the Apache Software Foundation (ASF) under one
 ~~ or more contributor license agreements.  See the NOTICE file


=====================================
src/site/site.xml
=====================================
@@ -19,9 +19,13 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-<project xmlns="http://maven.apache.org/DECORATION/1.0.0"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
+<project xmlns="http://maven.apache.org/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 https://maven.apache.org/xsd/decoration-1.8.0.xsd">
+  <skin>
+    <groupId>org.apache.maven.skins</groupId>
+    <artifactId>maven-fluido-skin</artifactId>
+    <version>1.9</version>
+  </skin>
   <body>
     <menu name="Overview">
       <item name="Introduction" href="index.html"/>
@@ -29,7 +33,7 @@ under the License.
       <item name="Usage" href="usage.html"/>
       <item name="FAQ" href="faq.html"/>
       <!-- According to https://issues.apache.org/jira/browse/MNGSITE-152 -->
-      <item name="License" href="http://www.apache.org/licenses/"/>
+      <item name="License" href="https://www.apache.org/licenses/"/>
       <item name="Download" href="download.html"/>
     </menu>
     <menu name="Examples">


=====================================
src/site/xdoc/download.xml.vm
=====================================
@@ -34,7 +34,7 @@ under the License.
 
       <p>In order to guard against corrupted downloads/installations, it is highly recommended to
       <a href="http://www.apache.org/dev/release-signing#verifying-signature">verify the signature</a>
-      of the release bundles against the public <a href="http://www.apache.org/dist/maven/KEYS">KEYS</a> used by the Apache Maven
+      of the release bundles against the public <a href="https://www.apache.org/dist/maven/KEYS">KEYS</a> used by the Apache Maven
       developers.</p>
 
       <p>${project.name} is distributed under the <a href="http://www.apache.org/licenses/">Apache License, version 2.0</a>.</p>
@@ -108,8 +108,8 @@ under the License.
           <tr>
             <td>${project.name} ${project.version} (Source zip)</td>
             <td><a href="[preferred]maven/plugins/${project.artifactId}-${project.version}-source-release.zip">maven/plugins/${project.artifactId}-${project.version}-source-release.zip</a></td>
-            <td><a href="http://www.apache.org/dist/maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha1">maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha1</a></td>
-            <td><a href="http://www.apache.org/dist/maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc">maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc</a></td>
+            <td><a href="https://www.apache.org/dist/maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha512">maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha512</a></td>
+            <td><a href="https://www.apache.org/dist/maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc">maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc</a></td>
           </tr>
         </tbody>
       </table>


=====================================
src/test/java/org/apache/maven/plugins/clean/CleanMojoTest.java
=====================================
@@ -19,39 +19,24 @@ package org.apache.maven.plugins.clean;
  * under the License.
  */
 
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+
 import java.io.File;
 import java.io.RandomAccessFile;
 import java.nio.channels.FileChannel;
 import java.nio.channels.FileLock;
 
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.plugins.clean.CleanMojo;
-import org.codehaus.plexus.util.FileUtils;
+import static org.apache.commons.io.FileUtils.copyDirectory;
 
 /**
  * Test the clean mojo.
  *
  * @author <a href="mailto:vincent.siveton at gmail.com">Vincent Siveton</a>
- * @version $Id$
  */
 public class CleanMojoTest
     extends AbstractMojoTestCase
 {
-    /** {@inheritDoc} */
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-    }
-
-    /** {@inheritDoc} */
-    protected void tearDown()
-        throws Exception
-    {
-        super.tearDown();
-    }
-
     /**
      * Tests the simple removal of directories
      *
@@ -63,8 +48,8 @@ public class CleanMojoTest
         String pluginPom = getBasedir() + "/src/test/resources/unit/basic-clean-test/plugin-pom.xml";
 
         // safety
-        FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/basic-clean-test" ),
-                                 new File( getBasedir(), "target/test-classes/unit/basic-clean-test" ), null, "**/.svn,**/.svn/**" );
+        copyDirectory( new File( getBasedir(), "src/test/resources/unit/basic-clean-test" ),
+                                 new File( getBasedir(), "target/test-classes/unit/basic-clean-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom );
         assertNotNull( mojo );
@@ -90,8 +75,8 @@ public class CleanMojoTest
         String pluginPom = getBasedir() + "/src/test/resources/unit/nested-clean-test/plugin-pom.xml";
 
         // safety
-        FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/nested-clean-test" ),
-                                 new File( getBasedir(), "target/test-classes/unit/nested-clean-test" ), null, "**/.svn,**/.svn/**" );
+        copyDirectory( new File( getBasedir(), "src/test/resources/unit/nested-clean-test" ),
+                                 new File( getBasedir(), "target/test-classes/unit/nested-clean-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom );
         assertNotNull( mojo );
@@ -115,8 +100,8 @@ public class CleanMojoTest
         String pluginPom = getBasedir() + "/src/test/resources/unit/empty-clean-test/plugin-pom.xml";
 
         // safety
-        FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/empty-clean-test" ),
-                                 new File( getBasedir(), "target/test-classes/unit/empty-clean-test" ), null, "**/.svn,**/.svn/**" );
+        copyDirectory( new File( getBasedir(), "src/test/resources/unit/empty-clean-test" ),
+                                 new File( getBasedir(), "target/test-classes/unit/empty-clean-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupEmptyMojo( "clean", pluginPom );
         assertNotNull( mojo );
@@ -143,8 +128,8 @@ public class CleanMojoTest
         String pluginPom = getBasedir() + "/src/test/resources/unit/fileset-clean-test/plugin-pom.xml";
 
         // safety
-        FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/fileset-clean-test" ),
-                                 new File( getBasedir(), "target/test-classes/unit/fileset-clean-test" ), null, "**/.svn,**/.svn/**" );
+        copyDirectory( new File( getBasedir(), "src/test/resources/unit/fileset-clean-test" ),
+                                 new File( getBasedir(), "target/test-classes/unit/fileset-clean-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom );
         assertNotNull( mojo );
@@ -179,8 +164,8 @@ public class CleanMojoTest
         String pluginPom = getBasedir() + "/src/test/resources/unit/invalid-directory-test/plugin-pom.xml";
 
         // safety
-        FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/invalid-directory-test" ),
-                                 new File( getBasedir(), "target/test-classes/unit/invalid-directory-test" ), null, "**/.svn,**/.svn/**" );
+        copyDirectory( new File( getBasedir(), "src/test/resources/unit/invalid-directory-test" ),
+                                 new File( getBasedir(), "target/test-classes/unit/invalid-directory-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom );
         assertNotNull( mojo );
@@ -208,8 +193,8 @@ public class CleanMojoTest
         String pluginPom = getBasedir() + "/src/test/resources/unit/missing-directory-test/plugin-pom.xml";
 
         // safety
-        FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/missing-directory-test" ),
-                                 new File( getBasedir(), "target/test-classes/unit/missing-directory-test" ), null, "**/.svn,**/.svn/**" );
+        copyDirectory( new File( getBasedir(), "src/test/resources/unit/missing-directory-test" ),
+                                 new File( getBasedir(), "target/test-classes/unit/missing-directory-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom );
         assertNotNull( mojo );
@@ -239,40 +224,23 @@ public class CleanMojoTest
         String pluginPom = getBasedir() + "/src/test/resources/unit/locked-file-test/plugin-pom.xml";
 
         // safety
-        FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/locked-file-test" ),
-                                 new File( getBasedir(), "target/test-classes/unit/locked-file-test" ), null, "**/.svn,**/.svn/**" );
+        copyDirectory( new File( getBasedir(), "src/test/resources/unit/locked-file-test" ),
+                                 new File( getBasedir(), "target/test-classes/unit/locked-file-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom );
         assertNotNull( mojo );
 
         File f = new File( getBasedir(), "target/test-classes/unit/locked-file-test/buildDirectory/file.txt" );
-        FileChannel channel = null;
-        FileLock lock = null;
-        try
+        try ( FileChannel channel = new RandomAccessFile( f, "rw" ).getChannel();
+              FileLock ignored = channel.lock() )
         {
-            channel = new RandomAccessFile( f, "rw" ).getChannel();
-            lock = channel.lock();
-
             mojo.execute();
-
             fail( "Should fail to delete a file that is locked" );
         }
         catch ( MojoExecutionException expected )
         {
             assertTrue( true );
         }
-        finally
-        {
-            if ( lock != null )
-            {
-                lock.release();
-            }
-
-            if ( channel != null )
-            {
-                channel.close();
-            }
-        }
     }
 
     /**
@@ -295,41 +263,24 @@ public class CleanMojoTest
         String pluginPom = getBasedir() + "/src/test/resources/unit/locked-file-test/plugin-pom.xml";
 
         // safety
-        FileUtils.copyDirectory( new File( getBasedir(), "src/test/resources/unit/locked-file-test" ),
-                                 new File( getBasedir(), "target/test-classes/unit/locked-file-test" ), null, "**/.svn,**/.svn/**" );
+        copyDirectory( new File( getBasedir(), "src/test/resources/unit/locked-file-test" ),
+                                 new File( getBasedir(), "target/test-classes/unit/locked-file-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom );
         setVariableValueToObject( mojo, "failOnError", Boolean.FALSE );
         assertNotNull( mojo );
 
         File f = new File( getBasedir(), "target/test-classes/unit/locked-file-test/buildDirectory/file.txt" );
-        FileChannel channel = null;
-        FileLock lock = null;
-        try
+        try ( FileChannel channel = new RandomAccessFile( f, "rw" ).getChannel();
+              FileLock ignored = channel.lock())
         {
-            channel = new RandomAccessFile( f, "rw" ).getChannel();
-            lock = channel.lock();
-
             mojo.execute();
-
             assertTrue( true );
         }
         catch ( MojoExecutionException expected )
         {
             fail( "Should display a warning when deleting a file that is locked" );
         }
-        finally
-        {
-            if ( lock != null )
-            {
-                lock.release();
-            }
-
-            if ( channel != null )
-            {
-                channel.close();
-            }
-        }
     }
 
     /**
@@ -338,7 +289,7 @@ public class CleanMojoTest
      */
     private boolean checkExists( String dir )
     {
-        return FileUtils.fileExists( new File( dir ).getAbsolutePath() );
+        return new File( new File( dir ).getAbsolutePath() ).exists();
     }
 
     /**
@@ -347,6 +298,7 @@ public class CleanMojoTest
      */
     private boolean checkEmpty( String dir )
     {
-        return new File( dir ).listFiles().length == 0;
+        File[] files = new File( dir ).listFiles();
+        return files == null || files.length == 0;
     }
 }


=====================================
src/test/java/org/apache/maven/plugins/clean/Utils.java
=====================================
@@ -23,7 +23,6 @@ import java.io.File;
 
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
-import org.codehaus.plexus.util.cli.StreamConsumer;
 
 /**
  * Testing helpers for the IT scripts.
@@ -49,19 +48,7 @@ public class Utils
             cli.createArg().setValue( "-s" );
             cli.createArg().setFile( target );
             cli.createArg().setFile( link );
-            int code = CommandLineUtils.executeCommandLine( cli, new StreamConsumer()
-            {
-                public void consumeLine( String line )
-                {
-                    System.out.println( line );
-                }
-            }, new StreamConsumer()
-            {
-                public void consumeLine( String line )
-                {
-                    System.err.println( line );
-                }
-            } );
+            int code = CommandLineUtils.executeCommandLine( cli, System.out::println, System.err::println );
             return 0 == code;
         }
         catch ( Exception e )



View it on GitLab: https://salsa.debian.org/java-team/maven-clean-plugin/-/compare/d8c3f23178ca67926a1b5a93d8f34ba77d331566...f48d816cf9ba5353cbffe1720c8694882e751e9c

-- 
View it on GitLab: https://salsa.debian.org/java-team/maven-clean-plugin/-/compare/d8c3f23178ca67926a1b5a93d8f34ba77d331566...f48d816cf9ba5353cbffe1720c8694882e751e9c
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20220927/8bc4febf/attachment.htm>


More information about the pkg-java-commits mailing list