Author: fgiust
Date: Sun Oct 22 13:46:41 2006
New Revision: 466874
URL: http://svn.apache.org/viewvc?view=rev&rev=466874
Log:
small improvement to the make-artifacts goal: resolve names in plugin.properties
Modified:
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/MakeArtifactsMojo.java
Modified:
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/MakeArtifactsMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/MakeArtifactsMojo.java?view=diff&rev=466874&r1=466873&r2=466874
==============================================================================
---
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/MakeArtifactsMojo.java
(original)
+++
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/MakeArtifactsMojo.java
Sun Oct 22 13:46:41 2006
@@ -19,12 +19,15 @@
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -152,17 +155,36 @@
getLog().info( "Processing file " + file.getAbsolutePath() );
+ JarFile jar = null;
Manifest manifest;
+ Properties pluginProperties = new Properties();
try
{
- JarFile jar = new JarFile( file );
+ jar = new JarFile( file );
manifest = jar.getManifest();
- jar.close();
+ ZipEntry jarEntry = jar.getEntry( "plugin.properties" );
+ if ( jarEntry != null )
+ {
+ InputStream pluginPropertiesStream = jar.getInputStream(
jarEntry );
+ pluginProperties.load( pluginPropertiesStream );
+ }
}
catch ( IOException e )
{
throw new MojoFailureException( "Unable to read manifest for
jar " + file.getAbsolutePath() );
}
+ finally
+ {
+ try
+ {
+ // this also closes any opened input stream
+ jar.close();
+ }
+ catch ( IOException e )
+ {
+ // ignore
+ }
+ }
if ( manifest == null )
{
@@ -180,6 +202,7 @@
artifactId = StringUtils.substring( artifactId, 0, separator );
}
artifactId = StringUtils.trim( artifactId );
+
String version = manifestEntries.getValue( "Bundle-Version" );
if ( artifactId == null || version == null )
@@ -193,9 +216,17 @@
version = StringUtils.substring( version, 0,
version.lastIndexOf( "." ) );
}
- // @todo could be i18n! Need to be read from plugin.properties
- // Bundle-Name: %pluginName
String name = manifestEntries.getValue( "Bundle-Name" );
+
+ // if Bundle-Name is %pluginName fetch the full name from
plugin.properties
+ if ( name != null && name.startsWith( "%" ) )
+ {
+ String nameFromProperties = pluginProperties.getProperty(
name.substring( 1 ) );
+ if ( nameFromProperties != null )
+ {
+ name = nameFromProperties;
+ }
+ }
String requireBundle = manifestEntries.getValue( "Require-Bundle"
);
Dependency[] deps = parseDependencies( requireBundle );