You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by mc...@apache.org on 2011/10/16 19:53:17 UTC
svn commit: r1184887 -
/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
Author: mcculls
Date: Sun Oct 16 17:53:16 2011
New Revision: 1184887
URL: http://svn.apache.org/viewvc?rev=1184887&view=rev
Log:
FELIX-3165: extract any BND generated resources when using unpackBundle with the manifest goal
Modified:
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java?rev=1184887&r1=1184886&r2=1184887&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java Sun Oct 16 17:53:16 2011
@@ -23,8 +23,10 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
import java.util.jar.Manifest;
@@ -35,6 +37,7 @@ import org.apache.maven.project.MavenPro
import aQute.lib.osgi.Analyzer;
import aQute.lib.osgi.Builder;
import aQute.lib.osgi.Jar;
+import aQute.lib.osgi.Resource;
/**
@@ -47,22 +50,14 @@ import aQute.lib.osgi.Jar;
*/
public class ManifestPlugin extends BundlePlugin
{
+ @Override
protected void execute( MavenProject project, Map instructions, Properties properties, Jar[] classpath )
throws MojoExecutionException
{
Manifest manifest;
try
{
- if ( supportedProjectTypes.contains( getProject().getArtifact().getType() ) )
- {
- Builder builder = buildOSGiBundle( project, instructions, properties, classpath );
- manifest = builder.getJar().getManifest();
- builder.close();
- }
- else
- {
- manifest = getManifest( project, instructions, properties, classpath );
- }
+ manifest = getManifest( project, instructions, properties, classpath );
}
catch ( FileNotFoundException e )
{
@@ -118,7 +113,25 @@ public class ManifestPlugin extends Bund
}
}
- Manifest manifest = analyzer.getJar().getManifest();
+ Jar jar = analyzer.getJar();
+
+ if ( unpackBundle )
+ {
+ File outputFile = getOutputDirectory();
+ for ( Entry<String, Resource> entry : jar.getResources().entrySet() )
+ {
+ File entryFile = new File( outputFile, entry.getKey() );
+ if ( !entryFile.exists() )
+ {
+ entryFile.getParentFile().mkdirs();
+ OutputStream os = new FileOutputStream( entryFile );
+ entry.getValue().write( os );
+ os.close();
+ }
+ }
+ }
+
+ Manifest manifest = jar.getManifest();
// cleanup...
analyzer.close();
@@ -137,6 +150,11 @@ public class ManifestPlugin extends Bund
protected Analyzer getAnalyzer( MavenProject project, Map instructions, Properties properties, Jar[] classpath )
throws IOException, MojoExecutionException, Exception
{
+ if ( supportedProjectTypes.contains( project.getArtifact().getType() ) )
+ {
+ return buildOSGiBundle( project, instructions, properties, classpath );
+ }
+
File file = project.getArtifact().getFile();
if ( file == null )
{