I'm using jgitver library to automatically generate semver using state of the Git repository.
I have a multi module project where modules are interdependent, meaning if I make change to one module then other modules should start referring to the new version of the changed module.
All the modules are in the same Git repository, so any change in the Git changes the version of all modules. Following is an example of my project structure
.git (Common repository)
module1
common-module
pom.xml (Parent POM)
Following is an example of how I have included a dependency module
<-- POM of module1, includes common-module-->
<dependency>
<groupId> com.test</groupId>
<artifactId>common-module</artifactId>
<version>1.0.0</version> <!-- version generated by jgitver -->
</dependency>
Since at any time version generated by jgitver would be same for module1 and common-module, as they're in the same Git repository, I don't want to hard code the version across all modules. As if the version changes then I would have to manually change the version in all modules for common-module dependency.
Is there a variable like ${project.version} that can be used to refer to current version generated by jgitver?
I'm hoping to configure the module1 as below
<dependency>
<groupId> com.test</groupId>
<artifactId>common-module</artifactId>
<version>${JGITVER_GENERATED_VERSION_VARIABLE}</version> <!-- version generated by jgitver -->
</dependency>
It turns out there is a property which can be used to specify the calculated version
jgitver.calculated_versionsince0.2.0-alpha2release. However it's supposedly not needed since the same0.2.0-alpha2release.Sub modules which want to specify the calculated version as the version of the dependency are supposed to use
project.version. Static value remains 0 and when project is built using maven,project.versionis resolved to correct value.I came across this after facing following issue Multi module project: Building only a sub module does not resolve versions for deps
project.versionworks as long as it's project is built from the parent, it doesn't work if the project is built from the sub module directory itself.project.versionresolves to0and hence results in an errorcommon-module-0.jarmissing. The issue has been closed and it'sjgitveris supposed to work from sub module also since0.2.0-alpha2. However it doesn't work with certain versions of maven.On the github page of the project it's mentioned that minimum version of maven should be
3.3.2Ref: jgitver-maven-plugin requires at least maven-3.3.2 to work correctly.. However for mejgitver 1.1.4doesn't work with maven3.3.5and build keeps on resulting in errorcommon-module-0missing when building submodules only. I can confirm that it works for maven3.3.9. I came to know that because I was working from two different machines with two different versions of maven. I have updated maven to current version3.5.2and it works fine from the submodules.Note: It seems that my IDE
STS 3.8.4/Eclipse Mars.2 (4.5.2)isn't able to resolve the calculated version of project fromproject.versionand it tries to resolvecommon-module-0. It's resolved only as long as this project is open in Eclipse. May be that's how it's supposed to work.