Hi Arnaud, There's also some code to merge Wars in Cargo's code. See http://cargo.codehaus.org/Merging+WAR+files
I haven't used it myself so I don't know how well it works but it may be worth a try. Thanks -Vincent > -----Original Message----- > From: Arnaud Bailly [mailto:[EMAIL PROTECTED] > Sent: lundi 6 novembre 2006 23:14 > To: users@maven.apache.org > Subject: Poor man's web.xml merging > > While trying to use war plugin for overlaying two webapps, I was > bitten by the somewhat obvious problem of how to merge web > descriptors. There does not seem to exist a standard (read mainstream) > way of doing this. All I found searching the ML on nabble was a > reference to some custom development modifying the plugin's standard > behavior and I did not however search the Jira issues. > > While certainly not against modifying plugins to suite my needs, I > tried to find a solution less "intrusive" and I came up with one > simple solution that may (or may not) be worth sharing: Use inclusion > in XML descriptor through internal subset mechanism. This solution is > not really elegant and may become rapidly unwieldy if the number of > webapps to merge is too important or rapidly changing, but it has the > advantage of relying on standard XML mechanisms and not changing maven > or its plugins. > > 1. Make your web.xml filterable: > You need to add some filtered repository to the war plugin and put > your WEB-INF/web.xml in it. Add the following to the build section: > > <plugin> > <artifactId>maven-war-plugin</artifactId> > <configuration> > <webResources> > <webResource> > <directory>${basedir}/src/main/webapp-filtered</directory> > <filtering>true</filtering> > <includes> > <include>**/*.xml</include> > </includes> > </webResource> > </webResources> > </configuration> > </plugin> > > 2. Add an entity definition into web.xml: > Each entity definition is a SYSTEM reference whose content is some > variable that will later be filtered: > > <?xml version="1.0" encoding="ISO-8859-1"?> > <!DOCTYPE web-app > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" > "http://java.sun.com/dtd/web-app_2_3.dtd" [ > <!ENTITY external.servlet SYSTEM "${testui.include.servlet}" > > <!ENTITY external.servlet-mapping SYSTEM "${testui.include.mapping}" > > ]> > > 3. Add entities references as needed in the web.xml file. > You need to breakdown the imported descriptor so that DTD validator is > kept happy. You could also set your web application container's XML > parser to some lenient mode so that DTD validation is not enforced > (not tried this). > > <!-- conditional inclusion of testui descriptor --> > &external.servlet; > > <servlet> > <servlet-name>Init</servlet-name> > <servlet-class>toto.Init</servlet-class> > <load-on-startup>1</load-on-startup> > </servlet> > > ... > > <!-- conditional inclusion of testui descriptor --> > &external.servlet-mapping; > > <servlet-mapping> > <servlet-name>webapp</servlet-name> > <url-pattern>/my-app</url-pattern> > </servlet-mapping> > > ... > > 4. Add profiles that defines the needed properties to some consistent > value. > In this case, we set a test and a production profile: test profile > import some content while production profile import dummy (empty) > fragments. > > > <profiles> > > <profile> > <id>web-test</id> > <properties> > <testui.include.servlet>servlet.xml</testui.include.servlet> > <testui.include.mapping>servlet- > mapping.xml</testui.include.mapping> > </properties> > > <dependencies> > <dependency> > <groupId>toto</groupId> > <artifactId>test-webapp</artifactId> > <version>${version}</version> > <type>war</type> > </dependency> > </dependencies> > </profile> > > <profile> > > <id>web-prod</id> > <properties> > <testui.include.servlet>dummy-servlet.xml</testui.include.servlet> > <testui.include.mapping>dummy-mapping.xml</testui.include.mapping> > </properties> > </profile> > </profiles> > > 5. In test-webapp project, create servlet.xml and servlet-mapping.xml > fragments from the full descriptor in WEB-INF > > 6. Then run mvn install with either profile set. With mvn -P web-test, > you end up with a web application containing the imported test-webapp > project's content and with a web.xml like: > > <?xml version="1.0" encoding="ISO-8859-1"?> > <!DOCTYPE web-app > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" > "http://java.sun.com/dtd/web-app_2_3.dtd" [ > <!ENTITY external.servlet SYSTEM "servlet.xml" > > <!ENTITY external.servlet-mapping SYSTEM "servlet-mapping.xml" > > ]> > > Note that war overlay mechanism took care of copying servlet.xml and > servlet-mapping.xml from test-webapp. > > At load time, the XML parser for the container (tested with Jetty6) > should resolve entities content and include the named files into the > web.xml. > > 7. enjoy :-) > > As already said, I tried all this on one container only and with two > simple web applications. But as this is standard XML mechanism, and > not particularly bleeding edge XML, I do have reasons to believe it > will work in any reasonably standard-compliant container. > > As usual, feedback is welcomed. If some people deems it worthwhile, I > could pack all this into the maven wiki. > > Regards, > -- > OQube < software engineering \ génie logiciel > > Arnaud Bailly, Dr. > \web> http://www.oqube.com > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] ___________________________________________________________________________ Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses http://fr.answers.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]