maven - maven git-commit-id-plugin:子文件夹/子模块的commitId
问题描述
我正在使用maven-git-commit-id-plugin
maven 插件来获取诸如 commitId 之类的数据。我的 maven 项目在子文件夹中有一些子模块,如下所示:
hfe/pom.xml -
- backend/pom.xml
- frontend/pom.xml
hfe
是 git-checkout,所以存在 .git 文件夹。
在hfe/pom.xml
构建部分中,我添加了它,maven-git-commit-id-plugin
以便它将在每个子模块中执行。
如果我现在mvn package
在文件夹中执行 a hfe/backend/
,我将在生成的 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 插件可以做到这一点?
解决方案
检查此git-commit-id/maven-git-commit-id-plugin
问题 137是否有帮助:
- 使用不同的 git 项目多次运行插件而不覆盖已经生成的属性。
- 使用 Git 子模块 SHA1 而不是父项目
来自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>
推荐阅读
- database - “删除键”与“永久删除键”:后者如何在数据存储中实现?
- python - 等到 PDF 页面使用 Selenium WebDriver for Python 加载
- android-studio - 如何在导航组件中查看片段何时更改为另一个片段
- sql - 使用 Hibernate 在 X 小时后更改列值
- java - 从 MainActivity 中的另一个 xml 获取元素
- python - 在 webbrowser 模块上使用格式
- python - 如何存储和自定义 jupyter notebook 幻灯片
- azure-application-insights - Azure Application Insight JavaScript SDK trackEvent 时间戳
- apache-nifi - NiFi 1.14 中缺少 ResizeImage 处理器
- charts - TradingView 时区设置问题