views:

1183

answers:

4

I'm looking for some way to replace patterns in files with values, during build time.

E.g. a configuration file may look the same except that different machines requires different hostnames in some setting. In that case i want to have a template file, where hostname is replaced with @@hostname@@ Then when building, I want to create separate versions of the file with the patter replaced with the correct value for each environment.

In ant you could use "replace", is there something similar in maven2? I know that I can run ant form maven, but if theres a maven plugin doing it, I'd prefer that one.

I found http://code.google.com/p/maven-replacer-plugin/ but it's very new...

Suggestions?

Thanks!

A: 

Why don't you use the Maven-ant plug-in?

kgiannakakis
I would like to stick to maven if possible
Tomas
There's nothing wrong with using the maven-antrun-plugin to help out with a maven build. That's fine. In this case, though I think the resources plugin is probably a better match, as Steve said.
Dominic Mitchell
+1  A: 

Maven's resource filtering might help you out.

Steve Reed
+3  A: 

The resource plugin is what does filtering in Maven. IIRC it supports the ant syntax as well as the ${foo} maven syntax.

Brian Fox
A: 

keep up with the maven-replacer-plugin, the project is still alive and well