You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-commits@maven.apache.org by df...@apache.org on 2008/02/08 03:00:10 UTC
svn commit: r619732 - in /maven/surefire/trunk/surefire-booter/src:
main/java/org/apache/maven/surefire/booter/
test/java/org/apache/maven/surefire/booter/
Author: dfabulich
Date: Thu Feb 7 18:00:09 2008
New Revision: 619732
URL: http://svn.apache.org/viewvc?rev=619732&view=rev
Log:
[SUREFIRE-451] Eliminate home-grown manifest writer; just use JarOutputStream and java.util.jar.Manifest. Based on a patch submitted by Joerg Lauer. His patch modified MJW; this check-in deletes the old class (and its test) entirely.
Removed:
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ManifestJarWriter.java
maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ManifestJarWriterTest.java
Modified:
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java?rev=619732&r1=619731&r2=619732&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java Thu Feb 7 18:00:09 2008
@@ -24,12 +24,16 @@
import org.codehaus.plexus.util.cli.Commandline;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
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;
/**
* Configuration for forking tests.
@@ -224,7 +228,13 @@
if ( !debug ) {
file.deleteOnExit();
}
- ManifestJarWriter writer = new ManifestJarWriter(file);
+ FileOutputStream fos = new FileOutputStream( file );
+ JarOutputStream jos = new JarOutputStream( fos );
+ jos.setLevel( JarOutputStream.STORED );
+ JarEntry je = new JarEntry( "META-INF/MANIFEST.MF" );
+ jos.putNextEntry( je );
+
+ Manifest man = new Manifest();
// we can't use StringUtils.join here since we need to add a '/' to
// the end of directory entries - otherwise the jvm will ignore them.
@@ -236,11 +246,12 @@
cp += UrlUtils.getURL( new File( el ) ).toExternalForm() + " ";
}
- writer.writeValue("Manifest-Version", "1.0");
- writer.writeValue("Class-Path", cp.trim());
- writer.writeValue("Main-Class", SurefireBooter.class.getName());
+ man.getMainAttributes().putValue("Manifest-Version", "1.0");
+ man.getMainAttributes().putValue("Class-Path", cp.trim());
+ man.getMainAttributes().putValue("Main-Class", SurefireBooter.class.getName());
- writer.close();
+ man.write(jos);
+ jos.close();
return file;
}