maven-install-plugin
maven-install-plugin copied to clipboard
[MINSTALL-201] Regression in 3.1.2 when installing pom artifact
Christian Kohlschütter opened MINSTALL-201 and commented
With 3.1.2, I'm seeing wrong artifact metadata (POM files) being installed for POM-packaged artifacts in a multi-module project.
Prior to 3.1.2, we were excluding some operations in InstallMojo.java when a project's packaging was "pom". The check got removed, leading to ".pom" artifact files being installed as some sort of zip file (yet having the ".pom" file suffix).
This breaks all sorts of things for me, effectively rendering version 3.1.2 unusable.
Patch forthcoming.
To reproduce:
git clone [email protected]:kohlschutter/kohlschutter-parent.git
git checkout kohlschutter-parent-1.7.2
cd kohlschutter-parent
mvn clean install -Dignorant -DskipTests
file $HOME/.m2/repository/com/kohlschutter/kohlschutter-parent-multirelease/1.7.2/kohlschutter-parent-multirelease-1.7.2.pom
1. the above command should return something like "XML 1.0 document text, ASCII text"
#
1. now change maven-install-plugin dependency version in kohlschutter-parent's pom.xml from 3.1.1 to 3.1.2
mvn clean install -Dignorant -DskipTests
file $HOME/.m2/repository/com/kohlschutter/kohlschutter-parent-multirelease/1.7.2/kohlschutter-parent-multirelease-1.7.2.pom
#
1. the above command now returns something like "Zip archive data, at least v1.0 to extract, compression method=store"
#
1. contents of the zip file:
1. META-INF/
1. META-INF/MANIFEST.MF
1. META-INF/maven/
1. META-INF/maven/com.kohlschutter/
1. META-INF/maven/com.kohlschutter/kohlschutter-parent-multirelease/
1. META-INF/maven/com.kohlschutter/kohlschutter-parent-multirelease/pom.xml
1. META-INF/maven/com.kohlschutter/kohlschutter-parent-multirelease/pom.properties}}
Affects: 3.1.2
Issue Links:
-
MNG-8138 Maven internal state should not allow to become "broken" ("is caused by")
-
MINSTALL-200 "mvn jar:jar install:install" installs a jar instead of a pom
-
MINSTALL-189 Add parameter to lax project validation
Remote Links:
1 votes, 7 watchers
Tamas Cservenak commented
This is not install/deploy plugin bug, but Maven bug: MNG-8138 In short, when MNG-8138 is fixed your project will fail, and reason is following: Your module kohlschutter-parent-multirelease declares packaging=pom in POM, but despite that it builds a JAR and attaches it as main JAR. This brings Maven inner state into "invalid state": a project that is packaging=pom, but has attached a JAR as main artifact. This should not happen. Workaround for now: skip jar plugin in module kohlschutter-parent-multirelease.
Tamas Cservenak commented
This issue is not related to install plugin: user has a POM packaging=pom but in that same POM he builds a JAR and attaches built JAR as main artifact. The MNG-8138 should prevent this from happening. Basically, the project is in "undefined" state that confuses install plugin, and installs the attached main JAR as POM (as packaging=pom).
Christian Kohlschütter commented
Thanks for the clarification!
The declaration of the jar plugin is in a parent POM that is supposed to be applied for any subprojects. This had worked until version 3.1.1. Such a change in behavior in a patch-level release is very unexpected, and also not declared in the change log.
I'm not arguing that this should be correct behavior, it just happened to be the previous one.
I have fixed my configuration by adding a profile that disables the maven-jar-plugin as much as possible for POM artifacts, as follows:
<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>
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 assume the second part will no longer be necessary in version 3.1.3 because it would fail in case the jar wasn't empty, right?
@slawekjaranowski MINSTALL-189 refers to a fix to 3.1.1; this is about 3.1.2.
fwiw, the problem remains unresolved in 3.1.4.