Skip to content

Instantly share code, notes, and snippets.

@gerardbosch
Last active November 24, 2020 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerardbosch/cffd7bf8eaf6be4ea658e3599cb04e98 to your computer and use it in GitHub Desktop.
Save gerardbosch/cffd7bf8eaf6be4ea658e3599cb04e98 to your computer and use it in GitHub Desktop.
JGitVer multi-module / service parent POM
<!-- While all the below belongs to the same project/build unit, this Microservice POM corresponds to a different project (different lifecycle, repository,...) -->
<parent>
<groupId>com.example.myproj.framework</groupId>
<artifactId>myproj-parent-ms</artifactId>
<version>1.2.3</version> <!-- Just example version -->
</parent>
<groupId>com.example.myproj.microservice</groupId>
<artifactId>microservice-a</artifactId>
<version>COMPUTED_BY_JGITVER</version> <!-- different version from all the below! clearly not 1.2.3! -->
<groupId>com.example.myproj.framework</groupId>
<artifactId>myproj-framework</artifactId>
<version>COMPUTED_BY_JGITVER</version>
<packaging>pom</packaging>
<modules>
<module>myproj-dependencies</module>
<module>myproj-libs</module>
<module>myproj-starters</module>
<module>myproj-archetypes</module>
<module>myproj-parents</module>
</modules>
<parent>
<groupId>com.example.myproj.framework</groupId>
<artifactId>myproj-libs</artifactId>
<version>COMPUTED_BY_JGITVER</version>
</parent>
<artifactId>myproj-lib-utils</artifactId>
<parent>
<groupId>com.example.myproj.framework</groupId>
<artifactId>myproj-parents</artifactId>
<version>COMPUTED_BY_JGITVER</version>
</parent>
<!-- Microservice parent uses a different groupId -->
<groupId>com.example.myproj.microservice</groupId>
<artifactId>myproj-parent-ms</artifactId>
<packaging>pom</packaging>
<!-- PROBLEM EXAMPLE -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.example.myproj.framework</groupId>
<artifactId>myproj-lib-utils</artifactId>
<!--
| The problem is here! Any way to express "the same version of this POM file"?
|
| This will take the version of theMicroservice that uses this parent POM (the version defined in the
| Microservice POM in its own project, which is not the same tan this current one.
|-->
<version>${project.version}</version> <!-- A dirty workaround: I replaced it by ${project.parent.version}, see below -->
</dependency>
</dependencies>
</dependencyManagement>
<!-- I solved it defining this: -->
<properties>
<!--
| Required as ${project.version} would make the microservices to use its own version. Use their parent
| version instead as it matches the framework version.
| This work as long as a microservice does *not define* its own "proxy" parent. In that case, manually
| overriding this property in the microservice with the framework version will be required
| which is inconvenient/error prone.
|-->
<proteo4-framework.version>${project.parent.version}</proteo4-framework.version>
</properties>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment