maven-install-plugin
maven-install-plugin copied to clipboard
[MINSTALL-200] "mvn jar:jar install:install" installs a jar instead of a pom
Urs Keller opened MINSTALL-200 and commented
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>test-project-parent</artifactId>
<version>main-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
$ rm -rf ~/.m2/repository/com/example/test-project-parent
$ mvn jar:jar install:install
$ file ~/.m2/repository/com/example/test-project-parent/main-SNAPSHOT/*
.../test-project-parent-main-SNAPSHOT.pom: Zip archive data, at least v1.0 to extract, compression method=store
The behaviour is different in 3.1.1 where this command will install the pom. The output looks like this:
.../test-project-parent-main-SNAPSHOT.pom: XML 1.0 document text, ASCII text
Affects: 3.1.2
Issue Links:
- MNG-8138 Maven internal state should not allow to become "broken" ("is caused by")
- MINSTALL-201 Regression in 3.1.2 when installing pom artifact
Tamas Cservenak commented
See MDEPLOY-318, same issue same problem. Also see MNG-8137 and MNG-8138 as well.
Tamas Cservenak commented
And full story w/ explanation here https://github.com/spring-projects/spring-boot/issues/40952#issuecomment-2146868703
Tamas Cservenak commented
Direct mojo invocation like jar:jar instructs Maven "do create a JAR for the project", and Maven obeys (creates empty JAR with Maven metadata only as there are no classes). If using lifecycle (ie. invoking {}package{}), it would not been invoked as packaging=pom does not use JAR plugin at all. Basically by direct mojo invocations you are circumventing the lifecycle (and packaging) of Maven. That is another problem (see related MNG issues) that Maven allows doing this, and will end up in "inconsistent internal state" (Maven Project of packaging POM will have JAR attached as main JAR, replacing the POM artifact). But again, user instructed Maven to do so, by invoking jar:jar on a module, that would otherwise never invoke this goal as part of lifecycle.
Christian Kohlschütter commented
I've encountered the same problem. I just saw your bug report after filing MINSTALL-201 with some root cause analysis and a potential fix.