Reputation: 21
So my question is...how do I use the branch name I am currently in as part of the version for a dependency in my project?
To start off here is what I have.
I have three branches. master, Alpha and Beta.
Under each of these there is a common dependency being used called automation-jar.jar .... There are also two other client projects that use that jar file as a dependency.
Example: automation-jar pom.xml file
<groupId>com.example.jarfile</groupID>
<artifactId>example-jar</artifactId>
<version>${branch.name}-SNAPSHOT</version>
Example: client project 1 - pom.xml (Uses automation-jar as a dependency)
<dependency>
<groupId>com.example.jarfile</groupID>
<artifactId>example-jar</artifactId>
<version>${branch.name}-SNAPSHOT</version>
</dependency>
I can deploy the jar file with the specified "branch.name" no problem....My problem is, how do I make the version snapshot generic enough where it won't cause merge conflicts in Git?
For instance, if I hard code the <version>
to master-SNAPSHOT
or Alpha-SNAPSHOT
, it will cause conflicts when merging the branches.
Any ideas?
Thanks in advance!
Upvotes: 1
Views: 8768
Reputation: 321
Try to include the following plugin
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Then you can use ${scmBranch} for branchName
http://www.mojohaus.org/buildnumber-maven-plugin/usage.html
<dependency>
<groupId>com.example.jarfile</groupID>
<artifactId>example-jar</artifactId>
<version>${scmBranch}-SNAPSHOT</version>
</dependency>
Upvotes: 1