我正在使用Maven插件git-commit-id-plugin来获取诸如commitId之类的信息。我的maven-project在子文件夹中有一些子模块,如下所示:
hfe/pom.xml -
- backend/pom.xml
- frontend/pom.xml
hfe是git-chekout,因此存在.git文件夹。
在构建部分的hfe / pom.xml中,我放置了插件git-commit-id-plugin,以便它将在每个子模块中执行。
如果我现在在hfe / backend /文件夹中执行“ mvn软件包”,则将在生成的git-property-file中获取整个项目的最新commitId。是否可以获取子文件夹hfe / backend的最新commitId。
为了清楚起见,我想在文件hfe / backend / target / git.properties中添加commitId 90791bcf ...,但此刻我得到了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
也许还有另一个Maven插件可以做到这一点?
答案 0 :(得分:2)
检查此git-commit-id/maven-git-commit-id-plugin
issue 137是否有帮助:
来自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>