EnvGen is an Ant task for generating different versions of the same file parameterized for different environments (i.e. development, test, and production) using FreeMarker as the template engine. Environment-specific properties are specified in a CSV file. EnvGen functions similar to Ant's Copy task: you run EnvGen against one or more source filesets into a target directory. Rather than simply copying each file over, EnvGen generates a version of the target file for each environment specified in the properties CSV file. Usually the target directory or filename is parameterized by environment so that EnvGen writes each version to a different physical file. While EnvGen is focused on environment-specific file generation, it may be suitable for more general use as an Ant task to drive FreeMarker. EnvGen can be downloaded from http://www.basilv.com/psd/software. To learn more about EnvGen, check out the EnvGen Release Documentation. Does this seem like a good solution for data that can change based on which environment is deployed to?
- Posted by: Basil Vandegriend
- Posted on: February 28 2007 08:02 EST
- xconf by Brad Dwyer on February 28 2007 15:19 EST
- Re: EnvGen 1.0: Environment-Specific File Generator by Eric Minick on March 05 2007 16:34 EST
For XML based configuration that differs between environments I've been using xconf (http://xconf.sourceforge.net) as part of the build process. This has worked quite well for Spring configuration that differs between local developer, test and production as you can manipulate individual XML elements and attributes (add/remove/modify) using an xconf config file. An example being removing production JMS interaction and replacing it with mocked local implementations for developer use, or switching between security implementation strategies (hardware vs software crypto). I've also used it on files like web.xml when developer vs test/prod environments have different container managed security constraints applied. The website also mentions this is useful for DDL scripts. For that I've had some success with dbmstools (http://dbmstools.sourceforge.net/). It probably isn't for everybody, but if you need to deploy to multiple database platforms and are currently managing different versions of your DB scripts it might be worth looking into.
We tend to tokenize our environment specific files and just use the Ant 'Replace' task to swap in the environment specific properties for the tokens. That seems to work pretty well. What does this approach do that's better than replacing tokens?