You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sn...@apache.org on 2010/09/05 18:32:59 UTC

svn commit: r992817 - in /maven/plugins/trunk/maven-ear-plugin/src: main/java/org/apache/maven/plugin/ear/ site/ site/apt/ site/apt/examples/ test/java/org/apache/maven/plugin/ear/it/ test/resources/projects/project-065/ test/resources/projects/project...

Author: snicoll
Date: Sun Sep  5 16:32:58 2010
New Revision: 992817

URL: http://svn.apache.org/viewvc?rev=992817&view=rev
Log:
MEAR-35: added the ability to specify an ID for a given module and to trigger automatic generation based on the generateModuleId property. Based on an initial patch from Matt Jensen.

Added:
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/generating-modules-id.apt.vm
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-065/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-065/expected-META-INF/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-065/expected-META-INF/application.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-065/pom.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-066/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-066/expected-META-INF/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-066/expected-META-INF/application.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-066/pom.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-067/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-067/expected-META-INF/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-067/expected-META-INF/application.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-067/pom.xml
Modified:
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/ApplicationXmlWriter.java
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EjbModule.java
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/HarModule.java
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JarModule.java
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/RarModule.java
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/SarModule.java
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/index.apt
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/modules.apt.vm
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt
    maven/plugins/trunk/maven-ear-plugin/src/site/site.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java?rev=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java Sun Sep  5 16:32:58 2010
@@ -42,8 +42,6 @@ public abstract class AbstractEarModule
 
     protected static final String ALT_DD = "alt-dd";
 
-    private String uri;
-
     private Artifact artifact;
 
     // Those are set by the configuration
@@ -60,10 +58,16 @@ public abstract class AbstractEarModule
 
     protected Boolean excluded = Boolean.FALSE;
 
+    private String uri;
+
     protected Boolean unpack = null;
 
     protected String altDeploymentDescriptor;
 
+    private String moduleId;
+
+    // This is injected once the module has been built.
+
     protected EarExecutionContext earExecutionContext;
 
     /**
@@ -129,6 +133,11 @@ public abstract class AbstractEarModule
         return artifact;
     }
 
+    public String getModuleId()
+    {
+        return moduleId;
+    }
+
     public String getUri()
     {
         if ( uri == null )
@@ -250,6 +259,36 @@ public abstract class AbstractEarModule
         }
     }
 
+    /**
+     * Starts a new {@link #MODULE_ELEMENT} on the specified writer, possibly
+     * including an id attribute.
+     *
+     * @param writer     the XML writer.
+     * @param generateId whether an id should be generated
+     */
+    protected void startModuleElement( XMLWriter writer, Boolean generateId )
+    {
+        writer.startElement( MODULE_ELEMENT );
+
+        // If a moduleId is specified, always include it
+        if ( getModuleId() != null )
+        {
+            writer.addAttribute( "id", getModuleId() );
+        }
+        else if ( generateId.booleanValue() )
+        {
+            // No module id was specified but one should be generated.
+            Artifact artifact = getArtifact();
+            String generatedId =
+                artifact.getType().toUpperCase() + "_" + artifact.getGroupId() + "." + artifact.getArtifactId();
+            if ( null != artifact.getClassifier() && artifact.getClassifier().trim().length() > 0 )
+            {
+                generatedId += "-" + artifact.getClassifier().trim();
+            }
+            writer.addAttribute( "id", generatedId );
+        }
+    }
+
     public String toString()
     {
         StringBuffer sb = new StringBuffer();

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/ApplicationXmlWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/ApplicationXmlWriter.java?rev=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/ApplicationXmlWriter.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/ApplicationXmlWriter.java Sun Sep  5 16:32:58 2010
@@ -43,10 +43,13 @@ final class ApplicationXmlWriter
 
     private final String version;
 
-    ApplicationXmlWriter( String version, String encoding )
+    private final Boolean generateModuleId;
+
+    ApplicationXmlWriter( String version, String encoding, Boolean generateModuleId )
     {
         super( encoding );
         this.version = version;
+        this.generateModuleId = generateModuleId;
     }
 
     public void write( ApplicationXmlWriterContext context )
@@ -90,7 +93,7 @@ final class ApplicationXmlWriter
         while ( moduleIt.hasNext() )
         {
             EarModule module = (EarModule) moduleIt.next();
-            module.appendModule( writer, version );
+            module.appendModule( writer, version, generateModuleId );
         }
 
         final Iterator securityRoleIt = context.getSecurityRoles().iterator();

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java?rev=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java Sun Sep  5 16:32:58 2010
@@ -91,10 +91,11 @@ public interface EarModule
     /**
      * Appends the <tt>XML</tt> representation of this module.
      *
-     * @param writer  the writer to use
-     * @param version the version of the <tt>application.xml</tt> file
+     * @param writer     the writer to use
+     * @param version    the version of the <tt>application.xml</tt> file
+     * @param generateId whether an id should be generated
      */
-    public void appendModule( XMLWriter writer, String version );
+    public void appendModule( XMLWriter writer, String version, Boolean generateId );
 
     /**
      * Resolves the {@link Artifact} represented by the module. Note

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EjbModule.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EjbModule.java?rev=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EjbModule.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EjbModule.java Sun Sep  5 16:32:58 2010
@@ -42,9 +42,9 @@ public class EjbModule
         super( a );
     }
 
-    public void appendModule( XMLWriter writer, String version )
+    public void appendModule( XMLWriter writer, String version, Boolean generateId )
     {
-        writer.startElement( MODULE_ELEMENT );
+        startModuleElement( writer, generateId );
         writer.startElement( EJB_MODULE );
         writer.writeText( getUri() );
         writer.endElement();

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java?rev=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java Sun Sep  5 16:32:58 2010
@@ -53,6 +53,13 @@ public class GenerateApplicationXmlMojo
     private Boolean generateApplicationXml = Boolean.TRUE;
 
     /**
+     * Whether a module ID should be generated if none is specified.
+     *
+     * @parameter
+     */
+    private Boolean generateModuleId = Boolean.FALSE;
+
+    /**
      * Display name of the application to be used when application.xml
      * file is autogenerated.
      *
@@ -164,7 +171,7 @@ public class GenerateApplicationXmlMojo
 
         File descriptor = new File( outputDir, "application.xml" );
 
-        final ApplicationXmlWriter writer = new ApplicationXmlWriter( version, encoding );
+        final ApplicationXmlWriter writer = new ApplicationXmlWriter( version, encoding, generateModuleId );
         final ApplicationXmlWriterContext context =
             new ApplicationXmlWriterContext( descriptor, getModules(), buildSecurityRoles(), displayName, description,
                                              defaultLibBundleDir );

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/HarModule.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/HarModule.java?rev=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/HarModule.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/HarModule.java Sun Sep  5 16:32:58 2010
@@ -41,7 +41,7 @@ public class HarModule
         super( a );
     }
 
-    public void appendModule( XMLWriter writer, String version )
+    public void appendModule( XMLWriter writer, String version, Boolean generateId )
     {
         // No entry is generated by this artifact ; it should be
         // defined in the jboss-app.xml.

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JarModule.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JarModule.java?rev=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JarModule.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JarModule.java Sun Sep  5 16:32:58 2010
@@ -57,13 +57,13 @@ public class JarModule
 
     }
 
-    public void appendModule( XMLWriter writer, String version )
+    public void appendModule( XMLWriter writer, String version, Boolean generateId )
     {
         // Generates an entry in the application.xml only if
         // includeInApplicationXml is set
         if ( includeInApplicationXml.booleanValue() )
         {
-            writer.startElement( MODULE_ELEMENT );
+            startModuleElement( writer, generateId );
             writer.startElement( JAVA_MODULE );
             writer.writeText( getUri() );
             writer.endElement();

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/RarModule.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/RarModule.java?rev=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/RarModule.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/RarModule.java Sun Sep  5 16:32:58 2010
@@ -42,9 +42,9 @@ public class RarModule
         super( a );
     }
 
-    public void appendModule( XMLWriter writer, String version )
+    public void appendModule( XMLWriter writer, String version, Boolean generateId )
     {
-        writer.startElement( MODULE_ELEMENT );
+        startModuleElement( writer, generateId );
         writer.startElement( RAR_MODULE );
         writer.writeText( getUri() );
         writer.endElement();

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/SarModule.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/SarModule.java?rev=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/SarModule.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/SarModule.java Sun Sep  5 16:32:58 2010
@@ -44,12 +44,12 @@ public class SarModule
         super( a );
     }
 
-    public void appendModule( XMLWriter writer, String version )
+    public void appendModule( XMLWriter writer, String version, Boolean generateId )
     {
         // If JBoss is not configured, add the module as a connector element
         if ( !earExecutionContext.isJbossConfigured() )
         {
-            writer.startElement( MODULE_ELEMENT );
+            startModuleElement( writer, generateId );
             writer.startElement( SAR_MODULE );
             writer.writeText( getUri() );
             writer.endElement();

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java?rev=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java Sun Sep  5 16:32:58 2010
@@ -52,9 +52,9 @@ public class WebModule
         this.contextRoot = getDefaultContextRoot( a );
     }
 
-    public void appendModule( XMLWriter writer, String version )
+    public void appendModule( XMLWriter writer, String version, Boolean generateId )
     {
-        writer.startElement( MODULE_ELEMENT );
+        startModuleElement( writer, generateId );
         writer.startElement( WEB_MODULE );
         writer.startElement( WEB_URI_FIELD );
         writer.writeText( getUri() );

Added: maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/generating-modules-id.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/generating-modules-id.apt.vm?rev=992817&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/generating-modules-id.apt.vm (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/generating-modules-id.apt.vm Sun Sep  5 16:32:58 2010
@@ -0,0 +1,71 @@
+  ------
+  Generating modules ID
+  ------
+  Stephane Nicoll
+  <sn...@apache.org>
+  ------
+  September 4, 2010
+
+~~ Copyright 2006 The Apache Software Foundation.
+~~
+~~ Licensed under the Apache License, Version 2.0 (the "License");
+~~ you may not use this file except in compliance with the License.
+~~ You may obtain a copy of the License at
+~~
+~~      http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing, software
+~~ distributed under the License is distributed on an "AS IS" BASIS,
+~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~~ See the License for the specific language governing permissions and
+~~ limitations under the License.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+
+Generating modules ID
+
+  Some environment requires an ID to be generated for each module defined in the <<application.xml>>. Enabling
+  the automatic IDs generation can be done as follows:
+
++--------
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <version>${project.version}</version>
+        <configuration>
+           [...]
+           <generateModuleId>true</generateModuleId>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
++---------
+
+  As a result, each module defined in the <<application.xml>> will have an ID unless an ID was provided in the
+  configuration. To provide an explicit ID for a given module, use the <<moduleId>> attribute; for instance:
+
++--------
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <version>${project.version}</version>
+        <configuration>
+           [...]
+           <modules>
+             <ejbModule>
+               <groupId>artifactGroupId</groupId>
+               <artifactId>artifactId</artifactId>
+               <moduleId>some-id</moduleId>
+             </ejbModule>
+          </modules>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
++---------

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=992817&r1=992816&r2=992817&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 Sun Sep  5 16:32:58 2010
@@ -119,4 +119,6 @@ Maven EAR Plugin
 
   * {{{./examples/generating-jboss-app.html} Generating the jboss-app.xml file}}
 
+  * {{{./examples/generating-modules-id.html} Generating modules id}}
+
    []

Modified: maven/plugins/trunk/maven-ear-plugin/src/site/apt/modules.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/modules.apt.vm?rev=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/modules.apt.vm (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/modules.apt.vm Sun Sep  5 16:32:58 2010
@@ -114,6 +114,8 @@ EAR Modules
   * <<altDeploymentDescriptor>> - sets the alternative deployment descriptor for
   this module.
 
+  * <<moduleId>> - sets the id of the module in the generated application.xml.
+
 
 * {ejbModule} Properties
 
@@ -148,6 +150,8 @@ EAR Modules
   * <<altDeploymentDescriptor>> - sets the alternative deployment descriptor for
   this module.
 
+  * <<moduleId>> - sets the id of the module in the generated application.xml.
+
 
 * {jarModule} Properties
 
@@ -182,6 +186,8 @@ EAR Modules
   * <<altDeploymentDescriptor>> - sets the alternative deployment descriptor for
   this module.
 
+  * <<moduleId>> - sets the id of the module in the generated application.xml.
+
   * <<includeInApplicationXml>> - set to true to if you want to generate an entry
   of this module in <<<application.xml>>>. Default is false.
 
@@ -219,6 +225,8 @@ EAR Modules
   * <<altDeploymentDescriptor>> - sets the alternative deployment descriptor for
   this module.
 
+  * <<moduleId>> - sets the id of the module in the generated application.xml.
+
 
 * {rarModule} Properties
 
@@ -253,6 +261,8 @@ EAR Modules
   * <<altDeploymentDescriptor>> - sets the alternative deployment descriptor for
   this module.
 
+  * <<moduleId>> - sets the id of the module in the generated application.xml.
+
 
 * {sarModule} Properties
 
@@ -284,6 +294,8 @@ EAR Modules
   * <<unpack>> - set to true to unpack this artifact into the ear archive according
   to its uri. Default is false.
 
+  * <<moduleId>> - sets the id of the module in the generated application.xml.
+
 
 * {webModule} Properties
 
@@ -318,6 +330,8 @@ EAR Modules
   * <<altDeploymentDescriptor>> - sets the alternative deployment descriptor for
   this module.
 
+  * <<moduleId>> - sets the id of the module in the generated application.xml.
+
   * <<contextRoot>> - sets the context root of this web artifact.
 
 
@@ -354,6 +368,8 @@ EAR Modules
   * <<altDeploymentDescriptor>> - sets the alternative deployment descriptor for
   this module.
 
+  * <<moduleId>> - sets the id of the module in the generated application.xml.
+
 
 * {harModule} Properties
 

Modified: maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt?rev=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt Sun Sep  5 16:32:58 2010
@@ -34,9 +34,9 @@ EAR Plugin Tests
 
   * project-002: builds an EAR with a customized artifact location and a customized artifact name
 
-  * project-003: builds an EAR with a defalt bundle directory for _java_ modules
+  * project-003: builds an EAR with a default bundle directory for _java_ modules
 
-  * project-004: builds an EAR with a defalt bundle directory for _java_ modules and a custom location overriding the default
+  * project-004: builds an EAR with a default bundle directory for _java_ modules and a custom location overriding the default
 
   * project-005: builds an EAR with a custom URI
 
@@ -158,5 +158,11 @@ EAR Plugin Tests
 
   * project-064: builds an EAR with ejb-client packaged for JavaEE 5 and still put it in the root
 
+  * project-065: builds an EAR with a custom moduleId
+
+  * project-066: builds an EAR with generateModuleId enabled
+
+  * project-067: builds an EAR with generateModuleId enabled and a custom module
+
 
    
\ No newline at end of file

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=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/site.xml (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/site.xml Sun Sep  5 16:32:58 2010
@@ -47,6 +47,7 @@ under the License.
       <item name="Specifying Security Roles For The Generated application.xml" href="examples/specifying-security-roles-for-the-generated-application-xml.html"/>
       <item name="Generating jboss-app.xml" href="examples/generating-jboss-app.html"/>
       <item name="Customize file name mapping" href="examples/customize-file-name-mapping.html"/>
+      <item name="Generating modules ID" href="examples/generating-modules-id.html"/>
     </menu>
   </body>
 </project>

Modified: maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java?rev=992817&r1=992816&r2=992817&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java Sun Sep  5 16:32:58 2010
@@ -19,8 +19,8 @@ package org.apache.maven.plugin.ear.it;
  * under the License.
  */
 
+import org.apache.maven.it.util.IOUtil;
 import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 
 import java.io.File;
@@ -54,7 +54,7 @@ public class EarMojoIT
     }
 
     /**
-     * Builds an EAR with a defalt bundle directory for <tt>java</tt> modules.
+     * Builds an EAR with a default bundle directory for <tt>java</tt> modules.
      */
     public void testProject003()
         throws Exception
@@ -64,7 +64,7 @@ public class EarMojoIT
     }
 
     /**
-     * Builds an EAR with a defalt bundle directory for _java_ modules and a custom
+     * Builds an EAR with a default bundle directory for _java_ modules and a custom
      * location overriding the default.
      */
     public void testProject004()
@@ -690,4 +690,32 @@ public class EarMojoIT
         doTestProject( "project-064", new String[]{ "ejb-sample-one-1.0.jar", "ejb-sample-two-1.0-client.jar" } );
     }
 
+    /**
+     * Builds an EAR with a custom moduleId.
+     */
+    public void testProject065()
+        throws Exception
+    {
+        doTestProject( "project-065", new String[]{ "ejb-sample-one-1.0.jar", "ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with generateModuleId enabled.
+     */
+    public void testProject066()
+        throws Exception
+    {
+        doTestProject( "project-066", new String[]{ "ejb-sample-one-1.0.jar", "ejb-sample-two-1.0.jar" } );
+    }
+
+
+    /**
+     * Builds an EAR with generateModuleId enabled and a custom module.
+     */
+    public void testProject067()
+        throws Exception
+    {
+        doTestProject( "project-067", new String[]{ "ejb-sample-one-1.0.jar", "ejb-sample-two-1.0.jar" } );
+    }
+
 }

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-065/expected-META-INF/application.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-065/expected-META-INF/application.xml?rev=992817&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-065/expected-META-INF/application.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-065/expected-META-INF/application.xml Sun Sep  5 16:32:58 2010
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<!DOCTYPE application PUBLIC
+	"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+	"http://java.sun.com/dtd/application_1_3.dtd">
+<application>
+  <display-name>maven-ear-plugin-test-project-065</display-name>
+  <module id="sample-one-id">
+    <ejb>ejb-sample-one-1.0.jar</ejb>
+  </module>
+  <module>
+    <ejb>ejb-sample-two-1.0.jar</ejb>
+  </module>
+</application>
\ No newline at end of file

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-065/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-065/pom.xml?rev=992817&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-065/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-065/pom.xml Sun Sep  5 16:32:58 2010
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>ear</groupId>
+  <artifactId>maven-ear-plugin-test-project-065</artifactId>
+  <version>99.0</version>
+  <name>Maven</name>
+  <packaging>ear</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>ejb-sample-one</artifactId>
+      <version>1.0</version>
+      <type>ejb</type>
+    </dependency>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>ejb-sample-two</artifactId>
+      <version>1.0</version>
+      <type>ejb</type>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <modules>
+            <ejbModule>
+              <groupId>eartest</groupId>
+              <artifactId>ejb-sample-one</artifactId>
+              <moduleId>sample-one-id</moduleId>
+            </ejbModule>
+          </modules>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-066/expected-META-INF/application.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-066/expected-META-INF/application.xml?rev=992817&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-066/expected-META-INF/application.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-066/expected-META-INF/application.xml Sun Sep  5 16:32:58 2010
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<!DOCTYPE application PUBLIC
+	"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+	"http://java.sun.com/dtd/application_1_3.dtd">
+<application>
+  <display-name>maven-ear-plugin-test-project-066</display-name>
+  <module id="EJB_eartest.ejb-sample-one">
+    <ejb>ejb-sample-one-1.0.jar</ejb>
+  </module>
+  <module id="EJB_eartest.ejb-sample-two">
+    <ejb>ejb-sample-two-1.0.jar</ejb>
+  </module>
+</application>
\ No newline at end of file

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-066/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-066/pom.xml?rev=992817&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-066/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-066/pom.xml Sun Sep  5 16:32:58 2010
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>ear</groupId>
+  <artifactId>maven-ear-plugin-test-project-066</artifactId>
+  <version>99.0</version>
+  <name>Maven</name>
+  <packaging>ear</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>ejb-sample-one</artifactId>
+      <version>1.0</version>
+      <type>ejb</type>
+    </dependency>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>ejb-sample-two</artifactId>
+      <version>1.0</version>
+      <type>ejb</type>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <generateModuleId>true</generateModuleId>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-067/expected-META-INF/application.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-067/expected-META-INF/application.xml?rev=992817&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-067/expected-META-INF/application.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-067/expected-META-INF/application.xml Sun Sep  5 16:32:58 2010
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<!DOCTYPE application PUBLIC
+	"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+	"http://java.sun.com/dtd/application_1_3.dtd">
+<application>
+  <display-name>maven-ear-plugin-test-project-067</display-name>
+  <module id="sample-one-id">
+    <ejb>ejb-sample-one-1.0.jar</ejb>
+  </module>
+  <module id="EJB_eartest.ejb-sample-two">
+    <ejb>ejb-sample-two-1.0.jar</ejb>
+  </module>
+</application>
\ No newline at end of file

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-067/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-067/pom.xml?rev=992817&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-067/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-067/pom.xml Sun Sep  5 16:32:58 2010
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>ear</groupId>
+  <artifactId>maven-ear-plugin-test-project-067</artifactId>
+  <version>99.0</version>
+  <name>Maven</name>
+  <packaging>ear</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>ejb-sample-one</artifactId>
+      <version>1.0</version>
+      <type>ejb</type>
+    </dependency>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>ejb-sample-two</artifactId>
+      <version>1.0</version>
+      <type>ejb</type>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <generateModuleId>true</generateModuleId>
+          <modules>
+            <ejbModule>
+              <groupId>eartest</groupId>
+              <artifactId>ejb-sample-one</artifactId>
+              <moduleId>sample-one-id</moduleId>
+            </ejbModule>
+          </modules>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>