Author: mperham
Date: Wed Jul 19 12:26:53 2006
New Revision: 423578

URL: http://svn.apache.org/viewvc?rev=423578&view=rev
Log:
Add documentation on creating skinny wars.
Minor verbage fixes for existing documentation.

Added:
    maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/skinny-wars.apt
Modified:
    
maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/rapid-testing-jetty6-plugin.apt
    maven/plugins/trunk/maven-war-plugin/src/site/site.xml

Modified: 
maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/rapid-testing-jetty6-plugin.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/rapid-testing-jetty6-plugin.apt?rev=423578&r1=423577&r2=423578&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/rapid-testing-jetty6-plugin.apt
 (original)
+++ 
maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/rapid-testing-jetty6-plugin.apt
 Wed Jul 19 12:26:53 2006
@@ -5,7 +5,7 @@
  ------
  19 June 2006
  
-Rapid testing during development with the jetty6 plugin 
+Rapid testing with the jetty6 plugin 
  
  Normally, testing a web application involves compiling java sources, creating 
a war and 
  deploying it to a web container. 
@@ -15,7 +15,7 @@
  any changes in your java sources and <<<src/main/webapp>>> for your web 
sources.
  The jetty6 plugin will automatically reload the modified classes and web 
sources.
  
- To use the jetty6 plugin just add the following in you <<<pom.xml>>>
+ To use the jetty6 plugin just add the following in your <<<pom.xml>>>:
  
 +-----------------+ 
   [...]
@@ -39,12 +39,12 @@
   [...]  
 +-----------------+ 
 
- then running 
+ then start Jetty:
  
 +-----------------+ 
   mvn jetty6:run
 +-----------------+  
 
- The command will block with the jetty6 listening on port <<<8080>>>.
+ The command will block with Jetty listening on port 8080.
  
  Check the {{{http://jetty.mortbay.org/jetty6/maven-plugin/index.html}jetty6 
plugin documentation}} for more details.

Added: 
maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/skinny-wars.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/skinny-wars.apt?rev=423578&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/skinny-wars.apt 
(added)
+++ maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/skinny-wars.apt 
Wed Jul 19 12:26:53 2006
@@ -0,0 +1,91 @@
+ ------
+ Maven 2 War Plugin - Creating Skinny WARs
+ ------
+ Mike Perham
+ ------
+ July 2006
+ 
+Creating Skinny WARs
+ 
+ In a typical J2EE environment, a WAR is packaged within an EAR for 
deployment.  The
+ WAR can contain all its dependent JARs in <<<WEB-INF/lib>>> but then the EAR 
can quickly grow
+ very large if there are multiple WARs, due to the presence of duplicate JARs. 
 Instead
+ the J2EE specification allows WARs to reference external JARs packaged within 
the EAR
+ via the <<<Class-Path>>> setting in their <<<MANIFEST.MF>>>.
+
+ The Maven WAR and EAR plugins do not directly support this mode of operation 
but
+ we can fake it through some POM and configuration magic.  First you need to 
tell
+ Maven to exclude the dependent JARs and add references to them in the 
<<<MANIFEST.MF>>>
+ instead.  This goes into your WAR's <<<pom.xml>>>:
+ 
++-----------------+ 
+    <plugins>
+      <plugin>
+         <artifactId>maven-war-plugin</artifactId>
+         <configuration>
+           <!-- This is broken in maven-war-plugin 2.0, works in 2.0.1 -->
+           <warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>
+           <archive>
+             <manifest>
+               <addClasspath>true</addClasspath>
+               <classpathPrefix>lib/</classpathPrefix>
+             </manifest>
+           </archive>
+         </configuration>       
+      </plugin>
+    </plugins>    
++-----------------+ 
+
+ Next we need to change the EAR's <<<pom.xml>>> to package those dependent 
JARs in the EAR.
+ Notice that we package everything into a lib/ directory within the EAR.  This 
is
+ just my own personal preference to distinguish between J2EE modules (which 
will
+ be packaged in the root of the EAR) and Java libraries (which are packaged in 
lib/).
+
++-----------------+ 
+    <plugins>
+      <plugin>
+        <artifactId>maven-ear-plugin</artifactId>
+        <configuration>
+          <defaultJavaBundleDir>lib/</defaultJavaBundleDir>
+        </configuration>       
+      </plugin>
+    </plugins>    
++-----------------+  
+
+ Now the painful part.  Your EAR's <<<pom.xml>>> needs to list every 
dependency that the WAR has.
+ This is because Maven assumes fat WARs and does not include transitive 
dependencies
+ of WARs within the EAR.
+
++-----------------+ 
+    <dependencies>
+        <dependency>
+            <groupId>com.acme</groupId>
+            <artifactId>shared-jar</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.acme</groupId>
+            <artifactId>war1</artifactId>
+            <version>1.0.0</version>
+            <type>war</type>
+        </dependency>
+        <dependency>
+            <groupId>com.acme</groupId>
+            <artifactId>war2</artifactId>
+            <version>1.0.0</version>
+            <type>war</type>
+        </dependency>
+    </dependencies>
++-----------------+ 
+
+ Your EAR will contain something like this:
+
++-----------------+ 
+ .
+ |-- META-INF
+ |   |-- application.xml
+ |-- lib
+ |   |-- shared-jar-1.0.0.jar
+ |-- war1-1.0.0.war
+ |-- war2-1.0.0.war
++-----------------+ 

Modified: maven/plugins/trunk/maven-war-plugin/src/site/site.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/site/site.xml?rev=423578&r1=423577&r2=423578&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/site/site.xml (original)
+++ maven/plugins/trunk/maven-war-plugin/src/site/site.xml Wed Jul 19 12:26:53 
2006
@@ -42,6 +42,7 @@
       <item name="Adding external web sources" 
href="examples/war-overlay.html"/>
       <item name="War manifest customization" 
href="examples/war-manifest-guide.html"/>
       <item name="Rapid testing using jetty6" 
href="examples/rapid-testing-jetty6-plugin.html"/>
+      <item name="Creating skinny wars" href="examples/skinny-wars.html"/>
     </menu>
     ${reports}
   </body>


Reply via email to