0

我正在尝试使用 maven-replacer-plugin 查找并替换带有 pom.xml 的 html 标记。使用当前配置,我收到“缺少结束标记地址”的错误,这意味着 pom 没有转义 open tag<和 close tag >

<plugin>
    <groupId>com.google.code.maven-replacer-plugin</groupId>
    <artifactId>replacer</artifactId>
    <version>1.5.2</version>
    <executions>      
        <execution>
        <id>replace-script-reset-path-variable</id>
        <phase>prepare-package</phase>
        <goals>
            <goal>replace</goal>
        </goals>
        <configuration>
            <includes>
            <include>${basedir}/books/*.xml</include>
            </includes>
            <replacements>
                <replacement>
                    <token>/<(address)>/</token>
                    <value>/<(address)>//abc.com</value>
                </replacement>
            </replacements>                     
        </configuration>
        </execution>                        
    </executions>
</plugin>

目的是将源文件中具有 html 标记的所有行替换<address><address>abc.com/

这是我的源文件的示例:

<address>books/category/ebooks1/index.html</address>
<address>books/category/ebooks2/index.html</address>
<address>books/category/ebooks3/index.html</address>
<address>books/category/ebooks4/index.html</address>
<address>books/category/ebooks5/index.html</address>

应用正则表达式后,预期的源文件应为:

<address>abc.com/books/category/ebooks1/index.html</address>
<address>abc.com/books/category/ebooks2/index.html</address>
<address>abc.com/books/category/ebooks3/index.html</address>
<address>abc.com/books/category/ebooks4/index.html</address>
<address>abc.com/books/category/ebooks5/index.html</address>
4

2 回答 2

1

您需要<在实际的 POM 文件中转义为&lt;, 和类似的<,

于 2013-09-13T14:29:41.263 回答
0

我建议您使用令牌和价值文件。在它们中你可以简单地写这个:

<address>

<address>abc.com

然后您只需输入文件的正确路径。例如:

<tokenFile>resources/common/address-token.txt</tokenFile>
<valueFile>resources/common/address-value.txt</valueFile>

有关更多详细信息,请参阅Replacer 使用指南

于 2015-02-09T11:44:57.980 回答