FELIX-2435: using bundle goals on a WAR file will switch the project to generate jar artifacts

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1139451 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 d9c9625..5da44dd 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -325,8 +325,11 @@
 
             Artifact mainArtifact = currentProject.getArtifact();
 
-            // workaround for MNG-1682: force maven to install artifact using the "jar" handler
-            mainArtifact.setArtifactHandler( m_artifactHandlerManager.getArtifactHandler( "jar" ) );
+            if ( "bundle".equals( mainArtifact.getType() ) )
+            {
+                // workaround for MNG-1682: force maven to install artifact using the "jar" handler
+                mainArtifact.setArtifactHandler( m_artifactHandlerManager.getArtifactHandler( "jar" ) );
+            }
 
             if ( null == classifier || classifier.trim().length() == 0 )
             {
@@ -908,12 +911,25 @@
      */
     protected String getBundleName( MavenProject currentProject )
     {
+        String extension;
+        try
+        {
+            extension = currentProject.getArtifact().getArtifactHandler().getExtension();
+        }
+        catch ( Throwable e )
+        {
+            extension = currentProject.getArtifact().getType();
+        }
+        if ( StringUtils.isEmpty( extension ) || "bundle".equals( extension ) )
+        {
+            extension = "jar"; // just in case maven gets confused
+        }
         String finalName = currentProject.getBuild().getFinalName();
         if ( null != classifier && classifier.trim().length() > 0 )
         {
-            return finalName + '-' + classifier + ".jar";
+            return finalName + '-' + classifier + '.' + extension;
         }
-        return finalName + ".jar";
+        return finalName + '.' + extension;
     }