It should work, since the dependencyManagement
do not declare an actual dependency, but only says "if someone will ask for it - that's the version". From the error log it seems that you added not only the dependencyManagement
, but also an actual dependency to the pom - it looks for the common-jar dependency for the common-jar project itself.
Can I add a child common project in the root project's dependency management section
-
21-09-2022 - |
문제
I am working on an application which got multiple projects. I am trying add dependency management for one of the common project in the root POM so that I can ensure that all projects uses the same version.
Root/parent pom contain
<groupId>com.citylimited</groupId>
<artifactId>maven-master-project</artifactId>
<version>12.3.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Maven Master Project</name>
<dependencyManagement>
<dependencies>
<!-- COMPILE Dependencies -->
<dependency>
<groupId>com.city.common</groupId>
<artifactId>common-project-jar</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<dependencyManagement>
When I do maven build from my common project it fails as shown below.
[ERROR] Failed to execute goal on project common-project-jar: Could not resolve dependencies for project com.citylimited:common-project-jar:jar:12.3.2-SNAPSHOT
: Failure to find com.citylimited:common-project-jar:jar:12.3.2-SNAPSHOT in http://server1/nexus/content/groups/public was cached in the local repository, re
solution will not be reattempted until the update interval of internal-city-repository has elapsed or updates are forced -> [Help 1]
[ERROR]
Questions:
- What causing the above issue ?
- Can I add a child common project in the root project's dependency management section and refer in all other child projects?.
해결책
다른 팁
AFAIK, you cannot do this. In practice, the jar was not built yet, so it does not exist.
Anyway, declaring the jar as a dependency in any of the child modules with ${project.version} will make sure they all get it (the right version).
Just make sure the jar is built before it's used by others (reactor build order).
I hope this helps.
제휴하지 않습니다 StackOverflow