0

It is something likes Maven: Non-resolvable parent POM but not the same.

I have a parent pom

<groupId>group</groupId>
<artifactId>parent</artifactId>
<version>SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
    <module>module1</module>
    <module>module2</module>
    <module>module3</module>
</modules>

module1 defines some dependencies using dependencyManagement

child pom: module3/pom.xml trying to import module1

<parent>
    <artifactId>group</artifactId>
    <groupId>parent</groupId>
    <version>SNAPSHOT</version>
    <relativePath>../</relativePath>
</parent>

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>group</groupId>
      <artifactId>module1</artifactId>
      <version>SNAPSHOT</version>
      <scope>import</scope>
      <type>pom</type>
      <!--
      <systemPath>../module1</systemPath>
      -->
    </dependency>
  </dependencies>
</dependencyManagement>

If I try to build the parent, it is OK

mvn validate
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:

... ...

[INFO] parent ............................................ SUCCESS [0.128s]
[INFO] module1 ........................................... SUCCESS [0.011s]
[INFO] module2 ........................................... SUCCESS [0.009s]
[INFO] module3 ........................................... SUCCESS [0.009s]
... ...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

But if I run the build in child module, it fails

mvn validate
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project group:module3:SNAPSHOT (/path-tp/project/module3/pom.xml) has 5 errors
[ERROR]     Non-resolvable import POM: Failure to find group:module1:pom:SNAPSHOT in https://repo1.maven.org/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced @ line 22, column 19 -> [Help 2]
... ...
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

What I'd tried

  • I'd try using systemPath but it is not supported for import scope.
  • I'd try move the import scope dependencies declaration from module3 to parent-module, but it failed complaining circular-dependency

How can I build/load the lone sub-module module3, or is there any other way to split tons of dependencyManagements to multi sub-module?

Community
  • 1
  • 1
William Leung
  • 1,556
  • 17
  • 26
  • 1
    Possible duplicate of [Maven Modules + Building a Single Specific Module](http://stackoverflow.com/questions/1114026/maven-modules-building-a-single-specific-module) – Tunaki Sep 05 '16 at 12:55
  • @Tunaki thanks for the information, it is worked using command line `mvn -pl module3 -am`, but actually I want to load the sub-module pom from some other utilities likes "running lifecycle from jetbrains IDEA" / "using ant integration (maven-ant) to load dependencies", there is no better support for those situations. maybe I had to move all `dependencyManagements` to parent pom – William Leung Sep 05 '16 at 13:13

1 Answers1

0

When working at parent level, Maven is able to resolve dependencies between the modules.

But if your are working inside module 3, it has no idea of the fact that module1 is a sibling module of the project.

You need to install module 1 first if you want to work inside module 3 directly.

YMomb
  • 2,366
  • 1
  • 27
  • 36
  • That's why I try using `systemPath` but found that maven has no support for this type of imports – William Leung Sep 05 '16 at 13:17
  • 1
    @WilliamLeung Go to the root level of your project make a `mvn install`. Afterwards use `mvn -pl ...` never change into the folder...and systemPath will never work.... – khmarbaise Sep 05 '16 at 13:56