Thursday, June 28, 2007

Maven 2 war plugin & docs

Maven 2 is really nice thing, but in some cases it is hard to understand new concepts. But there is not one problem.

So, the issue. I need to add some resource to final war file and it should be filtered. It is real world situation when you have to deal with applicationContext.xml one for unit testing another one for webapp. How to do the trick ? In Ant it is trivial :) In Maven we can use ant plugin, but using war plugin is a better solution. So, the docs.
They use version 2.0 in examples. Ok.

webResources is a list of resources. All options of resource is supported.
A web resource
* can have inclusion/exclusion
* can be filtered
* is not limited to the default destination - the root of the war.
Great ! Setting targetPath to WEB-INF should solve the problem. But it doesn't ! All is done according to docs, I see this plugin for the first time in my life... My filtered xml file copied but to the root of war.

After some time I realized that it's a bug in plugin. No hints in docs about it :( I have found solution here. There is no such problem in 2.0.2 version.