0

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-pluginis 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

Christian
  • 1,664
  • 1
  • 23
  • 43

2 Answers2

0

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.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • Thank you for the answer. The reason why we created the fat-jar in the first place was the jar will be used as CLI command and as maven plugin. But for testing we will remove it. – Christian Mar 25 '19 at 06:26
  • Ok currently I don't think the fat-jar is the source of the problem. But removing it for testing helped me to find the problem. Still I don't understand the problem in all the details. – Christian Mar 26 '19 at 08:31
0

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.

Christian
  • 1,664
  • 1
  • 23
  • 43