[MEAR-271] - Support lookup-name in resource-ref section master
authorFabio Boldrini <fabio.boldrini@netserv.it>
Mon, 5 Nov 2018 16:42:09 +0000 (17:42 +0100)
committerKarl Heinz Marbaise <khmarbaise@apache.org>
Fri, 9 Nov 2018 21:07:28 +0000 (22:07 +0100)
Jenkinsfile
pom.xml
src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java
src/main/java/org/apache/maven/plugins/ear/ResourceRef.java
src/site/apt/examples/specifying-resource-ref-entries-for-the-generated-application-xml.apt.vm
src/test/resources/projects/project-087/expected-META-INF/application.xml
src/test/resources/projects/project-087/pom.xml

index e9f05f7..4e3eef0 100644 (file)
@@ -17,4 +17,5 @@
  * under the License.
  */
 
-asfMavenTlpPlgnBuild()
+// asfMavenTlpStdBuild( 'jdks' : [ "11" ] )
+asfMavenTlpStdBuild( )
diff --git a/pom.xml b/pom.xml
index ed5cc55..04c051b 100644 (file)
--- 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>
             <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>
index 9d3565e..e39a88e 100644 (file)
@@ -480,11 +480,15 @@ public class GenerateApplicationXmlMojo
                     interpolate( ssi, resEntry.getChild( ResourceRef.RESOURCE_TYPE ).getValue() );\r
                 final String childResRefAuth =\r
                     interpolate( ssi, resEntry.getChild( ResourceRef.RESOURCE_AUTH ).getValue() );\r
+                final String childResRefLookupName =\r
+                    interpolate( ssi, resEntry.getChild( ResourceRef.LOOKUP_NAME ).getValue() );\r
                 // CHECKSTYLE_ON: LineLength\r
 \r
                 try\r
                 {\r
-                    result.add( new ResourceRef( childResRefName, childResType, childResRefAuth ) );\r
+                    // CHECKSTYLE_OFF: LineLength\r
+                    result.add( new ResourceRef( childResRefName, childResType, childResRefAuth, childResRefLookupName ) );\r
+                    // CHECKSTYLE_ON: LineLength\r
                 }\r
                 catch ( IllegalArgumentException e )\r
                 {\r
index 5f3d905..89ac1e4 100644 (file)
@@ -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;
+    }
 
 }
index 393ddad..3646aad 100644 (file)
@@ -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>
index d1ab0f7..e54da28 100644 (file)
@@ -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>
index 804e903..76d6e1d 100644 (file)
@@ -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>