We have a reactor pom whose child modules are versioned independently, ie. child module declares it's own version that is independent of the version of the main pom. There is however a dependency between two child modules. How should be this dependency configured to always use the version that is declared by the actual module of the reactor pom?
I would expect that I can set up dependency management in the root pom and use some implicit properties to determine the version of child modules, but the best such option I can find :
${session.projectDependencyGraph.sortedProjects[0].version}
or simply
${reactorProjects[0].version}
so that the dependency management in the root pom would look like this:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>mygroup</groupId>
<artifactId>mySubmodule</artifactid>
<version>${reactorProjects[0].version}</version>
</dependency>
</dependencies>
</dependencyManagement>
looks unreliable because the reactor order may change when new modules or dependencies are added.
Maybe this usage scenario is discouraged by design and then I would like to know why.
Edit: As is suggested in comments, declaring a global properties with child versions in parent POM may be an option for newer versions of Maven. I would however like to see some analysis with respect to wider consequences like workflow, releasing, directory and repository settings, some plugins usage (e.g. version plugin) etc. For example I think that direct consequence of this approach is that I would have to release parent module whenever any of child modules are released. Although this is doable, it would impact the original idea of having an independent versioning.
project/parent/version
but it works forproject/version
. If it works and fits my needs I'd use it. – Anett