You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/01/23 00:12:41 UTC

[maven-clean-plugin] branch fix updated (07bb13f -> 2a17f03)

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a change to branch fix
in repository https://gitbox.apache.org/repos/asf/maven-clean-plugin.git.


 discard 07bb13f  (doc) quick fixes
     add 7ce9664  [MCLEAN-92] Exclude plexus-container-default
     new 2a17f03  (doc) quick fixes

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (07bb13f)
            \
             N -- N -- N   refs/heads/fix (2a17f03)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml                                            |  6 +++
 .../apache/maven/plugins/clean/CleanMojoTest.java  | 44 +++++++---------------
 2 files changed, 19 insertions(+), 31 deletions(-)


[maven-clean-plugin] 01/01: (doc) quick fixes

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch fix
in repository https://gitbox.apache.org/repos/asf/maven-clean-plugin.git

commit 2a17f032dad52503cafcbce164ba70967dbd9926
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Mon Jan 18 23:38:27 2021 +0100

    (doc) quick fixes
---
 src/site/apt/index.apt.vm                          |  2 +-
 src/site/site.xml                                  |  2 +-
 .../apache/maven/plugins/clean/CleanMojoTest.java  | 84 +++++-----------------
 3 files changed, 20 insertions(+), 68 deletions(-)

diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm
index 8363b29..7958c0d 100644
--- a/src/site/apt/index.apt.vm
+++ b/src/site/apt/index.apt.vm
@@ -58,7 +58,7 @@ ${project.name}
   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
   {{{./scm.html}source repository}} and will find supplementary information in the
-  {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}.
+  {{{https://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}.
 
 * Examples
 
diff --git a/src/site/site.xml b/src/site/site.xml
index b32c257..0988688 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -29,7 +29,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">
diff --git a/src/test/java/org/apache/maven/plugins/clean/CleanMojoTest.java b/src/test/java/org/apache/maven/plugins/clean/CleanMojoTest.java
index 3083cce..9bf3b63 100644
--- a/src/test/java/org/apache/maven/plugins/clean/CleanMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/clean/CleanMojoTest.java
@@ -19,16 +19,15 @@ package org.apache.maven.plugins.clean;
  * under the License.
  */
 
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.shared.utils.io.FileUtils;
+
 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;
-
 /**
  * Test the clean mojo.
  *
@@ -37,20 +36,6 @@ import org.codehaus.plexus.util.FileUtils;
 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,7 +48,7 @@ public class CleanMojoTest
 
         // 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/**" );
+                                 new File( getBasedir(), "target/test-classes/unit/basic-clean-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom );
         assertNotNull( mojo );
@@ -90,7 +75,7 @@ public class CleanMojoTest
 
         // 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/**" );
+                                 new File( getBasedir(), "target/test-classes/unit/nested-clean-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom );
         assertNotNull( mojo );
@@ -115,7 +100,7 @@ public class CleanMojoTest
 
         // 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/**" );
+                                 new File( getBasedir(), "target/test-classes/unit/empty-clean-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupEmptyMojo( "clean", pluginPom );
         assertNotNull( mojo );
@@ -143,7 +128,7 @@ public class CleanMojoTest
 
         // 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/**" );
+                                 new File( getBasedir(), "target/test-classes/unit/fileset-clean-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom );
         assertNotNull( mojo );
@@ -179,7 +164,7 @@ public class CleanMojoTest
 
         // 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/**" );
+                                 new File( getBasedir(), "target/test-classes/unit/invalid-directory-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom );
         assertNotNull( mojo );
@@ -208,7 +193,7 @@ public class CleanMojoTest
 
         // 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/**" );
+                                 new File( getBasedir(), "target/test-classes/unit/missing-directory-test" ) );
 
         CleanMojo mojo = (CleanMojo) lookupMojo( "clean", pluginPom );
         assertNotNull( mojo );
@@ -239,39 +224,22 @@ public class CleanMojoTest
 
         // 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/**" );
+                                 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,40 +263,23 @@ public class CleanMojoTest
 
         // 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/**" );
+                                 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();
-            }
-        }
     }
 
     /**
@@ -346,6 +297,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;
     }
 }