Reputation: 111
I have a simple property file, containing the following lines:
abc=123
location=C:\temp
version=1.0.0
Now, using some Maven plugin, I need to change the value of version
from 1.0.0
to some other value.
I know I can use the maven-replacer-plugin by replacing 1.0.0
with some token (say $my_version
). Then, I could use this token to replace the value on the fly.
However, I don't want to use the token value; what I need is to replace all the text after the =
(equal sign).
How can I do that?
Upvotes: 2
Views: 1897
Reputation: 8067
You can use maven-antrun-plugin
to replace a string in the source code. Declare resources
and plugin
as below:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<configuration>
<tasks>
<replace token="<strToBeReplaced>" value="<yourValue>" dir="target/classes">
<include name="**/*.properties" />
</replace>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</build>
Run mvn clean install
the string/token in the properties file will be replaced by the value given in pom.xml
Upvotes: 0