Author: snicoll
Date: Sun Dec 19 15:24:18 2010
New Revision: 1050877

URL: http://svn.apache.org/viewvc?rev=1050877&view=rev
Log:
MEAR-128: added support for application-name and initialize-in-order (JavaEE 6 
features)

Added:
    
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-070/
    
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-070/expected-META-INF/
    
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-070/expected-META-INF/application.xml
      - copied, changed from r1050854, 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-069/expected-META-INF/application.xml
    
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-070/pom.xml
      - copied, changed from r1050854, 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-069/pom.xml
    
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-071/
    
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-071/expected-META-INF/
    
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-071/expected-META-INF/application.xml
      - copied, changed from r1050854, 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-044/expected-META-INF/application.xml
    
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-071/pom.xml
Modified:
    
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/ApplicationXmlWriterContext.java
    
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt
    
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/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=1050877&r1=1050876&r2=1050877&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 Dec 19 15:24:18 2010
@@ -75,6 +75,11 @@ final class ApplicationXmlWriter
             writer = initializeRootElementSix( w );
         }
 
+        // JavaEE6 only
+        if (GenerateApplicationXmlMojo.VERSION_6.equals( version )) {
+            writeApplicationName( context.getApplicationName(), writer );
+        }
+
         // IMPORTANT: the order of the description and display-name elements 
was
         // reversed between J2EE 1.3 and J2EE 1.4.
         if ( GenerateApplicationXmlMojo.VERSION_1_3.equals( version ) )
@@ -87,6 +92,12 @@ final class ApplicationXmlWriter
             writeDescription( context.getDescription(), writer );
             writeDisplayName( context.getDisplayName(), writer );
         }
+
+        // JavaEE6 only
+        if (GenerateApplicationXmlMojo.VERSION_6.equals( version )) {
+            writeInitializeInOrder( context.getInitializeInOrder(), writer );
+        }
+
         // Do not change this unless you really know what you're doing :)
 
         final Iterator moduleIt = context.getEarModules().iterator();
@@ -114,6 +125,16 @@ final class ApplicationXmlWriter
         close( w );
     }
 
+    private void writeApplicationName( String applicationName, XMLWriter 
writer )
+    {
+        if ( applicationName != null )
+        {
+            writer.startElement( "application-name" );
+            writer.writeText( applicationName );
+            writer.endElement();
+        }
+    }
+
     private void writeDescription( String description, XMLWriter writer )
     {
         if ( description != null )
@@ -134,6 +155,16 @@ final class ApplicationXmlWriter
         }
     }
 
+     private void writeInitializeInOrder( Boolean initializeInOrder, XMLWriter 
writer )
+    {
+        if ( initializeInOrder != null )
+        {
+            writer.startElement( "initialize-in-order" );
+            writer.writeText( initializeInOrder.toString() );
+            writer.endElement();
+        }
+    }
+
     private void writeLibraryDirectory( String libraryDirectory, XMLWriter 
writer )
     {
         if ( libraryDirectory != null )

Modified: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/ApplicationXmlWriterContext.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/ApplicationXmlWriterContext.java?rev=1050877&r1=1050876&r2=1050877&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/ApplicationXmlWriterContext.java
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/ApplicationXmlWriterContext.java
 Sun Dec 19 15:24:18 2010
@@ -43,8 +43,13 @@ class ApplicationXmlWriterContext
 
     private final String libraryDirectory;
 
+    private final String applicationName;
+
+    private final Boolean initializeInOrder;
+
     public ApplicationXmlWriterContext( File destinationFile, List earModules, 
List securityRoles, String displayName,
-                                        String description, String 
libraryDirectory )
+                                        String description, String 
libraryDirectory, String applicationName,
+                                        Boolean initializeInOrder )
     {
         this.destinationFile = destinationFile;
         this.earModules = earModules;
@@ -52,6 +57,8 @@ class ApplicationXmlWriterContext
         this.displayName = displayName;
         this.description = description;
         this.libraryDirectory = libraryDirectory;
+        this.applicationName = applicationName;
+        this.initializeInOrder = initializeInOrder;
     }
 
     /**
@@ -113,4 +120,25 @@ class ApplicationXmlWriterContext
     {
         return libraryDirectory;
     }
+
+    /**
+     * Returns the application name (as per JavaEE 6).
+     *
+     * @return the application name
+     */
+    public String getApplicationName()
+    {
+        return applicationName;
+    }
+
+    /**
+     * Returns the value of the initialize in order
+     * parameter (as per JavaEE 6).
+     *
+     * @return the initialize in order value
+     */
+    public Boolean getInitializeInOrder()
+    {
+        return initializeInOrder;
+    }
 }

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=1050877&r1=1050876&r2=1050877&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 Dec 19 15:24:18 2010
@@ -60,22 +60,43 @@ public class GenerateApplicationXmlMojo
     private Boolean generateModuleId = Boolean.FALSE;
 
     /**
-     * Display name of the application to be used when application.xml
-     * file is autogenerated.
+     * Application name of the application to be used when the application.xml
+     * file is auto-generated. Since JavaEE6.
+     *
+     * @parameter
+     */
+    private String applicationName;
+
+    /**
+     * Display name of the application to be used when the application.xml
+     * file is auto-generated.
      *
      * @parameter default-value="${project.artifactId}"
      */
     private String displayName;
 
     /**
-     * Description of the application to be used when application.xml
-     * file is autogenerated.
+     * Description of the application to be used when the application.xml
+     * file is auto-generated.
      *
      * @parameter default-value="${project.description}"
      */
     private String description;
 
     /**
+     * Defines the value of the initialize in order element to be used when
+     * the application.xml file is auto-generated. When set to true, modules
+     * must be initialized in the order they're listed in this deployment 
descriptor,
+     * with the exception of application client modules, which can be
+     * initialized in any order. If initialize-in-order is not set or set to
+     * false, the order of initialization is unspecified and may be
+     * product-dependent. Since JavaEE6.
+     *
+     * @parameter
+     */
+    private Boolean initializeInOrder;
+
+    /**
      * The security-roles to be added to the auto-generated
      * application.xml file.
      *
@@ -174,7 +195,7 @@ public class GenerateApplicationXmlMojo
         final ApplicationXmlWriter writer = new ApplicationXmlWriter( version, 
encoding, generateModuleId );
         final ApplicationXmlWriterContext context =
             new ApplicationXmlWriterContext( descriptor, getModules(), 
buildSecurityRoles(), displayName, description,
-                                             defaultLibBundleDir );
+                                             defaultLibBundleDir, 
applicationName, initializeInOrder );
         writer.write( context );
     }
 

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=1050877&r1=1050876&r2=1050877&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 Dec 19 
15:24:18 2010
@@ -168,3 +168,7 @@ EAR Plugin Tests
 
   * project-069: builds an EAR with a custom library-directory and JavaEE 6
 
+  * project-070: builds an EAR with application-name and initialize-in-order 
tags
+
+  * project-071: builds an EAR with application-name and initialize-in-order 
tags for unsupported version
+

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=1050877&r1=1050876&r2=1050877&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 Dec 19 15:24:18 2010
@@ -726,7 +726,7 @@ public class EarMojoIT
         doTestProject( "project-068", new String[]{ "ejb-sample-one.jar", 
"ejb-sample-two.jar" } );
     }
 
-     /**
+    /**
      * Builds an EAR with a custom library-directory and JavaEE 6.
      */
     public void testProject069()
@@ -735,4 +735,22 @@ public class EarMojoIT
         doTestProject( "project-069", new String[]{ "ejb-sample-one-1.0.jar", 
"myLibs/jar-sample-one-1.0.jar" } );
     }
 
+    /**
+     * Builds an EAR with application-name and initialize-in-order tags.
+     */
+    public void testProject070()
+        throws Exception
+    {
+        doTestProject( "project-070", new String[]{ "ejb-sample-one-1.0.jar", 
"jar-sample-one-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with application-name and initialize-in-order tags for 
unsupported version.
+     */
+    public void testProject071()
+        throws Exception
+    {
+        doTestProject( "project-071", new String[]{ "ejb-sample-one-1.0.jar", 
"jar-sample-one-1.0.jar" } );
+    }
+
 }

Copied: 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-070/expected-META-INF/application.xml
 (from r1050854, 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-069/expected-META-INF/application.xml)
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-070/expected-META-INF/application.xml?p2=maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-070/expected-META-INF/application.xml&p1=maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-069/expected-META-INF/application.xml&r1=1050854&r2=1050877&rev=1050877&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-069/expected-META-INF/application.xml
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-070/expected-META-INF/application.xml
 Sun Dec 19 15:24:18 2010
@@ -18,9 +18,10 @@ specific language governing permissions 
 under the License.
 -->
 <application xmlns="http://java.sun.com/xml/ns/javaee"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/application_6.xsd"; version="6">
-  <display-name>maven-ear-plugin-test-project-069</display-name>
+  <application-name>My application</application-name>
+  <display-name>maven-ear-plugin-test-project-070</display-name>
+  <initialize-in-order>true</initialize-in-order>
   <module>
     <ejb>ejb-sample-one-1.0.jar</ejb>
   </module>
-  <library-directory>myLibs</library-directory>
 </application>

Copied: 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-070/pom.xml
 (from r1050854, 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-069/pom.xml)
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-070/pom.xml?p2=maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-070/pom.xml&p1=maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-069/pom.xml&r1=1050854&r2=1050877&rev=1050877&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-069/pom.xml
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-070/pom.xml
 Sun Dec 19 15:24:18 2010
@@ -22,7 +22,7 @@ under the License.
          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-069</artifactId>
+  <artifactId>maven-ear-plugin-test-project-070</artifactId>
   <version>99.0</version>
   <name>Maven</name>
   <packaging>ear</packaging>
@@ -47,7 +47,8 @@ under the License.
         <version>@project.version@</version>
         <configuration>
           <version>6</version>
-          <defaultLibBundleDir>myLibs</defaultLibBundleDir>         
+          <applicationName>My application</applicationName>
+          <initializeInOrder>true</initializeInOrder>
         </configuration>
       </plugin>
     </plugins>

Copied: 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-071/expected-META-INF/application.xml
 (from r1050854, 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-044/expected-META-INF/application.xml)
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-071/expected-META-INF/application.xml?p2=maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-071/expected-META-INF/application.xml&p1=maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-044/expected-META-INF/application.xml&r1=1050854&r2=1050877&rev=1050877&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-044/expected-META-INF/application.xml
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-071/expected-META-INF/application.xml
 Sun Dec 19 15:24:18 2010
@@ -19,9 +19,8 @@ under the License.
 -->
 
 <application xmlns="http://java.sun.com/xml/ns/javaee"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/application_5.xsd"; version="5">
-  <display-name>maven-ear-plugin-test-project-044</display-name>
+  <display-name>maven-ear-plugin-test-project-071</display-name>
   <module>
     <ejb>ejb-sample-one-1.0.jar</ejb>
   </module>
-  <library-directory>myLibs</library-directory>
 </application>
\ No newline at end of file

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-071/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-071/pom.xml?rev=1050877&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-071/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-071/pom.xml
 Sun Dec 19 15:24:18 2010
@@ -0,0 +1,56 @@
+<?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-071</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>jar-sample-one</artifactId>
+      <version>1.0</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <version>5</version>
+          <applicationName>My application</applicationName>
+          <initializeInOrder>true</initializeInOrder>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>


Reply via email to