2

I am trying to use maven-replacer-plugin to replace values in several files.

First thing is I already read this topic and no answer work for me. I havn't enough point to comment and have neither the time nor the will to stupidly farm points on SOF. So, sorry for this duplicate but I need to step forward.

Back to the point, here is my 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:replace

[INFO] --- replacer:1.5.1:replace (default-cli) @ digishop-a --- [INFO] Replacement run on 0 file.

I tried the solution with

<filesToInclude>${basedir}/target/mailtools.properties,${basedir}/target/digishop-config.properties</filesToInclude>

and it didn't work either.

Community
  • 1
  • 1
terrasson marc
  • 97
  • 1
  • 10

2 Answers2

2

I manage to work around this issue by making multiple "single replacement" executions of the plugin

<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>
terrasson marc
  • 97
  • 1
  • 10
1

Use basedir before add as much includes as you want, e.g.

<basedir>${basedir}/target</basedir>
<includes>
    <include>mailtools.properties</include>
    <include>digishop-config.properties</include>
</includes>
Moesio
  • 3,100
  • 1
  • 27
  • 36