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/18 22:48:39 UTC

[maven-clean-plugin] branch fix created (now 07bb13f)

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.


      at 07bb13f  (doc) quick fixes

This branch includes the following new commits:

     new 07bb13f  (doc) quick fixes

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.



[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 07bb13f65e80e51ae2dd4723f55b0068b5151864
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  | 46 ++++------------------
 3 files changed, 10 insertions(+), 40 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..bbf0ba8 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.codehaus.plexus.util.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
      *
@@ -245,15 +230,11 @@ public class CleanMojoTest
         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() )
         {
-            channel = new RandomAccessFile( f, "rw" ).getChannel();
             lock = channel.lock();
-
             mojo.execute();
-
             fail( "Should fail to delete a file that is locked" );
         }
         catch ( MojoExecutionException expected )
@@ -267,10 +248,6 @@ public class CleanMojoTest
                 lock.release();
             }
 
-            if ( channel != null )
-            {
-                channel.close();
-            }
         }
     }
 
@@ -302,15 +279,11 @@ public class CleanMojoTest
         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() )
         {
-            channel = new RandomAccessFile( f, "rw" ).getChannel();
             lock = channel.lock();
-
             mojo.execute();
-
             assertTrue( true );
         }
         catch ( MojoExecutionException expected )
@@ -324,10 +297,6 @@ public class CleanMojoTest
                 lock.release();
             }
 
-            if ( channel != null )
-            {
-                channel.close();
-            }
         }
     }
 
@@ -346,6 +315,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;
     }
 }