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-rar-plugin.git
commit aa59aa785fdc370dd1b4da0ca3ce05d5061bb702 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Wed Nov 25 22:34:47 2026 +0000 Modernize Groovy IT scripts See https://github.com/apache/maven-invoker-plugin/issues/811. --- src/it/build-extension/verify.groovy | 4 +- src/it/default-extension/verify.groovy | 64 +++++++---------------- src/it/default/verify.groovy | 64 +++++++---------------- src/it/filtered/verify.groovy | 95 ++++++++++------------------------ 4 files changed, 63 insertions(+), 164 deletions(-) diff --git a/src/it/build-extension/verify.groovy b/src/it/build-extension/verify.groovy index 7a00363..b23654e 100644 --- a/src/it/build-extension/verify.groovy +++ b/src/it/build-extension/verify.groovy @@ -22,7 +22,5 @@ def log = new File(basedir, "build.log").text // The lifecycle mapping must bind the rar goal to the loaded extension's version, // not to whatever version repository metadata resolves for a version-less binding. -if (!log.contains(":" + version + ":rar (default-rar)")) { - throw new AssertionError("rar goal did not run at extension version " + version) -} +assert log.contains(":" + version + ":rar (default-rar)") : "rar goal did not run at extension version " + version assert new File(basedir, "target/build-extension-1.0-SNAPSHOT.rar").isFile() diff --git a/src/it/default-extension/verify.groovy b/src/it/default-extension/verify.groovy index 5eb2f22..f889d96 100644 --- a/src/it/default-extension/verify.groovy +++ b/src/it/default-extension/verify.groovy @@ -17,55 +17,27 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.jar.*; -import java.util.regex.*; -import org.codehaus.plexus.util.*; +import java.util.jar.JarFile -try -{ - File jarFile = new File( basedir, "target/maven-it-it0070-1.0-SNAPSHOT.rar" ); - System.out.println( "Checking for existence of " + jarFile ); - if ( !jarFile.isFile() ) - { - System.out.println( "FAILURE! rar file not found" ); - return false; - } - - JarFile jar = new JarFile( jarFile ); - - String[] includedEntries = [ - "META-INF/ra.xml", - "SomeResource.txt", - ]; - for ( String included : includedEntries ) - { - System.out.println( "Checking for existence of " + included ); - if ( jar.getEntry( included ) == null ) - { - System.out.println( "FAILURE! entry not in rar file" + included ); - return false; - } - } - - InputStream stream = jar.getInputStream( jar.getEntry("SomeResource.txt") ); - - String content = new String(IOUtil.toByteArray( stream )); +File jarFile = new File( basedir, "target/maven-it-it0070-1.0-SNAPSHOT.rar" ) +println "Checking for existence of " + jarFile +assert jarFile.isFile() : "rar file not found" - int idx = content.indexOf('${project.version}'); +JarFile jar = new JarFile( jarFile ) - if (idx<1) { - System.out.println("SomeResource.txt not filtered"); - return false; - } - - jar.close(); -} -catch( Throwable t ) +String[] includedEntries = [ + "META-INF/ra.xml", + "SomeResource.txt", +] +for ( String included : includedEntries ) { - t.printStackTrace(); - return false; + println "Checking for existence of " + included + assert jar.getEntry( included ) != null : "entry not in rar file" + included } -return true; +String content = new String( jar.getInputStream( jar.getEntry( "SomeResource.txt" ) ).bytes ) + +int idx = content.indexOf( '${project.version}' ) +assert idx >= 1 : "SomeResource.txt not filtered" + +jar.close() diff --git a/src/it/default/verify.groovy b/src/it/default/verify.groovy index 5eb2f22..f889d96 100644 --- a/src/it/default/verify.groovy +++ b/src/it/default/verify.groovy @@ -17,55 +17,27 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.jar.*; -import java.util.regex.*; -import org.codehaus.plexus.util.*; +import java.util.jar.JarFile -try -{ - File jarFile = new File( basedir, "target/maven-it-it0070-1.0-SNAPSHOT.rar" ); - System.out.println( "Checking for existence of " + jarFile ); - if ( !jarFile.isFile() ) - { - System.out.println( "FAILURE! rar file not found" ); - return false; - } - - JarFile jar = new JarFile( jarFile ); - - String[] includedEntries = [ - "META-INF/ra.xml", - "SomeResource.txt", - ]; - for ( String included : includedEntries ) - { - System.out.println( "Checking for existence of " + included ); - if ( jar.getEntry( included ) == null ) - { - System.out.println( "FAILURE! entry not in rar file" + included ); - return false; - } - } - - InputStream stream = jar.getInputStream( jar.getEntry("SomeResource.txt") ); - - String content = new String(IOUtil.toByteArray( stream )); +File jarFile = new File( basedir, "target/maven-it-it0070-1.0-SNAPSHOT.rar" ) +println "Checking for existence of " + jarFile +assert jarFile.isFile() : "rar file not found" - int idx = content.indexOf('${project.version}'); +JarFile jar = new JarFile( jarFile ) - if (idx<1) { - System.out.println("SomeResource.txt not filtered"); - return false; - } - - jar.close(); -} -catch( Throwable t ) +String[] includedEntries = [ + "META-INF/ra.xml", + "SomeResource.txt", +] +for ( String included : includedEntries ) { - t.printStackTrace(); - return false; + println "Checking for existence of " + included + assert jar.getEntry( included ) != null : "entry not in rar file" + included } -return true; +String content = new String( jar.getInputStream( jar.getEntry( "SomeResource.txt" ) ).bytes ) + +int idx = content.indexOf( '${project.version}' ) +assert idx >= 1 : "SomeResource.txt not filtered" + +jar.close() diff --git a/src/it/filtered/verify.groovy b/src/it/filtered/verify.groovy index 5dfecaf..f947633 100644 --- a/src/it/filtered/verify.groovy +++ b/src/it/filtered/verify.groovy @@ -17,79 +17,36 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.jar.*; -import java.util.regex.*; -import org.codehaus.plexus.util.*; +import java.util.jar.JarFile -try -{ - File jarFile = new File( basedir, "target/maven-it-non-filtered-1.0-SNAPSHOT.rar" ); - System.out.println( "Checking for existence of " + jarFile ); - if ( !jarFile.isFile() ) - { - System.out.println( "FAILURE! rar file not found" ); - return false; - } - - JarFile jar = new JarFile( jarFile ); - - String[] includedEntries = [ - "META-INF/ra.xml", - "SomeResource.txt", - "ext/wine.txt", - "ext-filtered/wine.txt" - ]; - for ( String included : includedEntries ) - { - System.out.println( "Checking for existence of " + included ); - if ( jar.getEntry( included ) == null ) - { - System.out.println( "FAILURE! entry not in rar file" + included ); - return false; - } - } - - InputStream stream = jar.getInputStream( jar.getEntry("SomeResource.txt") ); - - String content = new String(IOUtil.toByteArray( stream )); - - int idx = content.indexOf("1.0-SNAPSHOT"); - - if (idx<1) { - System.out.println("SomeResource.txt not filtered"); - return false; - } - - stream = jar.getInputStream( jar.getEntry("ext/wine.txt") ); +File jarFile = new File( basedir, "target/maven-it-non-filtered-1.0-SNAPSHOT.rar" ) +println "Checking for existence of " + jarFile +assert jarFile.isFile() : "rar file not found" - content = new String(IOUtil.toByteArray( stream )); +JarFile jar = new JarFile( jarFile ) - idx = content.indexOf('${bestwine}'); - - if (idx<1) { - System.out.println("ext/wine.txt filtered:"+content); - return false; - } - - stream = jar.getInputStream( jar.getEntry("ext-filtered/wine.txt") ); - - content = new String(IOUtil.toByteArray( stream )); +String[] includedEntries = [ + "META-INF/ra.xml", + "SomeResource.txt", + "ext/wine.txt", + "ext-filtered/wine.txt" +] +for ( String included : includedEntries ) +{ + println "Checking for existence of " + included + assert jar.getEntry( included ) != null : "entry not in rar file" + included +} - idx = content.indexOf("bordeaux"); +String content = new String( jar.getInputStream( jar.getEntry( "SomeResource.txt" ) ).bytes ) +int idx = content.indexOf( "1.0-SNAPSHOT" ) +assert idx >= 1 : "SomeResource.txt not filtered" - if (idx<1) { - System.out.println("ext-filtered/wine.txt filtered:"+content); - return false; - } +content = new String( jar.getInputStream( jar.getEntry( "ext/wine.txt" ) ).bytes ) +idx = content.indexOf( '${bestwine}' ) +assert idx >= 1 : "ext/wine.txt filtered:" + content - jar.close(); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} +content = new String( jar.getInputStream( jar.getEntry( "ext-filtered/wine.txt" ) ).bytes ) +idx = content.indexOf( "bordeaux" ) +assert idx >= 1 : "ext-filtered/wine.txt filtered:" + content -return true; +jar.close()
