I'm using the maven-git-commit-id-plugin maven plugin to get data like commitId. My maven project has some submodules in subfolders, like this:
hfe/pom.xml -
- backend/pom.xml
- frontend/pom.xml
hfe is the git-checkout, so there the folder .git exists.
In hfe/pom.xml in the build section I add the maven-git-commit-id-plugin so that it will be executed in every submodule.
If I do now a mvn package in the folder hfe/backend/, I will get the latest commitId of the whole project in the generated git-property-file. Is it possible to get the latest commitId of the subfolder hfe/backend.
To make it clear, I would like to have the commitId 90791bcf... in the file hfe/backend/target/git.properties, but in the moment I get the commitId d022a39342...:
/projects/hfe>git log -n 1 backend
commit 90791bcf145ee635c61f25c0ac62d0d66c49307f
Author: me
Date: Fri May 10 12:30:31 2019 +0200
/projects/hfe>git log -n 1
commit d022a39342ecd6bcedeafbaf4bd80db495fdf23c (HEAD -> master, origin/master, origin/HEAD)
Author: other
Date: Sun May 12 21:58:50 2019 +0200
Maybe there is another maven plugin which can do this?
Check if this git-commit-id/maven-git-commit-id-plugin issue 137 would help:
From TheSnoozer:
<!-- GIT COMMIT ID PLUGIN CONFIGURATION -->
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.5</version>
<executions>
<execution>
<phase>initialize</phase>
<id>get-the-git-infos-for-repository-one</id>
<goals>
<goal>revision</goal>
</goals>
<configuration>
<prefix>git1</prefix>
<dotGitDirectory>pathToRepositoryOne/.git</dotGitDirectory>
<generateGitPropertiesFilename>${project.build.outputDirectory}/repository_one_git.properties</generateGitPropertiesFilename>
</configuration>
</execution>
<execution>
<phase>initialize</phase>
<id>get-the-git-infos-for-repository-two</id>
<goals>
<goal>revision</goal>
</goals>
<configuration>
<prefix>git2</prefix>
<dotGitDirectory>pathToRepositoryTwo/.git</dotGitDirectory>
<generateGitPropertiesFilename>${project.build.outputDirectory}/repository_two_git.properties</generateGitPropertiesFilename>
</configuration>
</execution>
</executions>
<configuration>
<verbose>false</verbose>
<skipPoms>false</skipPoms>
<injectAllReactorProjects>true</injectAllReactorProjects>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
</configuration>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With