Skip to content

Commit 7ee3091

Browse files
#43: If the resource providing the archiver version does not exist, create
'Created-by' manifest entries without version information. If the resource providing the archiver version exists but cannot be read, throw an 'AssertionError'.
1 parent 3798e82 commit 7ee3091

File tree

2 files changed

+7
-35
lines changed

2 files changed

+7
-35
lines changed

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

+6-10
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,22 @@ public static java.util.jar.Manifest getDefaultManifest()
4949
return defaultManifest;
5050
}
5151

52-
private static String getArchiverVersion()
52+
static String getArchiverVersion()
5353
{
54-
String version = null;
55-
5654
try
5755
{
5856
final Properties properties = PropertyUtils.loadProperties( JdkManifestFactory.class.getResourceAsStream(
5957
"/META-INF/maven/org.codehaus.plexus/plexus-archiver/pom.properties" ) );
6058

61-
if ( properties != null )
62-
{
63-
version = properties.getProperty( "version" );
64-
}
59+
return properties != null
60+
? properties.getProperty( "version" )
61+
: null;
62+
6563
}
6664
catch ( final IOException e )
6765
{
68-
version = null;
66+
throw new AssertionError( e );
6967
}
70-
71-
return version;
7268
}
7369

7470
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

+1-25
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@
3030
import java.util.Hashtable;
3131
import java.util.Iterator;
3232
import java.util.Locale;
33-
import java.util.Properties;
3433
import java.util.StringTokenizer;
3534
import java.util.Vector;
3635
import java.util.jar.Attributes;
3736

3837
import org.codehaus.plexus.archiver.ArchiverException;
39-
import org.codehaus.plexus.util.PropertyUtils;
4038

4139
/**
4240
* Holds the data of a jar manifest.
@@ -740,7 +738,7 @@ public static Manifest getDefaultManifest()
740738

741739
String createdBy = "Plexus Archiver";
742740

743-
final String plexusArchiverVersion = getArchiverVersion();
741+
final String plexusArchiverVersion = JdkManifestFactory.getArchiverVersion();
744742

745743
if ( plexusArchiverVersion != null )
746744
{
@@ -752,28 +750,6 @@ public static Manifest getDefaultManifest()
752750
return defaultManifest;
753751
}
754752

755-
private static String getArchiverVersion()
756-
{
757-
String version = null;
758-
759-
try
760-
{
761-
final Properties properties = PropertyUtils.loadProperties( JdkManifestFactory.class.getResourceAsStream(
762-
"/META-INF/maven/org.codehaus.plexus/plexus-archiver/pom.properties" ) );
763-
764-
if ( properties != null )
765-
{
766-
version = properties.getProperty( "version" );
767-
}
768-
}
769-
catch ( final IOException e )
770-
{
771-
version = null;
772-
}
773-
774-
return version;
775-
}
776-
777753
/**
778754
* Construct an empty manifest
779755
*/

0 commit comments

Comments
 (0)