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

Karl Heinz Marbaise commented on MJAR-198:
------------------------------------------

So i have [taken your example 
project|https://github.com/khmarbaise/mjar/tree/master/mjar-198] and have run 
it...So what i can observe is that maven-jar-plugin is executed two times...

{code}
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ 0 ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ 0 ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ 0 ---
[INFO] Building jar: 
/Users/kama/ws-git/apache/mjar/mjar-198/target/0-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (executable) @ 0 ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.692 s
[INFO] Finished at: 2015-07-19T09:25:58+02:00
[INFO] Final Memory: 16M/210M
[INFO] ------------------------------------------------------------------------
{code}

This is based on the build life cycle which already contains a definition of 
maven-jar-plugin (packaging jar). You can identify it at the line with 
{{default-jar}} in braces. If you simply add a supplemental execution this will 
result in the second execution {{executable}} of maven-jar-plugin.

To configure things like the main class for the manifest correctly you can 
simply do this like the following without the need to configure a supplemental 
execution.
{code:xml}
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>A</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
{code}


> jar:jar without classifier replaces default jar
> -----------------------------------------------
>
>                 Key: MJAR-198
>                 URL: https://issues.apache.org/jira/browse/MJAR-198
>             Project: Maven JAR Plugin
>          Issue Type: Bug
>    Affects Versions: 2.3.1, 2.3.2, 2.4, 2.5, 2.6
>         Environment: Windows 8.1 Pro
> JDK 1.8 45
> Maven 3.2.5
>            Reporter: Elias Elmqvist Wulcan
>            Priority: Minor
>              Labels: newbie
>         Attachments: 0.tar, mvn.install.debug.txt
>
>
> If I add an execution of jar:jar in a project of packaging jar and do not 
> configure a classifier for the additional jar, the additional jar will be 
> installed instead of the default jar.
> Omitting a classifier in the configuration for the goal jar:jar is documented 
> to have the effect that the jar will not be attached and this is the behavior 
> that I want. Instead, the jar is attached and replaces the default jar.
> AbstractJarMojo.java:254 checks nullness of classifier to decide whether to 
> attach or not. JarMojo.java:51 declares a default value the empty string for 
> classifier. Maybe the combination of these lines cause the bug.
> http://svn.apache.org/viewvc/maven/plugins/tags/maven-jar-plugin-2.6/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java?revision=1664111&view=markup
> http://svn.apache.org/viewvc/maven/plugins/tags/maven-jar-plugin-2.6/src/main/java/org/apache/maven/plugin/jar/JarMojo.java?revision=1664111&view=markup



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to