我正在使用maven-replacer-plugin来修改XML文件中的值,作为构建的一部分。
XML文件包含我需要替换的元素:
<id>foo</id>
我的POM中有以下内容:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>process-resources
</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${pom.basedir}/${air.app.descriptor}</file>
<replacements>
<replacement>
<token><id>.*</id></token>
<value><id>id.${application.name}.${environment.name}.${project.version}</id></value>
</replacement>
</replacements>
</configuration>
</plugin>
我在本地构建时工作正常。但是,在我们的CI构建服务器(Bamboo)上,我收到以下错误:
[INFO] --- replacer:1.5.3:replace (default) @ app-main ---
[ERROR] named capturing group is missing trailing '}'
[INFO] Replacement run on 0 file.
这两台机器都是Windows。
更新
我修改了我的替代品以使用XPATH:
<replacement>
<xpath>/application/id/text()</xpath>
<token>^.*$</token>
<value>${application.name}.${environment.name}.${project.version}</value>
</replacement>
现在我的错误略有不同,但问题似乎是一样的:
[INFO] --- replacer:1.5.3:replace (default) @ app-main ---
[ERROR] Error during XML replacement: named capturing group is missing trailing '}'
[INFO] Replacement run on 0 file.
答案 0 :(得分:3)
回答我自己的问题。
错误消息令人困惑。其中一个属性在CI配置中不可用。出于某种原因,replacer插件不允许<value>
中的文本包含{
,并且抛出错误,即使错误文本使其在Regexp中显示为错误。