In this post, I will show how to build a simple yet robust resource modification engine for Maven using GMaven and Groovy Templates.
We sometimes need to generate files in our build cycle that are specific to each server and change per deployment cycle. For some projects, this might be Flash / Flex actionscript files that need to reference the build server. For others, it might be datasource locations that change per build project. While maven provides a built-in resource filtering mechanism, it is tied to parts of the maven lifecycle that might not work well for all projects, and mostly changes resources for War files.
Groovy provides a very robust Templating engine. With the introduction of the GMaven plugin, it becomes possible to filter and re-write resource files using this robust mechanism. Combined with the power of Maven’s built-in profiles mechanism, this solution provides a robust and powerful way to edit Flex / Grails and other resources. Continue reading