diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index 9ef601476a..ca690d41e6 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -91,6 +91,11 @@
org.apache.commons
commons-lang3
+
+ org.apache.commons
+ commons-compress
+ 1.19
+
com.google.code.findbugs
jsr305
@@ -195,6 +200,7 @@
org.apache.maven.shared:maven-common-artifact-filters
commons-io:commons-io
org.apache.commons:commons-lang3
+ org.apache.commons:commons-compress
@@ -210,6 +216,10 @@
org.apache.commons.lang3
org.apache.maven.surefire.shade.common.org.apache.commons.lang3
+
+ org.apache.commons.compress
+ org.apache.maven.surefire.shade.common.org.apache.commons.compress
+
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
index 1a3dd4f77b..dda6d3e07e 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
@@ -19,6 +19,9 @@
* under the License.
*/
+import org.apache.commons.compress.archivers.zip.Zip64Mode;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
import org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
@@ -28,9 +31,11 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
@@ -40,9 +45,8 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.jar.JarEntry;
-import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
+import java.util.zip.Deflater;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
@@ -109,12 +113,15 @@ private File createJar( @Nonnull List classPath, @Nonnull String startCl
file.deleteOnExit();
}
Path parent = file.getParentFile().toPath();
- FileOutputStream fos = new FileOutputStream( file );
- try ( JarOutputStream jos = new JarOutputStream( fos ) )
+ OutputStream fos = new BufferedOutputStream( new FileOutputStream( file ), 64 * 1024 );
+
+ try ( ZipArchiveOutputStream zos = new ZipArchiveOutputStream( fos ) )
{
- jos.setLevel( JarOutputStream.STORED );
- JarEntry je = new JarEntry( "META-INF/MANIFEST.MF" );
- jos.putNextEntry( je );
+ zos.setUseZip64( Zip64Mode.Never );
+ zos.setLevel( Deflater.NO_COMPRESSION );
+
+ ZipArchiveEntry ze = new ZipArchiveEntry( "META-INF/MANIFEST.MF" );
+ zos.putArchiveEntry( ze );
Manifest man = new Manifest();
@@ -146,10 +153,9 @@ private File createJar( @Nonnull List classPath, @Nonnull String startCl
man.getMainAttributes().putValue( "Class-Path", cp.toString().trim() );
man.getMainAttributes().putValue( "Main-Class", startClassName );
- man.write( jos );
+ man.write( zos );
- jos.closeEntry();
- jos.flush();
+ zos.closeArchiveEntry();
return file;
}
diff --git a/pom.xml b/pom.xml
index 7d3e876ff1..1cc826bb16 100644
--- a/pom.xml
+++ b/pom.xml
@@ -89,6 +89,7 @@
3.0
3.8.1
+ 1.19
2.6
1.9
1.9.1
@@ -107,6 +108,11 @@
+
+ org.apache.commons
+ commons-compress
+ ${commonsCompress}
+
org.apache.commons
commons-lang3