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>
Sorry to be a bit late on this question I did not saw it before.
If you are in the same multi-module project, then usage of jgitver should not change the way you declare dependencies between sub-modules. Even with jgitver in the party you should still reference your sub-modules using
project.version
<dependency> <groupId> com.test</groupId> <artifactId>common-module</artifactId> <version>${project.version}</version> <!-- use a reference to the POM model --> </dependency>
For the IDE, the problem is a bit different because they do not like that much the dynamic behavior of jgitver (same for Eclipse & Intellij IDEA at least). You can have a look at the wiki page about jgitver IDE usage by using profiles and/or deactivation ; you can then use your IDE normally but you will have to delegate to either maven or gradle a normal build for release/deployments.
Hope that helps.
--
Matthieu, author and maintainer of jgitver