Maven String Replace of Text Web Resources
Posted
by Jaco van Niekerk
on Stack Overflow
See other posts from Stack Overflow
or by Jaco van Niekerk
Published on 2010-06-10T20:50:20Z
Indexed on
2010/06/10
20:52 UTC
Read the original article
Hit count: 372
I have a Maven web application with text files in
src/main/webapp/textfilesdir
As I understand it, during the package phase this textfilesdir directory will be copied into the
target/project-1.0-SNAPSHOT
directory, which is then zipped up into a
target/project-1.0-SNAPSHOT.war
Problem
Now, I need to do a string replacement on the contents of the text files in target/project-1.0-SNAPSHOT/textfilesdir. This must then be done after the textfilesdir is copied into target/project-1.0-SNAPSHOT, but prior to the target/project-1.0-SNAPSHOT.war file being created. I believe this is all done during the package phase.
How can a plugin (potentially maven-antrun-plugin), plug into the package phase to do this.
The text files don't contain properties, like ${property-name} to filter on. String replacement is likely the only option.
Options
Modify the text files after the copy into target/project-1.0-SNAPSHOT directory, yet prior to the WAR creation.
After packaging, extract the text files from WAR, modify them, and add them back into the WAR.
I'm thinking there is another option here I'm missing. Thoughts anyone?
© Stack Overflow or respective owner