This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch MEAR-271
in repository https://gitbox.apache.org/repos/asf/maven-ear-plugin.git

commit f002918d6cad2e607572a5049fe2b8e078a04979
Author: Fabio Boldrini <fabio.boldr...@netserv.it>
AuthorDate: Mon Nov 5 17:42:09 2018 +0100

    [MEAR-271] - Support lookup-name in resource-ref section
---
 Jenkinsfile                                        |  3 +-
 pom.xml                                            |  2 ++
 .../plugins/ear/GenerateApplicationXmlMojo.java    |  6 +++-
 .../org/apache/maven/plugins/ear/ResourceRef.java  | 38 +++++++++++++++++++++-
 ...ntries-for-the-generated-application-xml.apt.vm |  5 +++
 .../project-087/expected-META-INF/application.xml  |  5 +++
 src/test/resources/projects/project-087/pom.xml    |  5 +++
 7 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index e9f05f7..4e3eef0 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -17,4 +17,5 @@
  * under the License.
  */
 
-asfMavenTlpPlgnBuild()
+// asfMavenTlpStdBuild( 'jdks' : [ "11" ] )
+asfMavenTlpStdBuild( )
diff --git a/pom.xml b/pom.xml
index ed5cc55..04c051b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,6 +84,7 @@
     <mavenFilteringVersion>3.1.1</mavenFilteringVersion>
     <mavenVersion>3.0</mavenVersion>
     <javaVersion>7</javaVersion>
+    <surefire.version>2.22.1</surefire.version>
   </properties>
 
   <dependencies>
@@ -255,6 +256,7 @@
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-invoker-plugin</artifactId>
             <configuration>
+              <streamLogs>true</streamLogs>
               <!-- NOTE: Must be synced with the repo path used by 
AbstractEarPluginIT -->
               <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
               <goals>
diff --git 
a/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java 
b/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java
index 9d3565e..e39a88e 100644
--- a/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java
+++ b/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java
@@ -480,11 +480,15 @@ public class GenerateApplicationXmlMojo
                     interpolate( ssi, resEntry.getChild( 
ResourceRef.RESOURCE_TYPE ).getValue() );
                 final String childResRefAuth =
                     interpolate( ssi, resEntry.getChild( 
ResourceRef.RESOURCE_AUTH ).getValue() );
+                final String childResRefLookupName =
+                    interpolate( ssi, resEntry.getChild( 
ResourceRef.LOOKUP_NAME ).getValue() );
                 // CHECKSTYLE_ON: LineLength
 
                 try
                 {
-                    result.add( new ResourceRef( childResRefName, 
childResType, childResRefAuth ) );
+                    // CHECKSTYLE_OFF: LineLength
+                    result.add( new ResourceRef( childResRefName, 
childResType, childResRefAuth, childResRefLookupName ) );
+                    // CHECKSTYLE_ON: LineLength
                 }
                 catch ( IllegalArgumentException e )
                 {
diff --git a/src/main/java/org/apache/maven/plugins/ear/ResourceRef.java 
b/src/main/java/org/apache/maven/plugins/ear/ResourceRef.java
index 5f3d905..89ac1e4 100644
--- a/src/main/java/org/apache/maven/plugins/ear/ResourceRef.java
+++ b/src/main/java/org/apache/maven/plugins/ear/ResourceRef.java
@@ -32,6 +32,14 @@ import org.codehaus.plexus.util.xml.XMLWriter;
  *   &lt;res-auth&gt;Container&lt;/res-auth&gt;
  * &lt;/resource-ref&gt;
  * </pre>
+ * or
+ * <pre>
+ * &lt;resource-ref&gt;
+ *   &lt;res-ref-name&gt;jdbc/myDs&lt;/res-ref-name&gt;
+ *   &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
+ *   &lt;lookup-name&gt;jdbc/lookup/myDs&lt;/lookup-name&gt;
+ * &lt;/resource-ref&gt;
+ * </pre>
  * 
  * @author Karl Heinz Marbaise
  * @since 3.0.0
@@ -46,18 +54,23 @@ public class ResourceRef
 
     static final String RESOURCE_AUTH = "res-auth";
 
+   static final String LOOKUP_NAME = "lookup-name";
+
     private String name;
 
     private String type;
 
     private String auth;
 
+   private String lookupName;
+
     /**
      * @param name The res-ref-name.
      * @param type The res-type
      * @param auth The res-auth.
+     * @param lookupName The lookup-name.
      */
-    public ResourceRef( String name, String type, String auth )
+   public ResourceRef( String name, String type, String auth, String 
lookupName )
     {
         if ( StringUtils.isEmpty( name ) )
         {
@@ -73,6 +86,7 @@ public class ResourceRef
         this.name = name;
         this.type = type;
         this.auth = auth;
+        this.lookupName = lookupName;
 
     }
 
@@ -100,6 +114,12 @@ public class ResourceRef
             doWriteElement( writer, RESOURCE_AUTH, getAuth() );
         }
 
+        // lookup-name
+        if ( getLookupName() != null ) 
+        {
+            doWriteElement( writer, LOOKUP_NAME, getLookupName() );
+        }
+
         // end of ejb-ref
         writer.endElement();
     }
@@ -158,5 +178,21 @@ public class ResourceRef
     {
         this.auth = auth;
     }
+    
+    /**
+     * @return {@link #LookupName}
+     */
+    public String getLookupName() 
+    {
+        return lookupName;
+    }
+
+   /**
+    * @param auth {@link #LookupName}
+    */
+    public void setLookupName( String lookupName ) 
+    {
+        this.lookupName = lookupName;
+    }
 
 }
diff --git 
a/src/site/apt/examples/specifying-resource-ref-entries-for-the-generated-application-xml.apt.vm
 
b/src/site/apt/examples/specifying-resource-ref-entries-for-the-generated-application-xml.apt.vm
index 393ddad..3646aad 100644
--- 
a/src/site/apt/examples/specifying-resource-ref-entries-for-the-generated-application-xml.apt.vm
+++ 
b/src/site/apt/examples/specifying-resource-ref-entries-for-the-generated-application-xml.apt.vm
@@ -49,6 +49,11 @@ Specifying Resource Ref entries For The Generated 
application.xml
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
              </resourceRef>
+             <resourceRef>
+               <res-ref-name>jdbc/myDs3</res-ref-name>
+               <res-type>javax.sql.DataSource</res-type>
+               <lookup-name>jdbc/lookup/myDs3</lookup-name>
+             </resourceRef>
             </resourceRefs>
           </configuration>
       </plugin>
diff --git 
a/src/test/resources/projects/project-087/expected-META-INF/application.xml 
b/src/test/resources/projects/project-087/expected-META-INF/application.xml
index d1ab0f7..e54da28 100644
--- a/src/test/resources/projects/project-087/expected-META-INF/application.xml
+++ b/src/test/resources/projects/project-087/expected-META-INF/application.xml
@@ -50,4 +50,9 @@ under the License.
     <res-type>javax.sql.DataSource</res-type>
     <res-auth>Container</res-auth>
   </resource-ref>
+  <resource-ref>
+    <res-ref-name>jdbc/myDs3</res-ref-name>
+    <res-type>javax.sql.DataSource</res-type>
+    <lookup-name>jdbc/lookup/myDs3</lookup-name>
+  </resource-ref>
 </application>
diff --git a/src/test/resources/projects/project-087/pom.xml 
b/src/test/resources/projects/project-087/pom.xml
index 804e903..76d6e1d 100644
--- a/src/test/resources/projects/project-087/pom.xml
+++ b/src/test/resources/projects/project-087/pom.xml
@@ -59,6 +59,11 @@ under the License.
               <res-type>javax.sql.DataSource</res-type>
               <res-auth>Container</res-auth>
             </resourceRef>
+            <resourceRef>
+              <res-ref-name>jdbc/myDs3</res-ref-name>
+              <res-type>javax.sql.DataSource</res-type>
+              <lookup-name>jdbc/lookup/myDs3</lookup-name>
+            </resourceRef>
           </resourceRefs>
           <envEntries>
             <env-entry>

Reply via email to