tags:

views:

209

answers:

2

Is there any way to strip elements out of a web.xml file using ANT?

For example I have certain servlets I use for Unit Testing defined in the web.xml that are unnecessary in the production environment is there a way to strip these out or do I need to have a separate production web.xml file?

Thank You.

+4  A: 

Having a separate web.xml for test environment is a better (and easier) approach. The Ant script can be easily configured to pick up the right xml based on some configurable parameters.

However, you could, if you want, tokenize the web.xml and let Ant script substitute the tokens suitably during build. Check out Ant filters.

Rahul
+1  A: 

You can have more web.xml files and switch between those in production/testing or you could build your web.xml file (instead of stripping out stuff from it) by using XDoclet web tags.

dpb