[ 
https://issues.apache.org/jira/browse/FELIX-3497?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13267697#comment-13267697
 ] 

Martin Petrovsky commented on FELIX-3497:
-----------------------------------------

And here is the patch:


Index: src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
===================================================================
--- src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java       
(revision 1333571)
+++ src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java       
(working copy)
@@ -132,6 +132,13 @@
     protected String classifier;
 
     /**
+     * Packaging type of the bundle. Retrieved from POM file if specified.
+     *
+     * @parameter expression="${packaging}"
+     */
+    private String packaging;
+
+    /**
      * @component
      */
     private MavenProjectHelper m_projectHelper;
@@ -375,7 +382,7 @@
             }
             else
             {
-                m_projectHelper.attachArtifact( currentProject, jarFile, 
classifier );
+                m_projectHelper.attachArtifact( currentProject, 
getPackaging(), classifier, jarFile );
             }
 
             if ( unpackBundle )
@@ -1237,7 +1244,19 @@
         outputDirectory = _outputDirectory;
     }
 
+    protected void setPackaging( String _packaging )
+    {
+        this.packaging = _packaging;
+    }
 
+    protected String getPackaging()
+    {
+        if (this.packaging == null || this.packaging.trim().length() == 0) {
+           this.packaging = getProject().getPackaging();
+        }
+        return packaging;
+    }
+
     private static void addLocalPackages( File outputDirectory, Analyzer 
analyzer )
     {
         Collection packages = new TreeSet();

                
> Wrong artifact type attached as a secondary artifact when project packaging 
> is set to "pom"
> -------------------------------------------------------------------------------------------
>
>                 Key: FELIX-3497
>                 URL: https://issues.apache.org/jira/browse/FELIX-3497
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven Bundle Plugin
>    Affects Versions: maven-bundle-plugin-2.3.7
>         Environment: any
>            Reporter: Martin Petrovsky
>              Labels: patch
>
> When trying to create a ${artifactid}-tests.jar in a maven project that does 
> not produce a primary bundle the plugin attaches the ${artifactid}-tests.jar 
> bundle as ${artifactid}-tests.pom. The plugin does not abide by the 
> "<packaging>jar</packaging>" config.
> I have attached both an example POM and a simple fix in the form of a patch.
> Example POM:
> {code}
> <project>
>       <groupId>foo</groupId>
>       <artifactId>bar</artifactId>
>       <version>1.5.1-SNAPSHOT</version>
>       <packaging>pom</packaging>
>       <build>
>               <plugins>
>                       <!-- Create a Integration test bundle -->
>                       <plugin>
>                               <groupId>org.apache.felix</groupId>
>                               <artifactId>maven-bundle-plugin</artifactId>
>                               <executions>
>                                       <execution>
>                                               <id>bundle-tests</id>
>                                               <phase>package</phase>
>                                               
> <goals><goal>bundle</goal></goals>
>                                       </execution>
>                               </executions>
>                               <configuration>
>                                       <classifier>tests</classifier>
>                                       <packaging>jar</packaging>
>                                       
> <supportedProjectTypes><supportedProjectType>pom</supportedProjectType></supportedProjectTypes>
>                                       
> <outputDirectory>target/test-classes</outputDirectory>
>                                       <instructions>
>                                               
> <Export-Package>com.foo.*</Export-Package>
>                                               
> <Sling-Test-Regexp>.*Test</Sling-Test-Regexp>
>                                               <Bundle-Description>Integration 
> Tests - ${project.description}</Bundle-Description>
>                                               <Bundle-Name>Integration Tests 
> for ${project.name}</Bundle-Name>
>                                               
> <Bundle-SymbolicName>${groupId}.${artifactId}-tests</Bundle-SymbolicName>
>                                       </instructions>
>                               </configuration>
>                       </plugin>
>               </plugins>
>       </build>
> </project>
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to