I'd like to keep Tomcat's context.xml file out of my WAR file's META-INF directory if possible. Can this be done with Maven's cargo plugin? I can't seem to find the correct configuration.
Eureka! After many days of studying this problem I finally found a very effective solution. The key is to take your Tomcat XML context fragment file and use the <configfiles>
element of cargo to drop it in the conf/Catalina/localhost
directory with the name context.xml.default
. The only downside is that this will make your context definitions available to all web-apps, but this shouldn't really matter only Cargo is using this Tomcat instance thus there is no other web-app.
Here's the configuration:
<configuration> <!-- Deployer configuration -->
<type>standalone</type>
<properties>
<cargo.servlet.port>${tomcat6.port}</cargo.servlet.port>
</properties>
<deployables>
<deployable>
<groupId>com.myapp<groupId>
<artifactId>myapp-war</artifactId>
<type>war</type>
<properties>
<context>${tomcat6.context}</context>
</properties>
</deployable>
</deployables>
<configfiles>
<configfile>
<file>${basedir}/../config/tomcat-context.xml</file>
<todir>conf/Catalina/localhost/</todir>
<tofile>context.xml.default</tofile>
</configfile>
</configfiles>
</configuration>
The net result is no more bogus WAR modules for testing only, and no more merging of WARs. Hope this helps somebody.