简体   繁体   中英

Why does Maven use a pom.xml of a provided build plugin?

We do have a simple maven pom like

<project xmlns="http://maven.apache.org/POM/4.0.0">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.xy.project.z</groupId>
  <artifactId>client</artifactId>
  <packaging>pom</packaging>

  <build>
    <plugins>
      <plugin>
        <groupId>org.xy.maven</groupId>
        <artifactId>own-maven-plugin</artifactId>
        <version>1.19.0</version>
        <executions>...</executions>
      </plugin>
    </plugins>
  </build>
</project>

As you may guess the own-maven-plugin is our own maven plugin created in another project and with an independent version. So far no problem. But out of nowhere (at least for me) the provided pom didn't run anymore. And it stopped with the message:

Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Failure to find org.xy.projcect:a:bundle:1.0.7-SNAPSHOT in http://repo.local:8081/repository/maven-public/ was cached in the local repository, resolution will not be reattempted until the update interval of internal-repository has elapsed or updates are forced

What happened. We have created a new version of own-maven-plugin this plugin was always a fat-jar containing all necessary dependencies. Now all we did we added just another dependency.

So there are two things I don't understand.

  1. Why does maven try to resolve all dependencies of an already created jar, that is used within the build-plugins .

  2. And why is the problem fixed after I have deleted .m2/org/xy/maven/own-maven-plugin/own-maven-plugin-1.19.0.pom

This is reproducible, adding the deleted pom fails the build. I didn't find any indication for my problem at the maven plugin description site .

So if someone has an explanation. Please let me know.

UPDATE-1: Updated error message

Maven plugins are usually not constructed as fat jars. They resolve their dependencies themselves.

If you have a fat jar that contains dependencies in its pom, then the dependencies are probably resolved as well, so you have the classes twice: Once in the fat jar and once in the dependencies.

I cannot say whether this explains all your errors, but I guess things are easier if you avoid the fat jar in the first place.

Ok found the reason for the problem.

The new dependency contained itself a dependency with a dependency of type bundle.

<dependency>
    <groupId>org.xy.maven</groupId>
    <artifactId>own-maven-plugin-dep</artifactId>
    <version>1.2.0</version>
    <type>bundle</bundle>
</dependency>

After removing this type it worked like charme, again. I don't know why <type>bundle</type> has been added in the first place. But I don't see any disadvantages by removing it.

Reading this about bundle type doesn't help much to understand why removing fixed my problem here.

This answer doesn't contain all answers for the question. And if someone provides a better one I am more than happy to change the accepted answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM