You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by de...@apache.org on 2011/12/09 09:07:47 UTC
svn commit: r1212271 - in /maven/plugins/trunk/maven-ear-plugin/src/site:
apt/examples/skinny-wars.apt.vm apt/index.apt site.xml
Author: dennisl
Date: Fri Dec 9 08:07:47 2011
New Revision: 1212271
URL: http://svn.apache.org/viewvc?rev=1212271&view=rev
Log:
[MEAR-60] Improve support for skinny war files
o Add documentation for this new feature.
Added:
maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/skinny-wars.apt.vm
- copied, changed from r1211311, maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/skinny-wars.apt.vm
Modified:
maven/plugins/trunk/maven-ear-plugin/src/site/apt/index.apt
maven/plugins/trunk/maven-ear-plugin/src/site/site.xml
Copied: maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/skinny-wars.apt.vm (from r1211311, maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/skinny-wars.apt.vm)
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/skinny-wars.apt.vm?p2=maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/skinny-wars.apt.vm&p1=maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/skinny-wars.apt.vm&r1=1211311&r2=1212271&rev=1212271&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/skinny-wars.apt.vm (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/skinny-wars.apt.vm Fri Dec 9 08:07:47 2011
@@ -2,8 +2,9 @@
Creating Skinny WARs
------
Mike Perham
+ Dennis Lundberg
------
- 2008-08-03
+ 2011-12-09
------
~~ Licensed to the Apache Software Foundation (ASF) under one
@@ -34,42 +35,16 @@ Creating Skinny WARs
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 project's <<<pom.xml>>>:
+ Starting with version 2.7 Maven EAR Plugin has basic support for this mode of
+ operation.
-+-----------------+
-<project>
- ...
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <version>${project.version}</version>
- <configuration>
- <!-- In version 2.1-alpha-1, this was incorrectly named warSourceExcludes -->
- <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <classpathPrefix>lib/</classpathPrefix>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- </build>
- ...
-</project>
-+-----------------+
+ First we need to change the EAR project's <<<pom.xml>>> to package those JARs
+ in the EAR, using the <<<skinnyWars>>> parameter.
- Here's another variant of the above example, but this time we use
- <<<\<packagingIncludes\>>>> to select a few JARs to be included in the WAR.
- This is useful when there is a need to package a small, but non-empty, subset
- of JARs into the WAR. When making an EAR of skinny WARs, one wants to package
- all of the JARs into the EAR. Sometimes a list of JARs must be packaged into
- the WAR though in order for it to work properly, like with tag libraries.
+ <<Note:>> In this example we package all JARs into a <<<lib/>>> directory
+ within the EAR. This is just to distinguish between J2EE modules (which will be
+ packaged in the root of the EAR) and Java libraries (which are packaged in
+ <<<lib/>>>).
+-----------------+
<project>
@@ -77,53 +52,27 @@ Creating Skinny WARs
<build>
<plugins>
<plugin>
- <artifactId>maven-war-plugin</artifactId>
- <version>${project.version}</version>
- <configuration>
- <!-- Use this to include a selection of jars that will be included in the WAR -->
- <packagingIncludes>WEB-INF/lib/my-tag-library.jar,**/*.xml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,**/*.jsp</packagingIncludes>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <classpathPrefix>lib/</classpathPrefix>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- </build>
- ...
-</project>
-+-----------------+
-
- Next we need to change the EAR project'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/>>>).
-
-+-----------------+
- ...
- <build>
- <plugins>
- <plugin>
<artifactId>maven-ear-plugin</artifactId>
- <version>2.3.2</version>
+ <version>${project.version}</version>
<configuration>
<defaultJavaBundleDir>lib/</defaultJavaBundleDir>
+ <skinnyWars>true</skinnyWars>
</configuration>
</plugin>
</plugins>
</build>
...
+</project>
+-----------------+
- Now the painful part. Your EAR project'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.
+ Now the painful part. Your EAR project's <<<pom.xml>>> needs to list every
+ dependency that you want to share through the EAR.
+-----------------+
+<project>
....
<dependencies>
+ <!-- This is the JAR we want to share -->
<dependency>
<groupId>com.acme</groupId>
<artifactId>shared-jar</artifactId>
@@ -143,6 +92,7 @@ Creating Skinny WARs
</dependency>
</dependencies>
...
+</project>
+-----------------+
Your EAR will contain something like this:
@@ -157,8 +107,16 @@ Creating Skinny WARs
`-- war2-1.0.0.war
+-----------------+
+ If you look inside the copies of <<<war1-1.0.0.war>>> and <<<war2-1.0.0.war>>>,
+ that are packaged within the EAR, you will see that they no longer contain the
+ file <<<WEB-INF/lib/shared-jar-1.0.0.jar>>>.
+
+ Also, if you inspect the <<<MANIFEST.MF>>> of the WARs you will notice that the
+ <<<Class-Path>>> entry has been modified and now has a reference to
+ <<<lib/shared-jar-1.0.0.jar>>>.
+
* Alternatives
- Our users have submitted alternatives to the above recipe on
- {{{http://docs.codehaus.org/display/MAVENUSER/Solving+the+Skinny+Wars+problem}the Wiki}}.
\ No newline at end of file
+ Our users have submitted information about how to deal with skinny wars using Maven on
+ {{{http://docs.codehaus.org/display/MAVENUSER/Solving+the+Skinny+Wars+problem}the Wiki}}.
Modified: maven/plugins/trunk/maven-ear-plugin/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/index.apt?rev=1212271&r1=1212270&r2=1212271&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/index.apt (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/index.apt Fri Dec 9 08:07:47 2011
@@ -3,8 +3,9 @@
------
Edwin Punzalan
Stephane Nicoll
+ Dennis Lundberg
------
- 27 July 2006
+ 2011-12-09
------
~~ Copyright 2006 The Apache Software Foundation.
@@ -100,6 +101,8 @@ Maven EAR Plugin
* {{{./examples/filtering-advanced.html}Advanced Filtering Techniques}}
+ * {{{./examples/skinny-wars.html}Creating Skinny WARs}}
+
* {{{./examples/customizing-a-module-filename.html}Customizing A Module
Filename}}
Modified: maven/plugins/trunk/maven-ear-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/site.xml?rev=1212271&r1=1212270&r2=1212271&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/site.xml (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/site.xml Fri Dec 9 08:07:47 2011
@@ -36,6 +36,7 @@ under the License.
<menu name="Examples">
<item name="Filtering EAR Resources" href="examples/filtering-sources.html"/>
<item name="Advanced Filtering Techniques" href="examples/filtering-advanced.html"/>
+ <item name="Creating Skinny WARs" href="examples/skinny-wars.html"/>
<item name="Customizing A Module Filename" href="examples/customizing-a-module-filename.html"/>
<item name="Customizing The Context Root" href="examples/customizing-context-root.html"/>
<item name="Customizing A Module Location" href="examples/customizing-module-location.html"/>