How to specify the relationship between child modules? I have a server module and a client. The second depends on the first. But when building an error occurs:

Failed to execute goal on project client: Could not resolve dependencies for project com.vladhuk:client:jar:0.9-SNAPSHOT: Could not find artifact com.vladhuk:server:jar:0.9-SNAPSHOT -> [Help 1] 

Searching the Internet, I found a solution only for those who connect dependencies from public repositories. In my case, these are just neighboring modules.

  • one
    Run mvn install for the module that you are installing as a dependency for another module. This command will put it into the local repository. - Vladimir Yarovoy
  • @Vladimir helped) Also, however, it was required to execute this command for the parent module. - Vladislav Hukovskii

1 answer 1

You need to add both modules to the "reactor" . Thus, you guarantee that the dependencies will be taken from the module’s build directory (the relative path is written in the reactor) during the build, and not from the repositories. Even if you do not perform the install step, dependencies will still be found.

 <project> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>example-parent</artifactId> <packaging>pom</packaging> <version>1.0</version> <name>Simple Parent Project</name> <modules> <module>example-server</module> <module>example-parent</module> </modules> <!- всё остальное, что общее для всего проекта - зависимости, плагины, и так далее --> </project> 
  • How to add modules to the reactor? If it means: register them in the <modules> tag, then I have them registered, and nevertheless you still have to install. - Vladislav Hukovskii pm
  • Well, something needs to be exactly launched, you need to collect it, Java does not know how to depend on the source code. Just not necessarily install , you can, for example, package . Well, of course, you don’t need to run on everything separately, you can only start on parent. - JBaruch