Configuring Multiple WebApp Source Directory
 |
available since jetty-6.1.12.rc2 and jetty-7.0.0pre3 |
It can be configured by passing Resource[], String[], or String (csv) in the constructor.
The primary resource(first in the list) is the main resource.
WEB-INF/lib and WEB-INF/classes are merged.
This basically means your dependent classes on webappA will be available in the classpath for webappB.
This feature enables webapp overlays.
Configuration in context.xml
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "- "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="contextPath">/</Set>
<Set name="baseResource">
<New class="org.mortbay.resource.ResourceCollection">
<Arg>
<Array type="java.lang.String">
<Item>E:/path/to/my/main/app</Item>
<Item>/home/johndoe/path/to/my/other/source</Item>
<Item><SystemProperty name="jetty.home" default="."/>/webapps/foo</Item>
</Array>
</Arg>
</New>
</Set>
</Configure>
Configuration in jetty-maven-plugin
<!-- comma(or semi-colon) separated values-->
<configuration>
<webAppConfig>
<contextPath>/</contextPath>
<baseResource implementation="org.mortbay.resource.ResourceCollection">
<resources>src/main/webapp,target/foo,E:/my/other/source,/home/johndoe/path/to/my/other/source</resources>
</baseResource>
</webAppConfig>
<reload>manual</reload>
</configuration>
 |
When maven fails to dependency-inject overloaded resources, use:
<resourcesAsCsv>src/main/webapp,target/foo,E:/my/other/source,/home/johndoe/path/to/my/other/source</resourcesAsCsv>
Note that for the other webapp sources, you can add them to the plugin's extra scan targets for dynamic reload. |
Example
Scenario:
WebAppX:
/foo.jsp
/bar.jsp
/WEB-INF/web.xml
WebAppY:
/bar.jsp
/baz.jsp
/WEB-INF/web.xml
/WEB-INF/sitemesh.xml
Configuration:
<resources>webappY/src/main/webapp, webappX/src/main/webapp</resources>
Output:
When Y(first resource) extends/overrides X, you get:
/foo.jsp
/bar.jsp (Y)
/baz.jsp
/WEB-INF/web.xml (Y)
/WEB-INF/sitemesh.xml
Overlays
 |
available since jetty-6.1.12.rc3 and jetty-7.0.0pre4 |
When using mvn jetty:run, you don't need to configure anything.
Just add a dependency like:
<dependency>
<groupId>org.dojotoolkit</groupId>
<artifactId>dojo-war</artifactId>
<version>1.2-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-test</artifactId>
<version>6.1.12.rc3</version>
<type>war</type>
</dependency>
If configured manually, it would look like:
<resources>src/main/webapp,/home/johndoe/path/to/dojo-war/dir,/home/johndoe/path/to/jetty-test/dir</resources>
The order of the overlays depends on how you arrange the war dependencies in your pom.xml (top to bottom)