如何使用maven replacer插件替换java源代码中的值?

时间:2014-07-16 08:33:30

标签: maven-3 maven-replacer-plugin

<plugin>
    <groupId>com.google.code.maven-replacer-plugin</groupId>
    <artifactId>replacer</artifactId>
    <version>1.5.0</version>
    <executions>
        <execution>
            <id>DB schema-replacement</id>
            <phase>compile</phase>
            <goals>
                <goal>replace</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <includes>
            <include>src/main/java/com/swissre/gc7/dao/hibernate/*.java</include>
            <include>src/main/java/com/swissre/gc7/dao/*.java</include>
            <include>src/main/java/com/swissre/gc7/dao/hibernate/*.java</include>
            <include>src/main/java/com/swissre/gc7/dao/*/*/hibernate/*.java</include>
            <include>src/main/java/com/swissre/gc7/dao/*/*/valueGroup/hibernate/*.java</include>
        </includes>
        <replacements>
            <replacement>
                <token>G10MDA.</token> <!-- Token which needs to be replaced -->
                <value>S1MTHT.</value> <!-- Value which is replaced for given token -->
            </replacement>
            <replacement>
                <token>"G10MDA.</token> <!-- Token which needs to be replaced -->
                <value>"S1MTHT.</value> <!-- Value which is replaced for given token -->
            </replacement>
.....
.....

以上代码无效。

你能帮助别人吗?

我想替换java源文件中的标记,并且值应该包含在.class文件中。

0 个答案:

没有答案