Author: dennisl
Date: Sun Feb 15 17:40:31 2009
New Revision: 744705

URL: http://svn.apache.org/viewvc?rev=744705&view=rev
Log:
[MWAR-182] warSourceIncludes no longer works

o Add a new parameter <packagingIncludes>

Modified:
    
maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java
    maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/skinny-wars.apt

Modified: 
maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java?rev=744705&r1=744704&r2=744705&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java
 Sun Feb 15 17:40:31 2009
@@ -82,6 +82,16 @@
     private String packagingExcludes;
 
     /**
+     * The comma separated list of tokens to include in the WAR before
+     * packaging. By default everything is included. This option may be used
+     * to implement the skinny war use case.
+     *
+     * @parameter alias="packagingIncludes"
+     * @since 2.1-beta-1
+     */
+    private String packagingIncludes;
+
+    /**
      * The War archiver.
      *
      * @component role="org.codehaus.plexus.archiver.Archiver" roleHint="war"
@@ -191,9 +201,11 @@
         archiver.setOutputFile( warFile );
 
         getLog().debug(
-            "Excluding " + Arrays.asList( getPackagingExcludes() ) + " for the 
generated webapp archive." );
+            "Excluding " + Arrays.asList( getPackagingExcludes() ) + " from 
the generated webapp archive." );
+        getLog().debug(
+            "Including " + Arrays.asList( getPackagingIncludes() ) + " in the 
generated webapp archive." );
 
-        warArchiver.addDirectory( getWebappDirectory(), new String[]{"**"}, 
getPackagingExcludes() );
+        warArchiver.addDirectory( getWebappDirectory(), 
getPackagingIncludes(), getPackagingExcludes() );
 
         final File webXmlFile = new File( getWebappDirectory(), 
"WEB-INF/web.xml" );
         if ( webXmlFile.exists() )
@@ -292,7 +304,6 @@
         {
             return StringUtils.split( packagingExcludes, "," );
         }
-
     }
 
     public void setPackagingExcludes( String packagingExcludes )
@@ -300,6 +311,23 @@
         this.packagingExcludes = packagingExcludes;
     }
 
+    public String[] getPackagingIncludes()
+    {
+        if ( StringUtils.isEmpty( packagingIncludes ) )
+        {
+            return new String[]{"**"};
+        }
+        else
+        {
+            return StringUtils.split( packagingIncludes, "," );
+        }
+    }
+
+    public void setPackagingIncludes( String packagingIncludes )
+    {
+        this.packagingIncludes = packagingIncludes;
+    }
+
     public String getOutputDirectory()
     {
         return outputDirectory;

Modified: 
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=744705&r1=744704&r2=744705&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/skinny-wars.apt 
(original)
+++ maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/skinny-wars.apt 
Sun Feb 15 17:40:31 2009
@@ -46,8 +46,9 @@
     <plugins>
       <plugin>
         <artifactId>maven-war-plugin</artifactId>
+        <version>2.1-alpha-2</version>
         <configuration>
-          <!-- In version 2.x, this was incorrectly named warSourceExcludes -->
+          <!-- In version 2.1-alpha-1, this was incorrectly named 
warSourceExcludes -->
           <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
           <archive>
             <manifest>
@@ -63,6 +64,38 @@
 </project>
 +-----------------+
 
+ 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 tag libraries.
+
++-----------------+
+<project>
+  ...
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-war-plugin</artifactId>
+        <version>2.1-beta-1</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,WEB-INF/web.xml</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


Reply via email to