我正在尝试使用maven-replacer-plugin来替换多个文件中的值。
首先,我已经阅读this topic并且没有答案适合我。我没有足够的评论意见,既没有时间也没有意愿在SOF上愚蠢地提出要点。所以,抱歉这个副本,但我需要前进。
回到这一点,这是我的pom
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.1</version><!-- already tried with 1.5.2 & 1.5.3 -->
<configuration>
<includes>
<include>${basedir}/target/mailtools.properties</include>
<include>${basedir}/target/digishop-config.properties</include>
</includes>
<replacements>
<replacement>
<token>$${dev.varA}</token>
<value>something</value>
</replacement>
<replacement>
<token>$${dev.varB}</token>
<value>somethingElse</value>
</replacement>
<replacement>
<token>${dev.</token>
<value>${</value>
</replacement>
</replacements>
<regex>false</regex>
</configuration>
</plugin>
mvn replacer:替换
[INFO] ---替换者:1.5.1:替换(default-cli)@ digishop-a --- [INFO]替换在0档上运行。
我用
尝试了解决方案<filesToInclude>${basedir}/target/mailtools.properties,${basedir}/target/digishop-config.properties</filesToInclude>
它也没有用。
答案 0 :(得分:1)
我设法通过对插件执行多次“单次替换”执行来解决此问题
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<id>replace-xxx.properties</id>
<phase>install</phase>
<goals>
<goal>replace</goal>
</goals>
<inherited>false</inherited>
<configuration>
<file>target/xxx.properties</file>
<replacements>
<replacement>
<token>$${dev.mail.server.address}</token>
<value>xxx</value>
</replacement>
<replacement>
<token>$${dev.mail.server.port}</token>
<value>yyyy</value>
</replacement>
<replacement>
<token>${dev.</token>
<value>${</value>
</replacement>
</replacements>
<regex>false</regex>
</configuration>
</execution>
<execution>
<id>replace-zzz-config.properties</id>
<phase>install</phase>
<goals>
<goal>replace</goal>
</goals>
<inherited>false</inherited>
<configuration>
<file>target/zzz-config.properties</file>
<replacements>
<replacement>
<token>$${dev.hazelcast.client.group.name}</token>
<value>ttt</value>
</replacement>
<replacement>
<token>${dev.</token>
<value>${</value>
</replacement>
</replacements>
<regex>false</regex>
</configuration>
</execution>
<execution>
<id>replace-aaa-security.properties</id>
<phase>install</phase>
<goals>
<goal>replace</goal>
</goals>
<inherited>false</inherited>
<configuration>
<file>target/aaa-security.properties</file>
<replacements>
<replacement>
<token>${dev.</token>
<value>${</value>
</replacement>
</replacements>
<regex>false</regex>
</configuration>
</execution>
</executions>
</plugin>
答案 1 :(得分:0)
在添加尽可能多的包含之前使用basedir
,例如
<basedir>${basedir}/target</basedir>
<includes>
<include>mailtools.properties</include>
<include>digishop-config.properties</include>
</includes>