maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r781168 - in /maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation: AbstractStringBasedModelInterpolator.java PathTranslatingPostProcessor.java
Date Tue, 02 Jun 2009 21:06:58 GMT
Author: bentmann
Date: Tue Jun  2 21:06:57 2009
New Revision: 781168

URL: http://svn.apache.org/viewvc?rev=781168&view=rev
Log:
o Minor tweaks to the interpolation post process:
  - Excluded it completely if it has nothing to do
  - Switched contains() test to use hash-based lookup rather than linear search

Modified:
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/PathTranslatingPostProcessor.java

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java?rev=781168&r1=781167&r2=781168&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
(original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
Tue Jun  2 21:06:57 2009
@@ -38,7 +38,9 @@
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Properties;
 
@@ -54,11 +56,11 @@
 {
     private static final List<String> PROJECT_PREFIXES = Arrays.asList( new String[]{
"pom.", "project." } );
 
-    private static final List<String> TRANSLATED_PATH_EXPRESSIONS;
+    private static final Collection<String> TRANSLATED_PATH_EXPRESSIONS;
 
     static
     {
-        List<String> translatedPrefixes = new ArrayList<String>();
+        Collection<String> translatedPrefixes = new HashSet<String>();
 
         // MNG-1927, MNG-2124, MNG-3355:
         // If the build section is present and the project directory is non-null, we should
make
@@ -150,9 +152,16 @@
                                                                                final File
projectDir,
                                                                                final ModelBuildingRequest
config )
     {
-        return Collections.singletonList( new PathTranslatingPostProcessor( PROJECT_PREFIXES,
-                                                                            TRANSLATED_PATH_EXPRESSIONS,
projectDir,
-                                                                            pathTranslator
) );
+        if ( projectDir != null )
+        {
+            return Collections.singletonList( new PathTranslatingPostProcessor( PROJECT_PREFIXES,
+                                                                                TRANSLATED_PATH_EXPRESSIONS,
+                                                                                projectDir,
pathTranslator ) );
+        }
+        else
+        {
+            return Collections.emptyList();
+        }
     }
     
     protected String interpolateInternal( String src, List<? extends ValueSource> valueSources,

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/PathTranslatingPostProcessor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/PathTranslatingPostProcessor.java?rev=781168&r1=781167&r2=781168&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/PathTranslatingPostProcessor.java
(original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/PathTranslatingPostProcessor.java
Tue Jun  2 21:06:57 2009
@@ -24,6 +24,7 @@
 import org.codehaus.plexus.interpolation.util.ValueSourceUtils;
 
 import java.io.File;
+import java.util.Collection;
 import java.util.List;
 
 /**
@@ -34,12 +35,12 @@
     implements InterpolationPostProcessor
 {
 
-    private final List<String> unprefixedPathKeys;
+    private final Collection<String> unprefixedPathKeys;
     private final File projectDir;
     private final PathTranslator pathTranslator;
     private final List<String> expressionPrefixes;
 
-    public PathTranslatingPostProcessor( List<String> expressionPrefixes, List<String>
unprefixedPathKeys, File projectDir, PathTranslator pathTranslator )
+    public PathTranslatingPostProcessor( List<String> expressionPrefixes, Collection<String>
unprefixedPathKeys, File projectDir, PathTranslator pathTranslator )
     {
         this.expressionPrefixes = expressionPrefixes;
         this.unprefixedPathKeys = unprefixedPathKeys;
@@ -49,11 +50,14 @@
 
     public Object execute( String expression, Object value )
     {
-        expression = ValueSourceUtils.trimPrefix( expression, expressionPrefixes, true );
-        
-        if ( projectDir != null && value != null && unprefixedPathKeys.contains(
expression ) )
+        if ( value != null )
         {
-            return pathTranslator.alignToBaseDirectory( String.valueOf( value ), projectDir
);
+            expression = ValueSourceUtils.trimPrefix( expression, expressionPrefixes, true
);
+
+            if ( unprefixedPathKeys.contains( expression ) )
+            {
+                return pathTranslator.alignToBaseDirectory( String.valueOf( value ), projectDir
);
+            }
         }
 
         return value;



Mime
View raw message