maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khmarba...@apache.org
Subject svn commit: r1806368 - in /maven/plugins/trunk/maven-ear-plugin/src: main/java/org/apache/maven/plugins/ear/ site/apt/examples/ test/java/org/apache/maven/plugins/ear/
Date Sun, 27 Aug 2017 13:54:21 GMT
Author: khmarbaise
Date: Sun Aug 27 13:54:21 2017
New Revision: 1806368

URL: http://svn.apache.org/viewvc?rev=1806368&view=rev
Log:
[MEAR-248] Support lookup-name in env-entry section
 o Added lookup-name in env-entry section.

Modified:
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EnvEntry.java
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/specifying-env-entries-for-the-generated-application-xml.apt.vm
    maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EnvEntry.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EnvEntry.java?rev=1806368&r1=1806367&r2=1806368&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EnvEntry.java
(original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EnvEntry.java
Sun Aug 27 13:54:21 2017
@@ -41,6 +41,8 @@ class EnvEntry
 
     static final String ENV_ENTRY_VALUE = "env-entry-value";
 
+    static final String ENV_LOOKUP_NAME = "lookup-name";
+
     private final String description;
 
     private final String name;
@@ -49,7 +51,9 @@ class EnvEntry
 
     private final String value;
 
-    public EnvEntry( String description, String name, String type, String value )
+    private final String lookupName;
+
+    public EnvEntry( String description, String name, String type, String value, String lookupName
)
     {
         if ( StringUtils.isEmpty( name ) )
         {
@@ -66,6 +70,7 @@ class EnvEntry
         this.name = name;
         this.type = type;
         this.value = value;
+        this.lookupName = lookupName;
     }
 
     public String getDescription()
@@ -88,6 +93,11 @@ class EnvEntry
         return value;
     }
 
+    public String getLookupName()
+    {
+        return lookupName;
+    }
+
     /**
      * Appends the <tt>XML</tt> representation of this env-entry.
      * 
@@ -119,6 +129,12 @@ class EnvEntry
             doWriteElement( writer, ENV_ENTRY_VALUE, getValue() );
         }
 
+        // lookup-name
+        if ( getLookupName() != null )
+        {
+            doWriteElement( writer, ENV_LOOKUP_NAME, getLookupName() );
+        }
+
         // end of env-entry
         writer.endElement();
     }
@@ -132,7 +148,8 @@ class EnvEntry
 
     public String toString()
     {
-        return "env-entry [name=" + getName() + ", type=" + getType() + ", value=" + getValue()
+ "]";
+        return "env-entry [name=" + getName() + ", type=" + getType() + ", value=" + getValue()
+ ", lookup-name="
+            + getLookupName() + "]";
     }
 
 }
\ No newline at end of file

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java?rev=1806368&r1=1806367&r2=1806368&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java
(original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java
Sun Aug 27 13:54:21 2017
@@ -356,6 +356,8 @@ public class GenerateApplicationXmlMojo
 
             final PlexusConfiguration[] allEnvEntries = envEntries.getChildren( EnvEntry.ENV_ENTRY
);
 
+            getLog().debug( "buildEnvEntries: allEnvEntries:" + allEnvEntries );
+            getLog().debug( "buildEnvEntries: allEnvEntries size:" + allEnvEntries.length
);
             for ( PlexusConfiguration envEntry : allEnvEntries )
             {
                 // CHECKSTYLE_OFF: LineLength
@@ -367,12 +369,14 @@ public class GenerateApplicationXmlMojo
                     interpolate( ssi, envEntry.getChild( EnvEntry.ENV_ENTRY_TYPE ).getValue()
);
                 final String childEnvEntryValue =
                     interpolate( ssi, envEntry.getChild( EnvEntry.ENV_ENTRY_VALUE ).getValue()
);
+                final String childEnvLookupNameValue =
+                    interpolate( ssi, envEntry.getChild( EnvEntry.ENV_LOOKUP_NAME ).getValue()
);
                 // CHECKSTYLE_ON: LineLength
 
                 try
                 {
                     result.add( new EnvEntry( childDescription, childEnvEntryName, childEnvEntryType,
-                                              childEnvEntryValue ) );
+                                              childEnvEntryValue, childEnvLookupNameValue
) );
                 }
                 catch ( IllegalArgumentException e )
                 {

Modified: maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/specifying-env-entries-for-the-generated-application-xml.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/specifying-env-entries-for-the-generated-application-xml.apt.vm?rev=1806368&r1=1806367&r2=1806368&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/specifying-env-entries-for-the-generated-application-xml.apt.vm
(original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/specifying-env-entries-for-the-generated-application-xml.apt.vm
Sun Aug 27 13:54:21 2017
@@ -4,7 +4,7 @@
   Stephane Nicoll
   <snicoll@apache.org>
   ------
-  January 25, 2012
+  August 27, 2017
 
 ~~ Copyright 2006 The Apache Software Foundation.
 ~~
@@ -45,6 +45,7 @@ Specifying Environment entries For The G
                <env-entry-name>complete</env-entry-name>
                <env-entry-type>java.lang.Integer</env-entry-type>
                <env-entry-value>4</env-entry-value>
+               <lookup-name>java:global/Example</lookup-name>
              </env-entry>
              <env-entry>
                <env-entry-name>no-type</env-entry-name>

Modified: maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java?rev=1806368&r1=1806367&r2=1806368&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java
(original)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java
Sun Aug 27 13:54:21 2017
@@ -40,48 +40,55 @@ public class EnvEntryTest
 
     public static final String VALUE = "34";
 
+    public static final String LOOKUP_NAME = "lookupName";
+
     @Test
     public void createComplete()
     {
-        final EnvEntry envEntry = new EnvEntry( DESCRIPTION, NAME, TYPE, VALUE );
-        assertEnvEntry( envEntry, DESCRIPTION, NAME, TYPE, VALUE );
+        final EnvEntry envEntry = new EnvEntry( DESCRIPTION, NAME, TYPE, VALUE, LOOKUP_NAME
);
+        assertEnvEntry( envEntry, DESCRIPTION, NAME, TYPE, VALUE, LOOKUP_NAME );
     }
 
     @Test
     public void createWithoutTypeButValue()
     {
-        final EnvEntry envEntry = new EnvEntry( null, NAME, null, VALUE );
-        assertEnvEntry( envEntry, null, NAME, null, VALUE );
+        final EnvEntry envEntry = new EnvEntry( null, NAME, null, VALUE, LOOKUP_NAME );
+        assertEnvEntry( envEntry, null, NAME, null, VALUE, LOOKUP_NAME );
     }
 
     @Test( expected = IllegalArgumentException.class )
     public void createWithoutName()
     {
-        new EnvEntry( DESCRIPTION, null, TYPE, VALUE );
+        new EnvEntry( DESCRIPTION, null, TYPE, VALUE, LOOKUP_NAME );
 
     }
 
     @Test( expected = IllegalArgumentException.class )
     public void createWithEmptyName()
     {
-        new EnvEntry( DESCRIPTION, "", TYPE, VALUE );
+        new EnvEntry( DESCRIPTION, "", TYPE, VALUE, LOOKUP_NAME );
     }
 
     @Test( expected = IllegalArgumentException.class )
     public void createWithNullTypeAndNoValue()
     {
-        new EnvEntry( DESCRIPTION, NAME, null, null );
-
+        new EnvEntry( DESCRIPTION, NAME, null, null, LOOKUP_NAME );
     }
 
     @Test( expected = IllegalArgumentException.class )
     public void createWithEmptyTypeAndNoValue()
     {
-        new EnvEntry( DESCRIPTION, NAME, "", null );
+        new EnvEntry( DESCRIPTION, NAME, "", null, LOOKUP_NAME );
+    }
 
+    @Test
+    public void createWithEmptyLookupName()
+    {
+        new EnvEntry( DESCRIPTION, NAME, TYPE, VALUE, null );
     }
 
-    private void assertEnvEntry( EnvEntry actual, String description, String name, String
type, String value )
+    private void assertEnvEntry( EnvEntry actual, String description, String name, String
type, String value,
+                                 String lookupName )
     {
         assertNotNull( "Env entry could not be null", actual );
         assertNotNull( "ToString could not be null", actual.toString() );
@@ -89,6 +96,7 @@ public class EnvEntryTest
         assertEquals( "Wrong env entry name for [" + actual + "]", name, actual.getName()
);
         assertEquals( "Wrong env entry type for [" + actual + "]", type, actual.getType()
);
         assertEquals( "Wrong env entry value for [" + actual + "]", value, actual.getValue()
);
+        assertEquals( "Wrong env entry value for [" + actual + "]", lookupName, actual.getLookupName()
);
 
     }
 }



Mime
View raw message