maven-plugin-plugin doesn't package plugin descriptor in jar file

I have this in my pom.xml file as a maven plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.9.0</version>
<configuration>
<packagingTypes>
<packagingType>jar</packagingType>
</packagingTypes>


</configuration>
<executions>
<execution>
<id>default-descriptor</id>
<phase>process-classes</phase>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.9.0</version>
<configuration>
<packagingTypes>
<packagingType>jar</packagingType>
</packagingTypes>


</configuration>
<executions>
<execution>
<id>default-descriptor</id>
<phase>process-classes</phase>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
The packaging of my project isn't currently set to
<packaging>maven-plugin</packaging>
<packaging>maven-plugin</packaging>
but even If I try to set it to that the plugin.xml still doesn't get packaged in the jar file. To be clear plugin.xml gets generated under classes/META-INF/maven , but when I open the generated .jar file and go to META-INF/maven the plugin.xml file isn't there. And so when I try to include this project as a plugin it fails with plugin descriptor not found.
31 Replies
JavaBot
JavaBot8mo ago
This post has been reserved for your question.
Hey @nikcho-kouhai! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Peter Rader
Peter Rader8mo ago
What is your goal?
nikcho-kouhai
nikcho-kouhaiOP8mo ago
well for the most part I want to make a maven plugin
Peter Rader
Peter Rader8mo ago
I mean your maven goal? install or package or clean or whatever?
nikcho-kouhai
nikcho-kouhaiOP8mo ago
I tried with mvn package and with mvn clean install
Peter Rader
Peter Rader8mo ago
Ok install is good.
nikcho-kouhai
nikcho-kouhaiOP8mo ago
and with mvn install so none of those worked
Peter Rader
Peter Rader8mo ago
Where exactly is your plugin.xml stored in src/main/resources/META-INF/maven?
nikcho-kouhai
nikcho-kouhaiOP8mo ago
it's generated by maven-plugin-plugin in target/classes/META-INF/maven/plugin.xml
Peter Rader
Peter Rader8mo ago
Hm, generated, hm?
nikcho-kouhai
nikcho-kouhaiOP8mo ago
do I need to have a plugin.xml in my resources?
Peter Rader
Peter Rader8mo ago
No
nikcho-kouhai
nikcho-kouhaiOP8mo ago
yeah that's why I included this maven-plugin-plugin thing which supposedly makes plugin descriptors. And it does make the plugin descriptor, it just doesn't package it in my jar
Peter Rader
Peter Rader8mo ago
I think the order of the mojos are wrong. I think the jar is packed before the plugin.xml is written.
nikcho-kouhai
nikcho-kouhaiOP8mo ago
that could certainly be a reason
Peter Rader
Peter Rader8mo ago
Try mvn clean compile plugin:addPluginArtifactMetadata package install Funny thing is: plugin:addPluginArtifactMetadata should be callend during package automatically.
nikcho-kouhai
nikcho-kouhaiOP8mo ago
well it probably does get called, because it didn't work I literally saw this exact same thing done in another project I compiled that other project the same way I do mine and it gets its plugins.xml packaged inside the jar
Peter Rader
Peter Rader8mo ago
Did my suggestion work?
nikcho-kouhai
nikcho-kouhaiOP8mo ago
nope
Peter Rader
Peter Rader8mo ago
Ah dammit.
nikcho-kouhai
nikcho-kouhaiOP8mo ago
oh also my project has a parent pom, could that be a potential cause?
Peter Rader
Peter Rader8mo ago
Can you share what reactor does? Can you share the output of mvn validate? Parent pom could change the build process.
nikcho-kouhai
nikcho-kouhaiOP8mo ago
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.niki:qtplayerbindings:jar:1.0-SNAPSHOT
[WARNING] 'version' contains an expression but should be a constant. @ com.niki:qtplayerbindings:${parent.version}, D:\gitroot\player\qtplayerbindings\pom.xml, line 15, column 14
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ com.niki:player-platform:1.0-SNAPSHOT, D:\gitroot\player\pom.xml, line 56, column 29
[WARNING] The expression ${parent.version} is deprecated. Please use ${project.parent.version} instead. @ com.niki:qtplayerbindings:${parent.version}, D:\gitroot\player\qtplayerbindings\pom.xml
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ---------------------< com.niki:qtplayerbindings >----------------------
[INFO] Building qtplayerbindings 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- javacpp:1.5.11-SNAPSHOT:build (javacpp-validate) @ qtplayerbindings ---
[INFO] Detected platform "windows-x86_64"
[INFO] Building platform "windows-x86_64"
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.291 s
[INFO] Finished at: 2024-04-05T20:43:21+03:00
[INFO] ------------------------------------------------------------------------
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.niki:qtplayerbindings:jar:1.0-SNAPSHOT
[WARNING] 'version' contains an expression but should be a constant. @ com.niki:qtplayerbindings:${parent.version}, D:\gitroot\player\qtplayerbindings\pom.xml, line 15, column 14
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ com.niki:player-platform:1.0-SNAPSHOT, D:\gitroot\player\pom.xml, line 56, column 29
[WARNING] The expression ${parent.version} is deprecated. Please use ${project.parent.version} instead. @ com.niki:qtplayerbindings:${parent.version}, D:\gitroot\player\qtplayerbindings\pom.xml
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ---------------------< com.niki:qtplayerbindings >----------------------
[INFO] Building qtplayerbindings 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- javacpp:1.5.11-SNAPSHOT:build (javacpp-validate) @ qtplayerbindings ---
[INFO] Detected platform "windows-x86_64"
[INFO] Building platform "windows-x86_64"
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.291 s
[INFO] Finished at: 2024-04-05T20:43:21+03:00
[INFO] ------------------------------------------------------------------------
well I also wrote the parent pom and from what I remember I don't think it does such a thing ...probably
Peter Rader
Peter Rader8mo ago
My only suggestion now is to put the plugin.xml to src/main/resources/META-INF/maven
nikcho-kouhai
nikcho-kouhaiOP8mo ago
I suppose I'll give it a shot nope yet again nowhere to be found in the jar file which is at this point starting to get from pretty odd to downright what the hell since aren't resources in particular supposed to be bundled in the jar file?
Peter Rader
Peter Rader8mo ago
Weird
nikcho-kouhai
nikcho-kouhaiOP8mo ago
yeah, that's what I've been saying to myself silently over and over for the past 4 hours
JavaBot
JavaBot8mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
nikcho-kouhai
nikcho-kouhaiOP8mo ago
okay so the problem was with an execution of the maven-jar-plugin I am not entirely sure why/how/what but I deleted it and made maven run the default-cli execution and it works so thanks
JavaBot
JavaBot8mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
JavaBot
JavaBot8mo ago
Post Closed
This post has been closed by <@359755548973072397>.
Want results from more Discord servers?
Add your server