I wrote a Java Web Application where I replace URLs to static content at build time to add version information, primarely for caching.
For example, href=\"mya
The solution for the plugin version 1.5.2 by mk7 works for me. I added a basedir-Tag (i didn't had one) before the include-Tag in the plugin configuration.
<basedir>${basedir}</basedir>
I used the plugin in version 1.5.3 and all works fine
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<basedir>ENTER_YOUR_BASEDIR</basedir>
<includes>
<include>**/*.js</include>
</includes>
<replacements>
<replacement>
<token>WHAT_TO_REPLACE</token>
<value>VALUE</value>
</replacement>
</replacements>
</configuration>
</plugin>
The includes
tag works with version 1.5.2 as well, you just have to specify the basedir
tag before includes
, and put the filepath (excluding the filename) as the basedir
value and just the filename as the include
tag value. So in your case something like this should work:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<basedir>${project.build.directory}/myApp</basedir>
<includes>
<include>index.jsp</include>
</includes>
<replacements>
<replacement>
<token>%PROJECT_VERSION%</token>
<value>${project.version}</value>
</replacement>
</replacements>
</configuration>
</plugin>
I tried all answers here but no one worked for me. 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>
This seems to be a bug in the latest 1.5.2 Version.
As soon as I change the version on bugfix level down to 1.5.1, the Not Working Example works just as expected and all tokens are replaced by their values.
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>${project.build.directory}/myApp/index.jsp</include>
</includes>
<replacements>
<replacement>
<token>%PROJECT_VERSION%</token>
<value>${project.version}</value>
</replacement>
</replacements>
</configuration>
</plugin>
I also removed the ignoreMissingFile as suggested by ben.
I had the same problem with 1.5.2 and reverted to
<filesToinclude>file1, file2</filesToInclude>
however I can imagine one would not like to add a dozen files manually...