You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2021/04/09 13:44:21 UTC
[maven-assembly-plugin] 01/01: Rewrite bash script to groovy due to
Java 16 restrictions
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch stabilize
in repository https://gitbox.apache.org/repos/asf/maven-assembly-plugin.git
commit 45254043fdfed6958728f8f50f2e7499a953fadd
Author: rfscholte <rf...@apache.org>
AuthorDate: Fri Apr 9 15:43:59 2021 +0200
Rewrite bash script to groovy due to Java 16 restrictions
---
.../massembly-285/{verify.bsh => verify.groovy} | 38 +++-----
.../massembly-919/{verify.bsh => verify.groovy} | 41 ++-------
.../depSet-enum-vs-wildcard/verify.bsh | 102 ---------------------
.../depSet-enum-vs-wildcard/verify.groovy | 70 ++++++++++++++
4 files changed, 94 insertions(+), 157 deletions(-)
diff --git a/src/it/projects/bugs/massembly-285/verify.bsh b/src/it/projects/bugs/massembly-285/verify.groovy
similarity index 65%
rename from src/it/projects/bugs/massembly-285/verify.bsh
rename to src/it/projects/bugs/massembly-285/verify.groovy
index 28fc6bf..e780ee2 100644
--- a/src/it/projects/bugs/massembly-285/verify.bsh
+++ b/src/it/projects/bugs/massembly-285/verify.groovy
@@ -17,51 +17,41 @@
* under the License.
*/
-import java.io.*;
-import java.util.*;
import java.util.jar.*;
import java.util.zip.*;
-File f = new File( basedir, "massembly-285-assembly/target/massembly-285-assembly-1-bin.jar" );
+File f = new File( basedir, "massembly-285-assembly/target/massembly-285-assembly-1-bin.jar" )
JarFile jf = new JarFile( f );
-String testPath = "tests/App.class";
+String testPath = "tests/App.class"
-int jarCount = 0;
+int jarCount = 0
-Enumeration e = jf.entries();
+Enumeration e = jf.entries()
while( e.hasMoreElements() )
{
if ( testPath.equals( String.valueOf( e.nextElement() ) ) )
{
- jarCount++;
+ jarCount++
}
}
+jf.close()
-if ( jarCount != 1 )
-{
- System.out.println( "ERROR! Test path: " + testPath + " was found " + jarCount + " times (should have been 1).\nArchive: " + f );
-}
-
-f = new File( basedir, "massembly-285-assembly/target/massembly-285-assembly-1-bin.zip" );
-ZipFile zf = new ZipFile( f );
+assert jarCount == 1 : "Test path: ${testPath} was found ${jarCount} times (should have been 1).\nArchive: ${f}"
-String testPath = "tests/App.class";
+f = new File( basedir, "massembly-285-assembly/target/massembly-285-assembly-1-bin.zip" )
+ZipFile zf = new ZipFile( f )
-int zipCount = 0;
+int zipCount = 0
-e = zf.entries();
+e = zf.entries()
while( e.hasMoreElements() )
{
if ( testPath.equals( String.valueOf( e.nextElement() ) ) )
{
- zipCount++;
+ zipCount++
}
}
+zf.close()
-if ( zipCount != 1 )
-{
- System.out.println( "ERROR! Test path: " + testPath + " was found " + zipCount + " times (should have been 1).\nArchive: " + f );
-}
-
-return jarCount == 1;
+assert zipCount == 1 : "Test path: ${testPath} was found ${zipCount} times (should have been 1).\nArchive: ${f}"
diff --git a/src/it/projects/bugs/massembly-919/verify.bsh b/src/it/projects/bugs/massembly-919/verify.groovy
similarity index 56%
rename from src/it/projects/bugs/massembly-919/verify.bsh
rename to src/it/projects/bugs/massembly-919/verify.groovy
index abd6036..62cb39f 100644
--- a/src/it/projects/bugs/massembly-919/verify.bsh
+++ b/src/it/projects/bugs/massembly-919/verify.groovy
@@ -17,43 +17,22 @@
* under the License.
*/
-import java.io.*;
import java.net.*;
import java.util.zip.*;
+File zipFile = new File( basedir, "bundle/target/project-bundle-0.0.1-SNAPSHOT-bin.zip" )
+assert zipFile.isFile() : "zip-file is missing or a directory."
-boolean result = true;
-
-try
-{
- File zipFile = new File( basedir, "bundle/target/project-bundle-0.0.1-SNAPSHOT-bin.zip" );
-
- if ( !zipFile.exists() || zipFile.isDirectory() )
- {
- System.err.println( "zip-file is missing or a directory." );
- result = false;
- }
-
- ZipFile zf = new ZipFile( zipFile );
-
- zes = zf.entries();
+ZipFile zf = new ZipFile( zipFile )
+try {
+ zes = zf.entries()
while(zes.hasMoreElements())
{
- ZipEntry ze = zes.nextElement();
- if (ze.getName().contains("maven-assembly-plugin"))
- {
- System.err.println( "filename is incorrect" );
- result = false;
- }
+ ZipEntry ze = zes.nextElement()
+ assert !ze.getName().contains("maven-assembly-plugin") : "filename '${ze.name}' is incorrect"
}
-
- zf.close();
-}
-catch( IOException e )
-{
- e.printStackTrace();
- result = false;
}
-
-return result;
+finally {
+ zf.close()
+}
\ No newline at end of file
diff --git a/src/it/projects/dependency-sets/depSet-enum-vs-wildcard/verify.bsh b/src/it/projects/dependency-sets/depSet-enum-vs-wildcard/verify.bsh
deleted file mode 100644
index 734f6c7..0000000
--- a/src/it/projects/dependency-sets/depSet-enum-vs-wildcard/verify.bsh
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * 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.
- */
-
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-
-boolean result = true;
-
-try
-{
- File f1 = new File( basedir, "enum/target/enum-1-bin.jar" );
- File f2 = new File( basedir, "wildcard/target/wildcard-1-bin.jar" );
-
- JarFile jf1 = new JarFile( f1 );
- JarFile jf2 = new JarFile( f2 );
-
- for( Enumeration e = jf1.entries(); e.hasMoreElements(); )
- {
- JarEntry entry1 = (JarEntry) e.nextElement();
- JarEntry entry2 = (JarEntry) jf2.getEntry( entry1.getName() );
-
- if ( entry2 == null )
- {
- System.out.println( "Missing entry: " + entry1.getName() + " in " + f2 );
- result = false;
- }
- }
-
- for( Enumeration e = jf2.entries(); e.hasMoreElements(); )
- {
- JarEntry entry2 = (JarEntry) e.nextElement();
- JarEntry entry1 = (JarEntry) jf2.getEntry( entry2.getName() );
-
- if ( entry1 == null )
- {
- System.out.println( "Missing entry: " + entry2.getName() + " in " + f1 );
- result = false;
- }
-
- if ( !entry1.isDirectory() )
- {
- if ( entry2.isDirectory() )
- {
- System.out.println( "One file is directory, the other a file! Entry: " + entry2.getName() );
- result = false;
- }
- else
- {
- ByteArrayOutputStream b1 = new ByteArrayOutputStream();
-
- InputStream in = jf1.getInputStream( entry1 );
- byte[] buf = new byte[1024];
- int read = -1;
-
- while( ( read = in.read( buf ) ) > -1 )
- {
- b1.write( buf, 0, read );
- }
-
- ByteArrayOutputStream b2 = new ByteArrayOutputStream();
-
- in = jf2.getInputStream( entry2 );
- read = -1;
-
- while( ( read = in.read( buf ) ) > -1 )
- {
- b2.write( buf, 0, read );
- }
-
- if ( !Arrays.equals( b1.toByteArray(), b2.toByteArray() ) )
- {
- System.out.println( "Entries are not equal! Entry name: " + entry2.getName() );
- result = false;
- }
- }
- }
- }
-}
-catch ( IOException e )
-{
- e.printStackTrace();
- result = false;
-}
-
-return result;
diff --git a/src/it/projects/dependency-sets/depSet-enum-vs-wildcard/verify.groovy b/src/it/projects/dependency-sets/depSet-enum-vs-wildcard/verify.groovy
new file mode 100644
index 0000000..284c8d3
--- /dev/null
+++ b/src/it/projects/dependency-sets/depSet-enum-vs-wildcard/verify.groovy
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+import java.util.jar.*;
+
+File f1 = new File( basedir, "enum/target/enum-1-bin.jar" )
+File f2 = new File( basedir, "wildcard/target/wildcard-1-bin.jar" )
+
+JarFile jf1 = new JarFile( f1 )
+JarFile jf2 = new JarFile( f2 )
+
+for( Enumeration e = jf1.entries(); e.hasMoreElements(); )
+{
+ JarEntry entry1 = (JarEntry) e.nextElement()
+ JarEntry entry2 = (JarEntry) jf2.getEntry( entry1.getName() )
+
+ assert entry2 != null : "Missing entry: ${entry1.name} in ${f2}"
+}
+
+for( Enumeration e = jf2.entries(); e.hasMoreElements(); )
+{
+ JarEntry entry2 = (JarEntry) e.nextElement()
+ JarEntry entry1 = (JarEntry) jf2.getEntry( entry2.getName() )
+
+ assert entry1 != null : "Missing entry: ${entry2.name} in ${f1}"
+
+ if ( !entry1.isDirectory() )
+ {
+ assert !entry2.isDirectory() : "One file is directory, the other a file! Entry: ${entry2.name}"
+
+ ByteArrayOutputStream b1 = new ByteArrayOutputStream()
+
+ InputStream is = jf1.getInputStream( entry1 )
+ byte[] buf = new byte[1024]
+ int read = -1
+
+ while( ( read = is.read( buf ) ) > -1 )
+ {
+ b1.write( buf, 0, read )
+ }
+
+ ByteArrayOutputStream b2 = new ByteArrayOutputStream()
+
+ is = jf2.getInputStream( entry2 )
+ read = -1
+
+ while( ( read = is.read( buf ) ) > -1 )
+ {
+ b2.write( buf, 0, read )
+ }
+
+ assert Arrays.equals( b1.toByteArray(), b2.toByteArray() ) : "Entries are not equal! Entry name: ${entry2.name}"
+ }
+}
\ No newline at end of file