I'm using the 1.5.3 version of the Maven replacer plugin. I want to replace the string “${version}” in my properties file, which contains the line
application.version=${version}
with the actual <version> element defined in my pom. I'm trying this, but without success:
<execution>
<id>replace-application-version</id>
<phase>compile</phase>
<configuration>
<file>${project.build.outputDirectory}/application.properties</file>
<replacements>
<replacement>
<token>\${version}</token>
<value>${version}</value>
</replacement>
</replacements>
</configuration>
<goals>
<goal>replace</goal>
</goals>
</execution>
I don't know how to properly escape the string “${version}” in the “<token>” block. Any help is appreciated.
For the Maven replacer plugin to look for the string “${version}” as a token without replacing it with the property value, you can specify the token as a regular expression by adding <regex>true</regex>
and leave it like this:
<execution>
<id>replace-application-version</id>
<phase>compile</phase>
<configuration>
<file>${project.build.outputDirectory}/application.properties</file>
<regex>true</regex>
<replacements>
<replacement>
<token>\$\{version\}</token>
<value>${version}</value>
</replacement>
</replacements>
</configuration>
<goals>
<goal>replace</goal>
</goals>
</execution>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.