I want to set project version for all modules and their children only in one place – in properties of the main pom.xml. This is my test project that has the following structure:
Project
|-- project-api
|-- project-foo
|-- project-foo-bar (uses project-api)
In Project/pom.xml
I have:
<properties>
<revision>1.0.0</revision>
</properties>
<modules>
<module>project-foo</module>
<module>project-api</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.project</groupId>
<artifactId>project-api</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
</dependencyManagement>
In Project/project-foo/project-foo-bar/pom.xml
I have:
<dependencies>
<dependency>
<groupId>org.project</groupId>
<artifactId>project-api</artifactId>
</dependency>
</dependencies>
When I build whole project (via mvn clean install
in Project
folder) then all modules are built without any problems. However, when I want to build only project-foo-bar
(via mvn clean install
in Project/project-foo/project-foo-bar
) I get:
[ERROR] Failed to execute goal on project project-foo-bar: Could not
resolve dependencies for project
org.project.foo:project-foo-bar:jar:1.0.0: Failed to collect
dependencies at org.project:project-api:jar:1.0.0: Failed to read
artifact descriptor for org.project:project-api:jar:1.0.0: The
following artifacts could not be resolved:
org.project:project:pom:${revision} (absent):
org.project:project:pom:${revision} was not found in
https://repo.maven.apache.org/maven2 during a previous attempt. This
failure was cached in the local repository and resolution is not
reattempted until the update interval of central has elapsed or
updates are forced -> [Help 1]
Could anyone say how to fix it?