Eclipse Maven buildnumber,在文件中替换不';行不通
我想把buildNumber maven插件中的Eclipse Maven buildnumber,在文件中替换不';行不通,eclipse,maven,pom.xml,versioning,Eclipse,Maven,Pom.xml,Versioning,我想把buildNumber maven插件中的buildNumber放在一个XML文件中 我配置了buildnumber插件。我可以看出它是有效的,因为finalName被设置为一个内部版本号。然后我配置了资源过滤。我可以看到资源deployment.xml被过滤,因为它替换了${project.version}。但是,它不会替换${buildNumber}。我需要做些什么才能让它工作?我看了一下,但它不像那里那样工作,尽管那里做的差不多 pom.xml: <!-- build
buildNumber
放在一个XML文件中
我配置了buildnumber插件。我可以看出它是有效的,因为finalName被设置为一个内部版本号。然后我配置了资源过滤。我可以看到资源deployment.xml
被过滤,因为它替换了${project.version}
。但是,它不会替换${buildNumber}
。我需要做些什么才能让它工作?我看了一下,但它不像那里那样工作,尽管那里做的差不多
pom.xml:
<!-- build number -->
<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>
<format>{0,number}</format>
<items>
<item>buildNumber</item>
</items>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}-${project.version}-r${buildNumber}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/deployment.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/deployment.xml</exclude>
</excludes>
</resource>
</resources>
</build>
<!-- dummy scm for build number plugin -->
<scm>
<connection>scm:git:http://127.0.0.1/dummy</connection>
<developerConnection>scm:git:https://127.0.0.1/dummy</developerConnection>
<tag>HEAD</tag>
<url>http://127.0.0.1/dummy</url>
</scm>
我在看目标/课程。当我查看target/xxx-1.0.0-build-SNAPSHOT-r36/WEB-INF/classes/deployment.xml
时,似乎内部版本号已正确打包到war文件中。我想我可以接受这一点,尽管我仍然不明白为什么在替换buildNumber之后会重新创建文件target/classes/deployment.xml
更奇怪的是:当我编辑src/main/resources/deployment.xml
时,文件target/classes/deployment.xml
也会更新。它一定是由EclipseIDE完成的
我已将deployment.xml移动到
resources filtered/deployment.xml
,但覆盖行为仍然存在。在xml中有一个属性部分。
通过这种方式,您可以告诉Maven您的自定义属性,这些属性将在构建时被替换
<project>
<properties>
<buildNumber>YOUR_BUILD_NUMBER</buildNumber>
<anotherProperty>foo</anotherProperty>
</properties>
</project>
您的构建号
以下是预定义Maven属性的非正式列表:
<root>
<build>
<buildNumber>${buildNumber}</buildNumber>
<buildNumber>1.0.0-BUILD-SNAPSHOT</buildNumber>
<buildNumber>${project.finalName}</buildNumber>
</build>
</root>
[INFO] --- maven-resources-plugin:3.1.0:copy-resources (copy-resources) @ rator ---
[INFO] Using 'Cp1252' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 83 resources
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ rator ---
[INFO] Skipping the execution.
[INFO]
.. compiling ..
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ rator ---
[INFO] Not copying test resources
[INFO]
<project>
<properties>
<buildNumber>YOUR_BUILD_NUMBER</buildNumber>
<anotherProperty>foo</anotherProperty>
</properties>
</project>