FELIX-433: must ensure directory exists before calling plexus unarchiver

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@602449 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 a051f44..57db3f5 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -324,16 +324,31 @@
 
             if (unpackBundle)
             {
+                File outputDir = this.getOutputDirectory();
+                if (null == outputDir)
+                {
+                    outputDir = new File( this.getBuildDirectory(), "classes" );
+                }
+
                 try
                 {
+                    /*
+                     * this directory must exist before unpacking, otherwise the plexus
+                     * unarchiver decides to use the current working directory instead!
+                     */
+                    if (!outputDir.exists())
+                    {
+                        outputDir.mkdirs();
+                    }
+
                     UnArchiver unArchiver = archiverManager.getUnArchiver( "jar" );
-                    unArchiver.setDestDirectory( getOutputDirectory() );
+                    unArchiver.setDestDirectory( outputDir );
                     unArchiver.setSourceFile( jarFile );
                     unArchiver.extract();
                 }
                 catch ( Exception e )
                 {
-                    getLog().error( "Problem unpacking " + jarFile + " to " + getOutputDirectory(), e );
+                    getLog().error( "Problem unpacking " + jarFile + " to " + outputDir, e );
                 }
             }