FELIX-433: add unpackBundle option that unpacks the bundle contents to the Maven output directory
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@602019 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/pom.xml b/bundleplugin/pom.xml
index f14fedd..9e6907d 100644
--- a/bundleplugin/pom.xml
+++ b/bundleplugin/pom.xml
@@ -89,6 +89,16 @@
<version>1.0-alpha-9-stable-1</version>
</dependency>
<dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-archiver</artifactId>
+ <version>1.0-alpha-7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.4.1</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>1.1</version>
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 9f94ea0..a051f44 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -43,6 +43,8 @@
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.osgi.Maven2OsgiConverter;
+import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.util.DirectoryScanner;
import aQute.lib.osgi.Analyzer;
@@ -69,6 +71,18 @@
protected File manifestLocation;
/**
+ * When true, unpack the bundle contents to the outputDirectory
+ *
+ * @parameter expression="${unpackBundle}"
+ */
+ protected boolean unpackBundle;
+
+ /**
+ * @component
+ */
+ private ArchiverManager archiverManager;
+
+ /**
* @component
*/
private ArtifactHandlerManager artifactHandlerManager;
@@ -308,6 +322,21 @@
Artifact bundleArtifact = project.getArtifact();
bundleArtifact.setFile(jarFile);
+ if (unpackBundle)
+ {
+ try
+ {
+ UnArchiver unArchiver = archiverManager.getUnArchiver( "jar" );
+ unArchiver.setDestDirectory( getOutputDirectory() );
+ unArchiver.setSourceFile( jarFile );
+ unArchiver.extract();
+ }
+ catch ( Exception e )
+ {
+ getLog().error( "Problem unpacking " + jarFile + " to " + getOutputDirectory(), e );
+ }
+ }
+
if (manifestLocation != null)
{
File outputFile = new File( manifestLocation, "MANIFEST.MF" );