[
https://issues.apache.org/jira/browse/MNG-8138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17874207#comment-17874207
]
Christian Kohlschütter commented on MNG-8138:
---------------------------------------------
I have fixed my configuration by adding a profile that disables the
maven-jar-plugin as much as possible for POM artifacts, as follows:
{code:xml}
<profile>
<id>disable-jar-plugin-for-pom</id>
<activation>
<property>
<name>packaging</name>
<value>pom</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<skipIfEmpty>true</skipIfEmpty>
<classifier>disabled</classifier><!-- just in case -->
</configuration>
</plugin>
</plugins>
</build>
</profile>{code}
There's no "skip" configuration attribute in maven-jar-plugin, so we use
"skipIfEmpty", which should always be true for POM artifacts. In case that
assumption does not hold true, we specify a classifier for that artifact so the
POM file does not get overwritten by an archive.
I could imagine that one could replace the above configuration with a default
plugin configuration of `<skipIfPomPackaging>true</skipIfPomPackaging>`: I
assume "pom" packaging is truly different from any other packaging — unless I'm
mistaken, a parent POM really has to be of packaging type "pom".
> Maven internal state should not allow to become "broken"
> --------------------------------------------------------
>
> Key: MNG-8138
> URL: https://issues.apache.org/jira/browse/MNG-8138
> Project: Maven
> Issue Type: Bug
> Components: Core
> Reporter: Tamas Cservenak
> Priority: Major
>
> It seems by certain goal combinations we can make Maven Project instance
> state end up in "wrong" state. Example:
> * create a packaging=pom project
> * invoke jar:jar deploy:deploy
> This will result in following:
> * MavenProject has packaging=pom
> * but, jar:jar will create (an empty) JAR and make it "main artifact"
> basically making JAR as main artifact with ".pom" extension (following what
> packaging artifact handler tells)
> * deploy will happily deploy the jar as pom (as it is the only one artifact
> in project, but backing file is empty JAR, no "replacement" happens here)
> Multiple issues here:
> * Maven should "protect" MavenProject instance IMHO
> * jar:jar should not (or core should not allow) to "break the state"
> * m-deploy-p should figure out this situation: we deal with two artifacts
> (POM and "main JAR") but due packaging they end up on same URL?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)