未过滤的Maven Build Number插件版本

时间:2015-02-09 11:10:14

标签: git maven

我想在属性文件中过滤buildnumber-maven-plugin提供的buildNumber(git修订版号),以便我可以从我的软件中访问它。

我得到了以下pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>xxxx</groupId>
        <artifactId>xxxx</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>..</relativePath>
    </parent>
    <artifactId>xxxx</artifactId>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources/</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.3</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                        <configuration>
                            <shortRevisionLength>5</shortRevisionLength>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

和folloling文件src / main / resources / revision.properties:

branch = ${scmBranch}
revision = ${buildNumber}
version = ${project.version}

运行mvn clean install之后,产生以下输出:

...
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ xxx ---
[INFO] Deleting D:\parsp\git\acm-utils\target
[INFO]
[INFO] --- buildnumber-maven-plugin:1.3:create (default) @ xxx ---
[INFO] ShortRevision tag detected. The value is '5'.
[INFO] Executing: cmd.exe /X /C "git rev-parse --verify --short=5 HEAD"
[INFO] Working directory: D:\parsp\git\acm-utils
[INFO] Storing buildNumber: 70cd7 at timestamp: 1423479895763
[INFO] Storing buildScmBranch: master
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ xxx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
...

我在target / classes中获得以下resultinf文件,其中只有maven版本被过滤到该文件中:

branch = ${scmBranch}
revision = ${buildNumber}
version = 1.0.0-SNAPSHOT

我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

这更像是一种解决方案,而不是答案,但我认为 validate后跟install为我工作。但是,这当然没有实用的方法来使用它......

在此期间你有没有找到任何解决方案?