FELIX-376: Support writing of manifest to the file system when using bundle goal
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@578067 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
index a2236a5..7daf2be 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -31,6 +31,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import java.util.jar.Manifest;
import java.util.zip.ZipException;
import org.apache.maven.artifact.Artifact;
@@ -60,6 +61,13 @@
public class BundlePlugin extends AbstractMojo {
/**
+ * Directory where the manifest will be written
+ *
+ * @parameter expression="${manifestLocation}" default-value="${project.build.outputDirectory}/META-INF"
+ */
+ protected String manifestLocation;
+
+ /**
* @component
*/
private ArtifactHandlerManager artifactHandlerManager;
@@ -274,15 +282,30 @@
Artifact bundleArtifact = project.getArtifact();
bundleArtifact.setFile(jarFile);
+ if (manifestLocation != null && manifestLocation.length() > 0)
+ {
+ File outputFile = new File( manifestLocation, "MANIFEST.MF" );
+
+ try
+ {
+ Manifest manifest = builder.getJar().getManifest();
+ ManifestPlugin.writeManifest( manifest, outputFile );
+ }
+ catch ( IOException e )
+ {
+ getLog().error( "Error trying to write Manifest to file " + outputFile, e );
+ }
+ }
+
// workaround for MNG-1682: force maven to install artifact using the "jar" handler
bundleArtifact.setArtifactHandler( artifactHandlerManager.getArtifactHandler( "jar" ) );
}
+
for (Iterator w = warnings.iterator(); w.hasNext();)
{
String msg = (String) w.next();
this.getLog().warn("Warning building bundle " + project.getArtifact() + " : " + msg);
}
-
}
catch (Exception e)
{
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
index 4a67c24..6fb02f2 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -43,13 +43,6 @@
public class ManifestPlugin
extends BundlePlugin
{
-
- /**
- * Directory where the manifest will be written
- * @parameter expression="${project.build.outputDirectory}/META-INF"
- */
- private String manifestLocation;
-
protected void execute( MavenProject project, Map instructions, Properties properties, Jar[] classpath )
throws MojoExecutionException
{
@@ -71,7 +64,7 @@
try
{
- this.writeManifest( manifest, outputFile );
+ writeManifest( manifest, outputFile );
}
catch ( IOException e )
{
@@ -144,7 +137,7 @@
return analyzer;
}
- public void writeManifest( Manifest manifest, File outputFile )
+ public static void writeManifest( Manifest manifest, File outputFile )
throws IOException
{
outputFile.getParentFile().mkdirs();