1

Here is a sample repository for this case: https://github.com/xShadov/maven-plugin-dependency-sample

When maven plugin uses a plugin dependency, and that dependency comes from the same project, maven cannot do it - it fails immediately. That is not the case with normal dependencies, only plugin dependencies.

I try to do it with spring-cloud-contract-maven-plugin, but the case is generic, it happens with every plugin. Spring cloud contract in their samples have exactly the same case (beer-common-dependency), but looking at their README, they have the same problem (You can run Maven from the root folder once the "common" module has been installed.).

Is there a way to solve it? I couldn't find one, and neither could guys from spring cloud contract, so probably not, but I want to be sure. Is it a bug or intended maven behavior?

This problem is serious for me, it's not possible to build a project with a single command, and complicates things even further on CI, because of version mismatch.

Shadov
  • 5,421
  • 2
  • 19
  • 38
  • So are you talking about `mvn clean install`, or something like `mvn clean package`? – J Fabian Meier Aug 24 '23 at 13:38
  • `mvn clean install` – Shadov Aug 24 '23 at 22:11
  • What do you mean exactly by plugin dependency? A dependency of the plugin, or a dependency you add to the plugin definition in your POM? Is this purely a problem of build order? – J Fabian Meier Aug 25 '23 at 08:35
  • Have a look at the repo I linked, it demonstrates this problem exactly. Problem is that dependency of a plugin comes from the same project, and maven immediately throws error instead building. This is not a build order problem. – Shadov Aug 25 '23 at 13:18
  • I just mean that if `plugin-dependency-module` is build before `business-module`, it does not matter any more. Then, `plugin-dependency-module` is in the local repository and therefore can be read like any other dependency. I do I misunderstand something? – J Fabian Meier Aug 25 '23 at 14:41
  • That's exactly how it works for later builds, but on the first build `plugin-dependency-module` is not in a local repository. If you download that sample repo, run `mvn clean install` in root folder - it will fail. If you run `mvn clean install` on `plugin-dependency-module` alone, it will build, then run it in root folder and it will work - but it's 2 separate maven builds, not one. – Shadov Aug 25 '23 at 22:03
  • The thing I find very confusing. If you run `mvn clean install` in the root folder, and the order is correct, meaning `plugin-dependency-module` is build before `business-module`, then `plugin-dependency-module` will be installed in the local repository, and THEN `business-module` is build. So I cannot really wrap my head around why it should make a difference if you build `plugin-dependency-module` separately. – J Fabian Meier Aug 26 '23 at 07:39
  • Because maven does some starting validation before building anything, and that validation fails immediately, because maven cannot find `plugin-dependency-module` in repository. So nothing is built. – Shadov Aug 28 '23 at 10:14

0 Answers0