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

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

commit 9b72f8fb6ee2061d4a26c9a5730d47978a857a7b
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Wed Nov 25 19:47:28 2026 +0000

    Modernize Groovy IT scripts
    
    See https://github.com/apache/maven-invoker-plugin/issues/811.
---
 src/it/dangling-symlinks/setup.groovy            |  41 ++++-----
 src/it/dangling-symlinks/verify.groovy           |  26 ++----
 src/it/default/setup.groovy                      |  26 ++----
 src/it/default/verify.groovy                     |  26 ++----
 src/it/exclude-default-dirs/verify.groovy        |  68 +++++---------
 src/it/file-sets-absolute-paths/verify.groovy    |  34 ++-----
 src/it/file-sets-includes-excludes/verify.groovy | 110 ++++++++++-------------
 src/it/file-sets-relative-paths/verify.groovy    |  64 +++++--------
 src/it/only-test-clean/setup.groovy              |  26 ++----
 src/it/only-test-clean/verify.groovy             |  43 ++-------
 src/it/read-only/setup.groovy                    |  18 +---
 src/it/read-only/verify.groovy                   |   8 +-
 src/it/special-characters/verify.groovy          |  27 ++----
 src/it/symlink-dont-follow/verify.groovy         |  30 +++----
 14 files changed, 164 insertions(+), 383 deletions(-)

diff --git a/src/it/dangling-symlinks/setup.groovy 
b/src/it/dangling-symlinks/setup.groovy
index e55b6ae..8072cb9 100644
--- a/src/it/dangling-symlinks/setup.groovy
+++ b/src/it/dangling-symlinks/setup.groovy
@@ -17,33 +17,24 @@
  * under the License.
  */
 
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.regex.*;
-import org.apache.maven.plugins.clean.*;
+import java.nio.file.*
+import java.nio.file.attribute.*
+import java.util.jar.*
+import java.util.regex.*
+import org.apache.maven.plugins.clean.*
 
-try
-{
-    Path targetDir = basedir.toPath().resolve( "target" );
-    Path link = targetDir.resolve( "link" );
-    Path target = targetDir.resolve( "link-target.txt" );
-
-    System.out.println( "Creating symlink " + link + " -> " + target );
-    Files.createSymbolicLink( link, target, new FileAttribute[0] );
-    if ( !Files.exists( link, new LinkOption[0] ) )
-    {
-        System.out.println( "FAILURE, platform does not support symlinks, 
skipping test." );
-    }
+Path targetDir = basedir.toPath().resolve( "target" )
+Path link = targetDir.resolve( "link" )
+Path target = targetDir.resolve( "link-target.txt" )
 
-    System.out.println( "Deleting symlink target " + target );
-    Files.delete( target );
-}
-catch( Throwable t )
+System.out.println( "Creating symlink " + link + " -> " + target )
+Files.createSymbolicLink( link, target, new FileAttribute[0] )
+if ( !Files.exists( link, new LinkOption[0] ) )
 {
-    t.printStackTrace();
-    return false;
+    System.out.println( "FAILURE, platform does not support symlinks, skipping 
test." )
 }
 
-return true;
+System.out.println( "Deleting symlink target " + target )
+Files.delete( target )
+
+return true
diff --git a/src/it/dangling-symlinks/verify.groovy 
b/src/it/dangling-symlinks/verify.groovy
index 9814365..b7ceb73 100644
--- a/src/it/dangling-symlinks/verify.groovy
+++ b/src/it/dangling-symlinks/verify.groovy
@@ -17,25 +17,9 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.regex.*;
+import java.util.jar.*
+import java.util.regex.*
 
-try
-{
-    File targetDir = new File( basedir, "target" );
-    System.out.println( "Checking for absence of " + targetDir );
-    if ( targetDir.exists() )
-    {
-        System.out.println( "FAILURE!" );
-        return false;
-    }
-}
-catch( Throwable t )
-{
-    t.printStackTrace();
-    return false;
-}
-
-return true;
+File targetDir = new File( basedir, "target" )
+System.out.println( "Checking for absence of " + targetDir )
+assert !targetDir.exists()
diff --git a/src/it/default/setup.groovy b/src/it/default/setup.groovy
index 4cf09f7..a2186fc 100644
--- a/src/it/default/setup.groovy
+++ b/src/it/default/setup.groovy
@@ -17,25 +17,9 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.regex.*;
+import java.util.jar.*
+import java.util.regex.*
 
-try
-{
-    File targetDir = new File( basedir, "target" );
-    System.out.println( "Checking for existence of " + targetDir );
-    if ( !targetDir.isDirectory() )
-    {
-        System.out.println( "FAILURE!" );
-        return false;
-    }
-}
-catch( Throwable t )
-{
-    t.printStackTrace();
-    return false;
-}
-
-return true;
+File targetDir = new File( basedir, "target" )
+System.out.println( "Checking for existence of " + targetDir )
+assert targetDir.isDirectory()
diff --git a/src/it/default/verify.groovy b/src/it/default/verify.groovy
index 9814365..b7ceb73 100644
--- a/src/it/default/verify.groovy
+++ b/src/it/default/verify.groovy
@@ -17,25 +17,9 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.regex.*;
+import java.util.jar.*
+import java.util.regex.*
 
-try
-{
-    File targetDir = new File( basedir, "target" );
-    System.out.println( "Checking for absence of " + targetDir );
-    if ( targetDir.exists() )
-    {
-        System.out.println( "FAILURE!" );
-        return false;
-    }
-}
-catch( Throwable t )
-{
-    t.printStackTrace();
-    return false;
-}
-
-return true;
+File targetDir = new File( basedir, "target" )
+System.out.println( "Checking for absence of " + targetDir )
+assert !targetDir.exists()
diff --git a/src/it/exclude-default-dirs/verify.groovy 
b/src/it/exclude-default-dirs/verify.groovy
index 979af19..b9c4803 100644
--- a/src/it/exclude-default-dirs/verify.groovy
+++ b/src/it/exclude-default-dirs/verify.groovy
@@ -17,52 +17,32 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.regex.*;
+import java.util.jar.*
+import java.util.regex.*
 
-try
+String[] expected = [
+    "target",
+    "target/test-1.0-SNAPSHOT.jar",
+    "target/classes",
+    "target/classes/main.properties",
+    "target/test-classes",
+    "target/test-classes/test.properties",
+    "target/site",
+    "target/site/index.html",
+]
+for ( String path : expected )
 {
-    String[] expected = [
-        "target",
-        "target/test-1.0-SNAPSHOT.jar",
-        "target/classes",
-        "target/classes/main.properties",
-        "target/test-classes",
-        "target/test-classes/test.properties",
-        "target/site",
-        "target/site/index.html",
-    ];
-    for ( String path : expected )
-    {
-        File file = new File( basedir, path );
-        System.out.println( "Checking for existence of " + file );
-        if ( !file.exists() )
-        {
-            System.out.println( "FAILURE!" );
-            return false;
-        }
-    }
-
-    String[] unexpected = [
-        "delete-me",
-    ];
-    for ( String path : unexpected )
-    {
-        File file = new File( basedir, path );
-        System.out.println( "Checking for absence of " + file );
-        if ( file.exists() )
-        {
-            System.out.println( "FAILURE!" );
-            return false;
-        }
-    }
+    File file = new File( basedir, path )
+    System.out.println( "Checking for existence of " + file )
+    assert file.exists()
 }
-catch( Throwable t )
+
+String[] unexpected = [
+    "delete-me",
+]
+for ( String path : unexpected )
 {
-    t.printStackTrace();
-    return false;
+    File file = new File( basedir, path )
+    System.out.println( "Checking for absence of " + file )
+    assert !file.exists()
 }
-
-return true;
diff --git a/src/it/file-sets-absolute-paths/verify.groovy 
b/src/it/file-sets-absolute-paths/verify.groovy
index fb7c62c..551a1c2 100644
--- a/src/it/file-sets-absolute-paths/verify.groovy
+++ b/src/it/file-sets-absolute-paths/verify.groovy
@@ -17,31 +17,15 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.regex.*;
+import java.util.jar.*
+import java.util.regex.*
 
-try
+String[] unexpected = [
+    "delete-me",
+]
+for ( String path : unexpected )
 {
-    String[] unexpected = [
-        "delete-me",
-    ];
-    for ( String path : unexpected )
-    {
-        File file = new File( basedir, path );
-        System.out.println( "Checking for absence of " + file );
-        if ( file.exists() )
-        {
-            System.out.println( "FAILURE!" );
-            return false;
-        }
-    }
+    File file = new File( basedir, path )
+    System.out.println( "Checking for absence of " + file )
+    assert !file.exists()
 }
-catch( Throwable t )
-{
-    t.printStackTrace();
-    return false;
-}
-
-return true;
diff --git a/src/it/file-sets-includes-excludes/verify.groovy 
b/src/it/file-sets-includes-excludes/verify.groovy
index 5f71ed6..dbcc35d 100644
--- a/src/it/file-sets-includes-excludes/verify.groovy
+++ b/src/it/file-sets-includes-excludes/verify.groovy
@@ -17,80 +17,60 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.regex.*;
+import java.util.jar.*
+import java.util.regex.*
 
-try
-{
-    String[] expected = [
-        "dir0/excluded.txt",
-        "dir0/sub0/excluded.txt",
-        "dir0/sub1",
-        "dir0/sub2/excluded.txt",
+String[] expected = [
+    "dir0/excluded.txt",
+    "dir0/sub0/excluded.txt",
+    "dir0/sub1",
+    "dir0/sub2/excluded.txt",
 
-        "dir1/excluded.txt",
-        "dir1/sub0/excluded.txt",
-        "dir1/sub1",
-        "dir1/sub2/excluded.txt",
+    "dir1/excluded.txt",
+    "dir1/sub0/excluded.txt",
+    "dir1/sub1",
+    "dir1/sub2/excluded.txt",
 
-        "dir2/excluded.txt",
-        "dir2/sub0/excluded.txt",
-        "dir2/sub2/excluded.txt",
+    "dir2/excluded.txt",
+    "dir2/sub0/excluded.txt",
+    "dir2/sub2/excluded.txt",
 
-        "dir3/excluded.txt",
-        "dir3/sub0/excluded.txt",
-        "dir3/sub2/excluded.txt",
+    "dir3/excluded.txt",
+    "dir3/sub0/excluded.txt",
+    "dir3/sub2/excluded.txt",
 
-        "dir4/excluded/file.txt",
-    ];
-    for ( String path : expected )
-    {
-        File file = new File( new File( basedir, "dirs" ), path );
-        System.out.println( "Checking for existence of " + file );
-        if ( !file.exists() )
-        {
-            System.out.println( "FAILURE!" );
-            return false;
-        }
-    }
+    "dir4/excluded/file.txt",
+]
+for ( String path : expected )
+{
+    File file = new File( new File( basedir, "dirs" ), path )
+    System.out.println( "Checking for existence of " + file )
+    assert file.exists()
+}
 
-    String[] unexpected = [
-        "dir0/included.txt",
-        "dir0/sub0/included.txt",
-        "dir0/sub1/included.txt",
+String[] unexpected = [
+    "dir0/included.txt",
+    "dir0/sub0/included.txt",
+    "dir0/sub1/included.txt",
 
-        "dir1/included.txt",
-        "dir1/sub0/included.txt",
-        "dir1/sub1/included.txt",
+    "dir1/included.txt",
+    "dir1/sub0/included.txt",
+    "dir1/sub1/included.txt",
 
-        "dir2/included.txt",
-        "dir2/sub0/included.txt",
-        "dir2/sub1",
+    "dir2/included.txt",
+    "dir2/sub0/included.txt",
+    "dir2/sub1",
 
-        "dir3/included.txt",
-        "dir3/sub0/included.txt",
-        "dir3/sub1",
+    "dir3/included.txt",
+    "dir3/sub0/included.txt",
+    "dir3/sub1",
 
-        "dir4/file.txt",
-        "dir4/included/file.txt",
-    ];
-    for ( String path : unexpected )
-    {
-        File file = new File( new File( basedir, "dirs" ), path );
-        System.out.println( "Checking for absence of " + file );
-        if ( file.exists() )
-        {
-            System.out.println( "FAILURE!" );
-            return false;
-        }
-    }
-}
-catch( Throwable t )
+    "dir4/file.txt",
+    "dir4/included/file.txt",
+]
+for ( String path : unexpected )
 {
-    t.printStackTrace();
-    return false;
+    File file = new File( new File( basedir, "dirs" ), path )
+    System.out.println( "Checking for absence of " + file )
+    assert !file.exists()
 }
-
-return true;
diff --git a/src/it/file-sets-relative-paths/verify.groovy 
b/src/it/file-sets-relative-paths/verify.groovy
index cdee852..da8db95 100644
--- a/src/it/file-sets-relative-paths/verify.groovy
+++ b/src/it/file-sets-relative-paths/verify.groovy
@@ -17,50 +17,30 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.regex.*;
+import java.util.jar.*
+import java.util.regex.*
 
-try
+String[] expected = [
+    "temp-stuff/test.txt",
+    "deploy/test.txt",
+]
+for ( String path : expected )
 {
-    String[] expected = [
-        "temp-stuff/test.txt",
-        "deploy/test.txt",
-    ];
-    for ( String path : expected )
-    {
-        File file = new File( basedir, path );
-        System.out.println( "Checking for existence of " + file );
-        if ( !file.exists() )
-        {
-            System.out.println( "FAILURE!" );
-            return false;
-        }
-    }
-
-    String[] unexpected = [
-        "target",
-        "child-a/target",
-        "child-a/temp-stuff",
-        "child-b/target",
-        "child-b/deploy",
-    ];
-    for ( String path : unexpected )
-    {
-        File file = new File( basedir, path );
-        System.out.println( "Checking for absence of " + file );
-        if ( file.exists() )
-        {
-            System.out.println( "FAILURE!" );
-            return false;
-        }
-    }
+    File file = new File( basedir, path )
+    System.out.println( "Checking for existence of " + file )
+    assert file.exists()
 }
-catch( Throwable t )
+
+String[] unexpected = [
+    "target",
+    "child-a/target",
+    "child-a/temp-stuff",
+    "child-b/target",
+    "child-b/deploy",
+]
+for ( String path : unexpected )
 {
-    t.printStackTrace();
-    return false;
+    File file = new File( basedir, path )
+    System.out.println( "Checking for absence of " + file )
+    assert !file.exists()
 }
-
-return true;
diff --git a/src/it/only-test-clean/setup.groovy 
b/src/it/only-test-clean/setup.groovy
index 4cf09f7..a2186fc 100644
--- a/src/it/only-test-clean/setup.groovy
+++ b/src/it/only-test-clean/setup.groovy
@@ -17,25 +17,9 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.regex.*;
+import java.util.jar.*
+import java.util.regex.*
 
-try
-{
-    File targetDir = new File( basedir, "target" );
-    System.out.println( "Checking for existence of " + targetDir );
-    if ( !targetDir.isDirectory() )
-    {
-        System.out.println( "FAILURE!" );
-        return false;
-    }
-}
-catch( Throwable t )
-{
-    t.printStackTrace();
-    return false;
-}
-
-return true;
+File targetDir = new File( basedir, "target" )
+System.out.println( "Checking for existence of " + targetDir )
+assert targetDir.isDirectory()
diff --git a/src/it/only-test-clean/verify.groovy 
b/src/it/only-test-clean/verify.groovy
index 377caed..829e5eb 100644
--- a/src/it/only-test-clean/verify.groovy
+++ b/src/it/only-test-clean/verify.groovy
@@ -17,40 +17,15 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.regex.*;
+import java.util.jar.*
+import java.util.regex.*
 
-try
-{
-    File targetDir = new File( basedir, "target" );
-    System.out.println( "Checking for absence of " + targetDir );
-    if ( !targetDir.exists() )
-    {
-        System.out.println( "FAILURE!  target must exists" );
-        return false;
-    }
+File targetDir = new File( basedir, "target" )
+System.out.println( "Checking for absence of " + targetDir )
+assert targetDir.exists()
 
-    File targetClasses = new File( targetDir, "classes" );
-    if ( !targetClasses.exists() )
-    {
-        System.out.println( "FAILURE!  target/classes must exists" );
-        return false;
-    }
+File targetClasses = new File( targetDir, "classes" )
+assert targetClasses.exists()
 
-    File targetTestsClasses = new File( targetDir, "test-classes" );
-    if ( targetTestsClasses.exists() )
-    {
-        System.out.println( "FAILURE!  target/test-classes must not exists" );
-        return false;
-    }
-
-}
-catch( Throwable t )
-{
-    t.printStackTrace();
-    return false;
-}
-
-return true;
+File targetTestsClasses = new File( targetDir, "test-classes" )
+assert !targetTestsClasses.exists()
diff --git a/src/it/read-only/setup.groovy b/src/it/read-only/setup.groovy
index a98d21e..88cc7cf 100644
--- a/src/it/read-only/setup.groovy
+++ b/src/it/read-only/setup.groovy
@@ -17,21 +17,9 @@
  * under the License.
  */
 
-import java.io.File;
-
-if (!new File(basedir, 
"target/read-only-dir/read-only.properties").setWritable(false)) {
-    System.out.println("Cannot change file permission.");
-    return false;
-}
+assert new File(basedir, 
"target/read-only-dir/read-only.properties").setWritable(false) : "Cannot 
change file permission."
 if (File.separatorChar == '/' as char) {
     // Directory permission can be changed only on Unix, not on Windows.
-    if (!new File(basedir, "target/read-only-dir").setWritable(false)) {
-        System.out.println("Cannot change directory permission.");
-        return false;
-    }
-}
-if (!new File(basedir, "target/writable-dir/writable.properties").canWrite()) {
-    System.out.println("Expected a writable file.");
-    return false;
+    assert new File(basedir, "target/read-only-dir").setWritable(false) : 
"Cannot change directory permission."
 }
-return true;
+assert new File(basedir, "target/writable-dir/writable.properties").canWrite() 
: "Expected a writable file."
diff --git a/src/it/read-only/verify.groovy b/src/it/read-only/verify.groovy
index ed830cc..7c95839 100644
--- a/src/it/read-only/verify.groovy
+++ b/src/it/read-only/verify.groovy
@@ -17,10 +17,4 @@
  * under the License.
  */
 
-import java.io.File;
-
-if (new File(basedir, "target").exists()) {
-    System.out.println("target should have been deleted.");
-    return false;
-}
-return true;
+assert !new File(basedir, "target").exists() : "target should have been 
deleted."
diff --git a/src/it/special-characters/verify.groovy 
b/src/it/special-characters/verify.groovy
index f18659c..6c2c401 100644
--- a/src/it/special-characters/verify.groovy
+++ b/src/it/special-characters/verify.groovy
@@ -17,26 +17,9 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.regex.*;
+import java.util.jar.*
+import java.util.regex.*
 
-try
-{
-       // this confirms that special character file and directory are deleted 
-    File targetDir = new File( basedir, "target" );
-    if ( targetDir.exists() )
-    {
-        System.out.println( "FAILURE!  target must not exist" );
-        return false;
-    }
-
-}
-catch( Throwable t )
-{
-    t.printStackTrace();
-    return false;
-}
-
-return true;
+// this confirms that special character file and directory are deleted 
+File targetDir = new File( basedir, "target" )
+assert !targetDir.exists() : "target must not exist"
diff --git a/src/it/symlink-dont-follow/verify.groovy 
b/src/it/symlink-dont-follow/verify.groovy
index e912d6b..41caf99 100644
--- a/src/it/symlink-dont-follow/verify.groovy
+++ b/src/it/symlink-dont-follow/verify.groovy
@@ -17,26 +17,20 @@
  * under the License.
  */
 
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.regex.*;
+import java.util.jar.*
+import java.util.regex.*
 
 String[] expected = [
     "ext",
     "ext/file.txt",
     "ext/dir/file.txt",
-];
+]
 
 for ( String path : expected )
 {
-    File file = new File( basedir, path );
-    System.out.println( "Checking for existence of " + file );
-    if ( !file.exists() )
-    {
-        System.out.println( "FAILURE!" );
-        return false;
-    }
+    File file = new File( basedir, path )
+    System.out.println( "Checking for existence of " + file )
+    assert file.exists()
 }
 
 String[] unexpected = [
@@ -46,15 +40,11 @@ String[] unexpected = [
     "target2/link.txt",
     "target2/link",
     "target2",
-];
+]
 
 for ( String path : unexpected )
 {
-    File file = new File( basedir, path );
-    System.out.println( "Checking for absence of " + file );
-    if ( file.exists() )
-    {
-        System.out.println( "FAILURE!" );
-        return false;
-    }
+    File file = new File( basedir, path )
+    System.out.println( "Checking for absence of " + file )
+    assert !file.exists()
 }

Reply via email to