Skip to content

Commit 8857663

Browse files
committed
#35: Replace defaultManifest.mf with inline code
This closes #35
1 parent da5a2e1 commit 8857663

File tree

3 files changed

+15
-69
lines changed

3 files changed

+15
-69
lines changed

src/main/java/org/codehaus/plexus/archiver/jar/JdkManifestFactory.java

+7-29
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
* limitations under the License.
1717
*/
1818

19-
import java.io.IOException;
20-
import java.io.InputStream;
2119
import java.util.Map;
2220
import java.util.jar.Attributes;
21+
2322
import org.codehaus.plexus.archiver.ArchiverException;
24-
import org.codehaus.plexus.util.IOUtil;
2523

2624
/**
2725
* Not part of any public API
@@ -32,33 +30,13 @@ class JdkManifestFactory
3230
public static java.util.jar.Manifest getDefaultManifest()
3331
throws ArchiverException
3432
{
35-
InputStream in = null;
36-
final String defManifest = "/org/codehaus/plexus/archiver/jar/defaultManifest.mf";
37-
try
38-
{
39-
in = JdkManifestFactory.class.getResourceAsStream( defManifest );
40-
if ( in == null )
41-
{
42-
throw new ArchiverException( "Could not find default manifest: " + defManifest );
43-
}
44-
java.util.jar.Manifest defaultManifest = new java.util.jar.Manifest( in );
45-
46-
in.close();
47-
in = null;
33+
final java.util.jar.Manifest defaultManifest = new java.util.jar.Manifest();
34+
defaultManifest.getMainAttributes().putValue( "Manifest-Version", "1.0" );
35+
defaultManifest.getMainAttributes().putValue( "Created-By", System.getProperty(
36+
"java.vm.version" ) + " (" + System.getProperty(
37+
"java.vm.vendor" ) + ")" );
4838

49-
defaultManifest.getMainAttributes().putValue( "Created-By",
50-
System.getProperty( "java.vm.version" ) + " ("
51-
+ System.getProperty( "java.vm.vendor" ) + ")" );
52-
return defaultManifest;
53-
}
54-
catch ( IOException e )
55-
{
56-
throw new ArchiverException( "Unable to read default manifest", e );
57-
}
58-
finally
59-
{
60-
IOUtil.close( in );
61-
}
39+
return defaultManifest;
6240
}
6341

6442
public static void merge( java.util.jar.Manifest target, java.util.jar.Manifest other, boolean overwriteMain )

src/main/java/org/codehaus/plexus/archiver/jar/Manifest.java

+8-39
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.io.ByteArrayOutputStream;
2222
import java.io.IOException;
2323
import java.io.InputStream;
24-
import java.io.InputStreamReader;
2524
import java.io.PrintWriter;
2625
import java.io.Reader;
2726
import java.io.StringWriter;
@@ -34,8 +33,8 @@
3433
import java.util.StringTokenizer;
3534
import java.util.Vector;
3635
import java.util.jar.Attributes;
36+
3737
import org.codehaus.plexus.archiver.ArchiverException;
38-
import org.codehaus.plexus.util.IOUtil;
3938

4039
/**
4140
* Holds the data of a jar manifest.
@@ -388,7 +387,7 @@ public Iterator<String> iterator()
388387
{
389388
return getKeys(attributes).iterator();
390389
}
391-
390+
392391
public void setName( String name )
393392
{
394393
throw new UnsupportedOperationException( "Cant do this" );
@@ -738,43 +737,13 @@ public Iterator<String> iterator()
738737
public static Manifest getDefaultManifest()
739738
throws ArchiverException
740739
{
741-
InputStream in = null;
742-
Reader reader = null;
743-
final String defManifest = "/org/codehaus/plexus/archiver/jar/defaultManifest.mf";
744-
try
745-
{
746-
in = Manifest.class.getResourceAsStream( defManifest );
747-
if ( in == null )
748-
{
749-
throw new ArchiverException( "Could not find default manifest: " + defManifest );
750-
}
751-
reader = new InputStreamReader( in, "UTF-8" );
752-
final Manifest defaultManifest = new Manifest( reader );
753-
defaultManifest.getMainAttributes().putValue( "Created-By", System.getProperty(
754-
"java.vm.version" ) + " (" + System.getProperty(
755-
"java.vm.vendor" ) + ")" );
756-
757-
reader.close();
758-
reader = null;
759-
760-
in.close();
761-
in = null;
740+
final Manifest defaultManifest = new Manifest();
741+
defaultManifest.getMainAttributes().putValue( "Manifest-Version", "1.0" );
742+
defaultManifest.getMainAttributes().putValue( "Created-By", System.getProperty(
743+
"java.vm.version" ) + " (" + System.getProperty(
744+
"java.vm.vendor" ) + ")" );
762745

763-
return defaultManifest;
764-
}
765-
catch ( ManifestException e )
766-
{
767-
throw new ArchiverException( "Default manifest is invalid !!", e );
768-
}
769-
catch ( IOException e )
770-
{
771-
throw new ArchiverException( "Unable to read default manifest", e );
772-
}
773-
finally
774-
{
775-
IOUtil.close( in );
776-
IOUtil.close( reader );
777-
}
746+
return defaultManifest;
778747
}
779748

780749
/**

src/main/resources/org/codehaus/plexus/archiver/jar/defaultManifest.mf

-1
This file was deleted.

0 commit comments

Comments
 (0)