maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject svn commit: r1212327 - in /maven/plugins/trunk/maven-ear-plugin/src/site: apt/examples/excluding-files-from-ear.apt.vm apt/index.apt site.xml
Date Fri, 09 Dec 2011 10:42:22 GMT
Author: dennisl
Date: Fri Dec  9 10:42:21 2011
New Revision: 1212327

URL: http://svn.apache.org/viewvc?rev=1212327&view=rev
Log:
[MEAR-87] Allow exclusion of artifacts when building the ear file

o Add documentation for this new feature.

Added:
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/excluding-files-from-ear.apt.vm
      - copied, changed from r1211459, maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/including-excluding-files-from-war.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/excluding-files-from-ear.apt.vm
(from r1211459, maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/including-excluding-files-from-war.apt.vm)
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/excluding-files-from-ear.apt.vm?p2=maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/excluding-files-from-ear.apt.vm&p1=maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/including-excluding-files-from-war.apt.vm&r1=1211459&r2=1212327&rev=1212327&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/site/apt/examples/including-excluding-files-from-war.apt.vm
(original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/excluding-files-from-ear.apt.vm
Fri Dec  9 10:42:21 2011
@@ -1,9 +1,9 @@
   ------
-  Including and Excluding Files From the WAR
+  Excluding Files From the EAR
   ------
   Dennis Lundberg
   ------
-  2011-11-21
+  2011-12-09
   ------
 
 ~~ Licensed to the Apache Software Foundation (ASF) under one
@@ -26,16 +26,70 @@
 ~~ NOTE: For help with the syntax of this file, see:
 ~~ http://maven.apache.org/doxia/references/apt-format.html
 
-Including and Excluding Files From the WAR
+Excluding Files From the EAR
 
 
-  It is possible to include or exclude certain files from the WAR file, by using
-  the <<<\<packagingIncludes\>>>> and <<<\<packagingExcludes\>>>>
configuration
+  It is possible to exclude certain files from the EAR, by using the
+  <<<\<packagingIncludes\>>>> and <<<\<packagingExcludes\>>>>
configuration
   parameters. They each take a comma-separated list of Ant file set patterns.
   You can use wildcards such as <<<**>>> to indicate multiple directories
and
   <<<*>>> to indicate an optional part of a file or directory name.
-  
-  Here is an example where we exclude all JAR files from <<<WEB-INF/lib>>>:
+
+
+* Shared libraries
+
+  One use case for this is if you want to use shared libraries in your
+  application server. This involves configuring a location in your application
+  server that contains some libraries that you want to share between several
+  EARs. This is a bit like {{{./skinny-wars.html}skinny WARs}}, but taken to the
+  next level. With skinny WARs you share libraries (JARs) between web
+  applications within an enterprise application. Shared libraries as described
+  here shares libraries (JARs) between enterprise applications.
+
+  As an example, let's say that we want to exclude all non-in-house artifacts
+  from the generated EARs, so that the EAR files we distribute only contains our
+  own artifacts. The other dependencies we want to put in a shared library on
+  our application server. They only serve to bloat our EAR files, especially
+  if we're building or deploying several EARs, each with all of those
+  dependencies in them.
+
+  Our company in this example, the Acme Corporation, have wisely set a naming
+  convention for all their in-house artifacts. The artifactId is always prefixed
+  with "acme-". If they do not use a shared library, the directory layout for
+  their applications might look like this:
+
++-----------------+
+ acme-ear-1
+ |-- acme-ejb-1.jar
+ |-- acme-library-1.jar
+ |-- acme-library-2.jar
+ |-- acme-war-1.war
+ |-- acme-war-2.war
+ |-- external-library-1.jar
+ |-- external-library-2.jar
+ `-- external-library-3.jar
+
+ acme-ear-2
+ |-- acme-ejb-1.war
+ |-- acme-library-1.jar
+ |-- acme-library-2.jar
+ |-- acme-war-3.war
+ |-- acme-war-4.war
+ |-- external-library-2.jar
+ |-- external-library-3.jar
+ `-- external-library-4.jar
++-----------------+
+
+
+** Configuring the EARs
+
+  In order for us to avoid having duplicate copies of the external libraries we
+  need to do two things. First we make sure that our EARs only contain our own
+  artifacts. We do this with the <<<\<packagingIncludes\>>>> parameter,
which
+  tells the EAR Plugin what files to include in the EAR. Everything else will be
+  excluded. This configuration should be used in all of Acme's EAR projects, so
+  it would be better to move this configuration to a parent that is shared
+  by all of Acme's EAR projects.
 
 +-----------------+
 <project>
@@ -43,10 +97,10 @@ Including and Excluding Files From the W
   <build>
     <plugins>
       <plugin>
-        <artifactId>maven-war-plugin</artifactId>
+        <artifactId>maven-ear-plugin</artifactId>
         <version>${project.version}</version>
         <configuration>
-          <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
+          <packagingIncludes>META-INF/**,**/acme-*.jar,**/acme-*.war</packagingIncludes>
         </configuration>
       </plugin>
     </plugins>
@@ -55,32 +109,47 @@ Including and Excluding Files From the W
 </project>
 +-----------------+
 
-  Sometimes even such wildcards are not enough. In these cases you can use
-  regular expressions with the <<<%regex[]>>> syntax. Here is a real life
use
-  case in which this is used. In this example we want to exclude any
-  commons-logging and log4j JARs, but we do not want to exclude the
-  log4j-over-slf4j JAR. So we want to exclude <<<log4j-\<version\>.jar>>>
but
-  keep the <<<log4j-over-slf4j-\<version\>.jar>>>.
+
+** Creating the shared library EAR
+
+  Next we create a shared library EAR that contains all the dependencies that we
+  want to share between the EARs. In this example we are packaging our shared
+  library as an EAR. What type of packaging you can use differ between various
+  application servers.
+
+  <<Note:>> The <<<\<version\>>>> elements of the dependencies
have been omitted
+  here for brevity.
 
 +-----------------+
 <project>
   ...
+  <artifactId>external-shared-libraries</artifactId>
+  <packaging>ear</packaging>
+  ...
+  <dependencies>
+    <dependency>
+      <groupId>com.external.supplier</groupId>
+      <artifactId>external-library-1.jar</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.external.supplier</groupId>
+      <artifactId>external-library-2.jar</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.external.supplier</groupId>
+      <artifactId>external-library-3.jar</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.external.supplier</groupId>
+      <artifactId>external-library-4.jar</artifactId>
+    </dependency>
+  </dependencies>
+  ...
   <build>
     <plugins>
       <plugin>
-        <artifactId>maven-war-plugin</artifactId>
+        <artifactId>maven-ear-plugin</artifactId>
         <version>${project.version}</version>
-        <configuration>
-          <!--
-            Exclude JCL and LOG4J since all logging should go through SLF4J.
-            Note that we're excluding log4j-<version>.jar but keeping
-            log4j-over-slf4j-<version>.jar
-          -->
-          <packagingExcludes>
-            WEB-INF/lib/commons-logging-*.jar,
-            %regex[WEB-INF/lib/log4j-(?!over-slf4j).*.jar]
-          </packagingExcludes>
-        </configuration>
       </plugin>
     </plugins>
   </build>
@@ -88,7 +157,33 @@ Including and Excluding Files From the W
 </project>
 +-----------------+
 
-  If you have more real life examples of using regular expressions, we'd like to
-  know about them. Please file an issue in
-  {{{../issue-tracking.html}our issue tracker}} with your configuration, so we
-  can expand this page.
+** The results
+
+  With all the Maven configuration done, the resulting directory layout would
+  look like this:
+
++-----------------+
+ external-shared-libraries
+ |-- external-library-1.jar
+ |-- external-library-2.jar
+ |-- external-library-3.jar
+ `-- external-library-4.jar
+
+ acme-ear-1
+ |-- acme-ejb-1.jar
+ |-- acme-library-1.jar
+ |-- acme-library-2.jar
+ |-- acme-war-1.war
+ `-- acme-war-2.war
+
+ acme-ear-2
+ |-- acme-ejb-1.war
+ |-- acme-library-1.jar
+ |-- acme-library-2.jar
+ |-- acme-war-3.war
+ `-- acme-war-4.war
++-----------------+
+
+  <<Note:>> You would also need to configure your application server to use
+  <<<external-shared-libraries>>> as a shared library. How you do that
is
+  however out of scope for this example.

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=1212327&r1=1212326&r2=1212327&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 10:42:21 2011
@@ -114,6 +114,8 @@ Maven EAR Plugin
 
   * {{{./examples/excluding-a-module.html}Excluding A Module}}
 
+  * {{{./examples/excluding-files-from-ear.html}Excluding Files From the EAR}}
+
   * {{{./examples/unpacking-a-module.html}Unpacking A Module}}
 
   * {{{./examples/including-a-third-party-library-in-application-xml.html}

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=1212327&r1=1212326&r2=1212327&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 10:42:21 2011
@@ -42,6 +42,7 @@ under the License.
       <item name="Customizing A Module Location" href="examples/customizing-module-location.html"/>
       <item name="Customizing A Module URI" href="examples/customizing-module-uri.html"/>
       <item name="Excluding A Module" href="examples/excluding-a-module.html"/>
+      <item name="Excluding Files From the EAR" href="examples/excluding-files-from-ear.html"/>
       <item name="Unpacking A Module" href="examples/unpacking-a-module.html"/>
       <item name="Including A Third Party Library In application.xml" href="examples/including-a-third-party-library-in-application-xml.html"/>
       <item name="Specifying Security Roles For The Generated application.xml" href="examples/specifying-security-roles-for-the-generated-application-xml.html"/>



Mime
View raw message