Question

I'm developing a maven project with several modules in eclipse. The parent pom.xml declares all submodules, and every submodule contains a pom.xml with a reference to the parent. Some submodules are dependent on other submodules, so I have added them as a dependency (m2e finds them when searching for dependencies). However, when I try to run a submodule outside eclipse using jetty (mvn -pl submodule jetty:run), I get the error that it is missing the other submodules.

In other words, and more elaborate: there's parent, sub1 and sub2. sub2 depends on sub1. I added

<modules>
  <module>sub1</module>
  <module>sub2</module>
</modules>

in the parent and

<parent>
  <groupId>group</groupId>
  <artifactId>parent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</parent>

In both sub1 and sub2, and

<dependency> 
  <groupId>group.parent</groupId>
  <artifactId>sub1</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</depdency>

in sub2.

When I run:

mvn -pl sub2 jetty:run

I get:

[INFO] Failed to resolve artifact.

Missing:
----------
1) group.parent:sub1:jar:0.0.1-SNAPSHOT

How can I get maven to find the submodule dependencies?

Était-ce utile?

La solution

Have you tried running mvn install in your parent project before running Jetty in the submodule? This will install your jars in your local Maven repository, following which Maven will be able to find them.

(Or I could be grossly misreading the complexity of your question, in which case: please correct me.)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top