使用git信息生成git.properties文件

Rak*_*eni 7 git maven

我正在尝试git.properties在我的项目中生成文件.我添加了git-commit-plugin依赖项pom.xml.请在下面找到我的代码

            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <version>2.1.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <verbose>true</verbose>
                    <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                    <dateFormat>MM-dd-yyyy '@' HH:mm:ss Z</dateFormat>
                    <generateGitPropertiesFile>true</generateGitPropertiesFile>               <generateGitPropertiesFilename>src/main/resources/git.properties</generateGitPropertiesFilename>
                    <failOnNoGitDirectory>true</failOnNoGitDirectory>
                </configuration>
            </plugin>
Run Code Online (Sandbox Code Playgroud)

还在gitignore文件中添加了git.properties.但我无法在我的项目中生成属性.

Rak*_*eni 5

我找到了我的问题的答案。上面的 pom.xml 有 git.properties 的插件。在同一个 pom.xml 中,我错过了添加包含的

    <includes>
    <include>**/*.properties</include>
    </includes>
Run Code Online (Sandbox Code Playgroud)

另外添加以下内容(除了插件管理之外)

        <plugin>
            <groupId>pl.project13.maven</groupId>
            <artifactId>git-commit-id-plugin</artifactId>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

希望这能解决您生成 git.properties 文件的问题