You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2013/11/12 23:08:00 UTC

svn commit: r1541259 - in /maven/plugins/trunk/maven-ear-plugin/src: main/java/org/apache/maven/plugin/ear/ test/java/org/apache/maven/plugin/ear/it/ test/resources/projects/project-084/ test/resources/projects/project-084/expected-META-INF/

Author: rfscholte
Date: Tue Nov 12 22:07:59 2013
New Revision: 1541259

URL: http://svn.apache.org/r1541259
Log:
[MEAR-174] generate-application-xml does not support the definition of an application id

Added:
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/   (with props)
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/expected-META-INF/   (with props)
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/expected-META-INF/application.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/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/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=1541259&r1=1541258&r2=1541259&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 Tue Nov 12 22:07:59 2013
@@ -76,9 +76,15 @@ final class ApplicationXmlWriter
         }
         else if ( JavaEEVersion.Seven.eq( version ) )
         {
-                writer = initializeRootElementSeven( w );
+            writer = initializeRootElementSeven( w );
         }
-        
+
+        // writer is still on root element, so we can still add this attribute
+        if ( context.getApplicationId() != null )
+        {
+            writer.addAttribute( "id", context.getApplicationId() );
+        }
+
         // As from JavaEE6
         if ( version.ge( JavaEEVersion.Six ) )
         {

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=1541259&r1=1541258&r2=1541259&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 Tue Nov 12 22:07:59 2013
@@ -31,6 +31,8 @@ import java.util.List;
 class ApplicationXmlWriterContext
 {
 
+    private String applicationId;
+    
     private final File destinationFile;
 
     private final List<EarModule> earModules;
@@ -65,6 +67,17 @@ class ApplicationXmlWriterContext
         this.initializeInOrder = initializeInOrder;
     }
 
+    public final ApplicationXmlWriterContext setApplicationId( String applicationId )
+    {
+        this.applicationId = applicationId;
+        return this;
+    }
+    
+    public final String getApplicationId()
+    {
+        return applicationId;
+    }
+    
     /**
      * Returns the name of the file to use to write application.xml to.
      *

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=1541259&r1=1541258&r2=1541259&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 Tue Nov 12 22:07:59 2013
@@ -118,6 +118,13 @@ public class GenerateApplicationXmlMojo
     private Boolean initializeInOrder;
 
     /**
+     * Defines the application id used when generating the deployment descriptor.
+     * @since 2.9
+     */
+    @Parameter
+    private String  applicationId;
+    
+    /**
      * The security-roles to be added to the auto-generated
      * application.xml file.
      */
@@ -216,7 +223,7 @@ public class GenerateApplicationXmlMojo
         final ApplicationXmlWriterContext context =
             new ApplicationXmlWriterContext( descriptor, getModules(), buildSecurityRoles(), buildEnvEntries(),
                                              displayName, description, getActualLibraryDirectory(), applicationName,
-                                             initializeInOrder );
+                                             initializeInOrder ).setApplicationId( applicationId );
         writer.write( context );
     }
 

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=1541259&r1=1541258&r2=1541259&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 Tue Nov 12 22:07:59 2013
@@ -867,4 +867,13 @@ public class EarMojoIT
     {
         doTestProject( "project-083", new String[] { "ejb-sample-one-1.0.jar", "ejb-sample-two-1.0.jar" } );
     }
+
+    /**
+     * Support of an application id (MEAR-174).
+     */
+    public void testProject084()
+        throws Exception
+    {
+        doTestProject( "project-084", new String[] { "ejb-sample-one-1.0.jar" } );
+    }
 }

Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Tue Nov 12 22:07:59 2013
@@ -0,0 +1 @@
+MEAR-\d+

Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/
------------------------------------------------------------------------------
    bugtraq:url = http://jira.codehaus.org/browse/%BUGID%

Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/expected-META-INF/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Tue Nov 12 22:07:59 2013
@@ -0,0 +1 @@
+MEAR-\d+

Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/expected-META-INF/
------------------------------------------------------------------------------
    bugtraq:url = http://jira.codehaus.org/browse/%BUGID%

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/expected-META-INF/application.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/expected-META-INF/application.xml?rev=1541259&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/expected-META-INF/application.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/expected-META-INF/application.xml Tue Nov 12 22:07:59 2013
@@ -0,0 +1,25 @@
+<?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.
+-->
+<application xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" version="7" id="myapp">
+  <display-name>maven-ear-plugin-test-project-084</display-name>
+  <module>
+    <ejb>ejb-sample-one-1.0.jar</ejb>
+  </module>
+</application>

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/pom.xml?rev=1541259&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-084/pom.xml Tue Nov 12 22:07:59 2013
@@ -0,0 +1,50 @@
+<?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-084</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>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <version>7</version>
+          <applicationId>myapp</applicationId>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>