maven jar / war插件添加git哈希提交id

时间:2018-01-10 19:47:18

标签: git maven buildnumber-maven-plugin

我想在jar的manifest.mf文件中添加Git commit id。

我在pom xml插件配置中完成了以下配置,

当我发布maven目标时,我能够获得git修订版 clean buildnumber:create install

是否可以在不发出buildnumber:create和插件配置的情况下获取git修订版?

的pom.xml

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>${maven.jarplugin.version}</version>
    <configuration>
        <archive>
            <manifest>    
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                <addDefaultSpecificationEntries>false</addDefaultSpecificationEntries>
            </manifest>
            <manifestEntries>
                <Implementation-Build>${buildNumber}</Implementation-Build>
            </manifestEntries>
        </archive>
    </configuration>
</plugin>

<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>
    <configuration>
        <doCheck>true</doCheck>
        <doUpdate>true</doUpdate>
    </configuration>
</plugin>

1 个答案:

答案 0 :(得分:0)

确保插件已在<plugins>部分中定义,而不仅仅是<pluginManagement>