[英]Maven Build Number Plugin version not filtered
I'd like to filter my buildNumber (git revision number), provided by the buildnumber-maven-plugin in a property file, so I can access it from my software. 我想过滤由属性文件中的buildnumber-maven-plugin提供的buildNumber(git修订版号),以便可以从软件中访问它。
I got the following pom: 我收到以下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>
and the folloling file src/main/resources/revision.properties: 和以下文件src / main / resources / revision.properties:
branch = ${scmBranch}
revision = ${buildNumber}
version = ${project.version}
After I ran mvn clean install, which produces the following output: 在运行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]
...
I get the following resultinf file in target/classes, where only the maven version is filtered into that file: 我在目标/类中得到以下resultinf文件,其中只有Maven版本被过滤到该文件中:
branch = ${scmBranch}
revision = ${buildNumber}
version = 1.0.0-SNAPSHOT
Is there anything I missed? 我有什么想念的吗?
This is more of a work around, than an answer, but I figured that a validate
followed by install
works for me. 这更像是一种解决方法,而不是一个答案,但是我认为先进行
validate
进行install
对我来说很有效。 But that's of course no practical way to use it... 但这当然不是使用它的实用方法...
Did you find any solutions by yourself in the meantime? 在此期间,您自己找到了解决方案吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.