maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r780749 - in /maven/components/trunk: ./ maven-model-builder/ maven-model-builder/src/main/java/org/apache/maven/model/ maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ maven-model-builder/src/main/java/org/apache/mav...
Date Mon, 01 Jun 2009 17:49:35 GMT
Author: bentmann
Date: Mon Jun  1 17:49:34 2009
New Revision: 780749

URL: http://svn.apache.org/viewvc?rev=780749&view=rev
Log:
o Flipped interpolation over to use the in-memory based interpolator from 2.2.x which makes
the overall building twice as fast as before

Added:
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/
      - copied from r780665, maven/components/branches/maven-2.2.x/maven-project/src/main/java/org/apache/maven/project/interpolation/
Removed:
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/RegexBasedModelInterpolator.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/
Modified:
    maven/components/trunk/maven-model-builder/pom.xml
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java
    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/BuildTimestampValueSource.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolationException.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolator.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/PathTranslatingPostProcessor.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java
    maven/components/trunk/pom.xml

Modified: maven/components/trunk/maven-model-builder/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/pom.xml?rev=780749&r1=780748&r2=780749&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/pom.xml (original)
+++ maven/components/trunk/maven-model-builder/pom.xml Mon Jun  1 17:49:34 2009
@@ -31,6 +31,10 @@
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-interpolation</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-component-annotations</artifactId>
     </dependency>
     <dependency>

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java?rev=780749&r1=780748&r2=780749&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java
(original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java
Mon Jun  1 17:49:34 2009
@@ -28,11 +28,13 @@
 import java.util.Map;
 
 import org.apache.maven.model.inheritance.InheritanceAssembler;
-import org.apache.maven.model.interpolator.Interpolator;
+import org.apache.maven.model.interpolation.ModelInterpolationException;
+import org.apache.maven.model.interpolation.ModelInterpolator;
 import org.apache.maven.model.io.ModelParseException;
 import org.apache.maven.model.io.ModelReader;
 import org.apache.maven.model.management.ManagementInjector;
 import org.apache.maven.model.normalization.ModelNormalizer;
+import org.apache.maven.model.path.ModelPathTranslator;
 import org.apache.maven.model.plugin.LifecycleBindingsInjector;
 import org.apache.maven.model.plugin.PluginConfigurationExpander;
 import org.apache.maven.model.profile.ProfileActivationException;
@@ -66,7 +68,10 @@
     private ModelNormalizer modelNormalizer;
 
     @Requirement
-    private Interpolator modelInterpolator;
+    private ModelInterpolator modelInterpolator;
+
+    @Requirement
+    private ModelPathTranslator modelPathTranslator;
 
     @Requirement
     private InheritanceAssembler inheritanceAssembler;
@@ -155,6 +160,8 @@
         resultModel = interpolateModel( resultModel, request );
         resultModels.set( 0, resultModel );
 
+        modelPathTranslator.alignToBaseDirectory( resultModel, resultModel.getProjectDirectory()
);
+
         if ( request.isProcessPlugins() )
         {
             lifecycleBindingsInjector.injectLifecycleBindings( resultModel );
@@ -281,14 +288,11 @@
     {
         try
         {
-            Model result =
-                modelInterpolator.interpolateModel( model,
-                                                    request.getProfileActivationContext().getExecutionProperties(),
-                                                    model.getProjectDirectory() );
+            Model result = modelInterpolator.interpolateModel( model, model.getProjectDirectory(),
request );
             result.setPomFile( model.getPomFile() );
             return result;
         }
-        catch ( IOException e )
+        catch ( ModelInterpolationException e )
         {
             throw new ModelBuildingException( "Failed to interpolate model " + toSourceHint(
model ), e );
         }

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=780749&r1=780665&r2=780749&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
Mon Jun  1 17:49:34 2009
@@ -1,4 +1,4 @@
-package org.apache.maven.project.interpolation;
+package org.apache.maven.model.interpolation;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,11 +20,9 @@
  */
 
 import org.apache.maven.model.Model;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
-import org.apache.maven.project.DefaultProjectBuilderConfiguration;
-import org.apache.maven.project.ProjectBuilderConfiguration;
-import org.apache.maven.project.path.PathTranslator;
+import org.apache.maven.model.ModelBuildingRequest;
+import org.apache.maven.model.path.PathTranslator;
+import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.interpolation.AbstractValueSource;
 import org.codehaus.plexus.interpolation.InterpolationException;
 import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
@@ -36,21 +34,12 @@
 import org.codehaus.plexus.interpolation.PrefixedValueSourceWrapper;
 import org.codehaus.plexus.interpolation.RecursionInterceptor;
 import org.codehaus.plexus.interpolation.ValueSource;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.logging.Logger;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 
 /**
@@ -61,8 +50,7 @@
  * @todo Consolidate this logic with the PluginParameterExpressionEvaluator, minus deprecations/bans.
  */
 public abstract class AbstractStringBasedModelInterpolator
-    extends AbstractLogEnabled
-    implements ModelInterpolator, Initializable
+    implements ModelInterpolator
 {
     private static final List<String> PROJECT_PREFIXES = Arrays.asList( new String[]{
"pom.", "project." } );
 
@@ -88,133 +76,20 @@
         TRANSLATED_PATH_EXPRESSIONS = translatedPrefixes;
     }
 
+    @Requirement
     private PathTranslator pathTranslator;
     
     private Interpolator interpolator;
     
     private RecursionInterceptor recursionInterceptor;
-
-    // for testing.
-    protected AbstractStringBasedModelInterpolator( PathTranslator pathTranslator )
-    {
-        this.pathTranslator = pathTranslator;
-    }
-
-    /**
-     * @todo: Remove the throws clause.
-     * @throws IOException This exception is not thrown any more, and needs to be removed.
-     */
-    protected AbstractStringBasedModelInterpolator()
-    {
-    }
-
-    public Model interpolate( Model model, Map<String, ?> context )
-        throws ModelInterpolationException
-    {
-        return interpolate( model, context, true );
-    }
-
-    /**
-     * Serialize the inbound Model instance to a StringWriter, perform the regex replacement
to resolve
-     * POM expressions, then re-parse into the resolved Model instance.
-     * <br/>
-     * <b>NOTE:</b> This will result in a different instance of Model being returned!!!
-     *
-     * @param model   The inbound Model instance, to serialize and reference for expression
resolution
-     * @param context The other context map to be used during resolution
-     * @return The resolved instance of the inbound Model. This is a different instance!
-     *
-     * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration,
boolean)} instead.
-     */
-    public Model interpolate( Model model, Map<String, ?> context, boolean strict )
-        throws ModelInterpolationException
-    {
-        Properties props = new Properties();
-        props.putAll( context );
-
-        return interpolate( model,
-                            null,
-                            new DefaultProjectBuilderConfiguration().setExecutionProperties(
props ),
-                            true );
-    }
-
-    public Model interpolate( Model model,
-                              File projectDir,
-                              ProjectBuilderConfiguration config,
-                              boolean debugEnabled )
-        throws ModelInterpolationException
+    
+    public AbstractStringBasedModelInterpolator()
     {
-        StringWriter sWriter = new StringWriter( 1024 );
-
-        MavenXpp3Writer writer = new MavenXpp3Writer();
-        try
-        {
-            writer.write( sWriter, model );
-        }
-        catch ( IOException e )
-        {
-            throw new ModelInterpolationException( "Cannot serialize project model for interpolation.",
e );
-        }
-
-        String serializedModel = sWriter.toString();
-        serializedModel = interpolate( serializedModel, model, projectDir, config, debugEnabled
);
-
-        StringReader sReader = new StringReader( serializedModel );
-
-        MavenXpp3Reader modelReader = new MavenXpp3Reader();
-        try
-        {
-            model = modelReader.read( sReader );
-        }
-        catch ( IOException e )
-        {
-            throw new ModelInterpolationException(
-                "Cannot read project model from interpolating filter of serialized version.",
e );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new ModelInterpolationException(
-                "Cannot read project model from interpolating filter of serialized version.",
e );
-        }
-
-        return model;
+        interpolator = createInterpolator();
+        recursionInterceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES );
     }
 
-    /**
-     * Interpolates all expressions in the src parameter.
-     * <p>
-     * The algorithm used for each expression is:
-     * <ul>
-     *   <li>If it starts with either "pom." or "project.", the expression is evaluated
against the model.</li>
-     *   <li>If the value is null, get the value from the context.</li>
-     *   <li>If the value is null, but the context contains the expression, don't replace
the expression string
-     *       with the value, and continue to find other expressions.</li>
-     *   <li>If the value is null, get it from the model properties.</li>
-     *   <li>
-     * @param overrideContext
-     * @param outputDebugMessages
-     */
-    public String interpolate( String src,
-                               Model model,
-                               final File projectDir,
-                               ProjectBuilderConfiguration config,
-                               boolean debug )
-        throws ModelInterpolationException
-    {
-        try
-        {
-            List<ValueSource> valueSources = createValueSources( model, projectDir,
config );
-            List<InterpolationPostProcessor> postProcessors = createPostProcessors(
model, projectDir, config );
-            
-            return interpolateInternal( src, valueSources, postProcessors, debug );
-        }
-        finally
-        {
-            interpolator.clearAnswers();
-        }
-    }
-    
-    protected List<ValueSource> createValueSources( final Model model, final File projectDir,
final ProjectBuilderConfiguration config )
+    protected List<ValueSource> createValueSources( final Model model, final File projectDir,
final ModelBuildingRequest config )
     {
         String timestampFormat = DEFAULT_BUILD_TIMESTAMP_FORMAT;
 
@@ -255,9 +130,8 @@
         // NOTE: Order counts here!
         valueSources.add( basedirValueSource );
         valueSources.add( baseUriValueSource );
-        valueSources.add( new BuildTimestampValueSource( config.getBuildStartTime(), timestampFormat
) );
+        // TODO: valueSources.add( new BuildTimestampValueSource( config.getBuildStartTime(),
timestampFormat ) );
         valueSources.add( modelValueSource1 );
-        valueSources.add( new MapBasedValueSource( config.getUserProperties() ) );
         valueSources.add( new MapBasedValueSource( modelProperties ) );
         valueSources.add( new MapBasedValueSource( config.getExecutionProperties() ) );
         valueSources.add( new AbstractValueSource( false )
@@ -273,7 +147,7 @@
     }
     
     protected List<InterpolationPostProcessor> createPostProcessors( final Model model,
final File projectDir,
-                                                                     final ProjectBuilderConfiguration
config )
+                                                                     final ModelBuildingRequest
config )
     {
         return Collections.singletonList( (InterpolationPostProcessor) new PathTranslatingPostProcessor(
                                                                                         
                PROJECT_PREFIXES,
@@ -282,17 +156,14 @@
                                                                                         
                pathTranslator ) );
     }
     
-    @SuppressWarnings("unchecked")
     protected String interpolateInternal( String src, List<ValueSource> valueSources,
-                                          List<InterpolationPostProcessor> postProcessors,
boolean debug )
+                                          List<InterpolationPostProcessor> postProcessors
)
         throws ModelInterpolationException
     {
         if ( src.indexOf( "${" ) < 0 )
         {
             return src;
         }
-        
-        Logger logger = getLogger();
 
         String result = src;
         synchronized( this )
@@ -319,45 +190,6 @@
                     throw new ModelInterpolationException( e.getMessage(), e );
                 }
 
-                if ( debug )
-                {
-                    List<Object> feedback = (List<Object>) interpolator.getFeedback();
-                    if ( feedback != null && !feedback.isEmpty() )
-                    {
-                        logger.debug( "Maven encountered the following problems during initial
POM interpolation:" );
-
-                        Object last = null;
-                        for ( Object next : feedback )
-                        {
-                            if ( next instanceof Throwable )
-                            {
-                                if ( last == null )
-                                {
-                                    logger.debug( "", ( (Throwable) next ) );
-                                }
-                                else
-                                {
-                                    logger.debug( String.valueOf( last ), ( (Throwable) next
) );
-                                }
-                            }
-                            else
-                            {
-                                if ( last != null )
-                                {
-                                    logger.debug( String.valueOf( last ) );
-                                }
-
-                                last = next;
-                            }
-                        }
-
-                        if ( last != null )
-                        {
-                            logger.debug( String.valueOf( last ) );
-                        }
-                    }
-                }
-
                 interpolator.clearFeedback();
             }
             finally
@@ -388,13 +220,6 @@
     }
 
     protected abstract Interpolator createInterpolator();
-
-    public void initialize()
-        throws InitializationException
-    {
-        interpolator = createInterpolator();
-        recursionInterceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES );
-    }
     
     protected final Interpolator getInterpolator()
     {

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/BuildTimestampValueSource.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/BuildTimestampValueSource.java?rev=780749&r1=780665&r2=780749&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/BuildTimestampValueSource.java
(original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/BuildTimestampValueSource.java
Mon Jun  1 17:49:34 2009
@@ -1,4 +1,4 @@
-package org.apache.maven.project.interpolation;
+package org.apache.maven.model.interpolation;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolationException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolationException.java?rev=780749&r1=780665&r2=780749&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolationException.java
(original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolationException.java
Mon Jun  1 17:49:34 2009
@@ -1,4 +1,4 @@
-package org.apache.maven.project.interpolation;
+package org.apache.maven.model.interpolation;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -28,9 +28,6 @@
 public class ModelInterpolationException
     extends Exception
 {
-    private String expression;
-
-    private String originalMessage;
 
     public ModelInterpolationException( String message )
     {
@@ -42,30 +39,4 @@
         super( message, cause );
     }
 
-    public ModelInterpolationException( String expression, String message, Throwable cause
)
-    {
-        super( "The POM expression: " + expression + " could not be evaluated. Reason: "
+ message, cause );
-
-        this.expression = expression;
-        this.originalMessage = message;
-    }
-
-    public ModelInterpolationException( String expression, String message )
-    {
-        super( "The POM expression: " + expression + " could not be evaluated. Reason: "
+ message );
-
-        this.expression = expression;
-        this.originalMessage = message;
-    }
-
-    public String getExpression()
-    {
-        return expression;
-    }
-
-    public String getOriginalMessage()
-    {
-        return originalMessage;
-    }
-
 }
\ No newline at end of file

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolator.java?rev=780749&r1=780665&r2=780749&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolator.java
(original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelInterpolator.java
Mon Jun  1 17:49:34 2009
@@ -1,4 +1,4 @@
-package org.apache.maven.project.interpolation;
+package org.apache.maven.model.interpolation;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,10 +20,9 @@
  */
 
 import org.apache.maven.model.Model;
-import org.apache.maven.project.ProjectBuilderConfiguration;
+import org.apache.maven.model.ModelBuildingRequest;
 
 import java.io.File;
-import java.util.Map;
 
 /**
  * @author jdcasey
@@ -32,34 +31,12 @@
  */
 public interface ModelInterpolator
 {
+
     String DEFAULT_BUILD_TIMESTAMP_FORMAT = "yyyyMMdd-HHmm";
 
     String BUILD_TIMESTAMP_FORMAT_PROPERTY = "maven.build.timestamp.format";
 
-    String ROLE = ModelInterpolator.class.getName();
-
-    /**
-     * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration,
boolean)} instead.
-     */
-    Model interpolate( Model project, Map<String, ?> context )
-        throws ModelInterpolationException;
-
-    /**
-     * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration,
boolean)} instead.
-     */
-    Model interpolate( Model model, Map<String, ?> context, boolean strict )
+    Model interpolateModel( Model model, File projectDir, ModelBuildingRequest request )
         throws ModelInterpolationException;
 
-    Model interpolate( Model model,
-                       File projectDir,
-                       ProjectBuilderConfiguration config,
-                       boolean debugEnabled )
-        throws ModelInterpolationException;
-
-    String interpolate( String src,
-                        Model model,
-                        File projectDir,
-                        ProjectBuilderConfiguration config,
-                        boolean debugEnabled )
-        throws ModelInterpolationException;
-}
\ No newline at end of file
+}

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=780749&r1=780665&r2=780749&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
Mon Jun  1 17:49:34 2009
@@ -1,4 +1,4 @@
-package org.apache.maven.project.interpolation;
+package org.apache.maven.model.interpolation;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,7 +19,7 @@
  * under the License.
  */
 
-import org.apache.maven.project.path.PathTranslator;
+import org.apache.maven.model.path.PathTranslator;
 import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
 import org.codehaus.plexus.interpolation.util.ValueSourceUtils;
 
@@ -47,8 +47,7 @@
         this.pathTranslator = pathTranslator;
     }
 
-    public Object execute( String expression,
-                                      Object value )
+    public Object execute( String expression, Object value )
     {
         expression = ValueSourceUtils.trimPrefix( expression, expressionPrefixes, true );
         

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java?rev=780749&r1=780665&r2=780749&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java
(original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java
Mon Jun  1 17:49:34 2009
@@ -1,13 +1,31 @@
-package org.apache.maven.project.interpolation;
+package org.apache.maven.model.interpolation;
+
+/*
+ * 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.
+ */
 
 import org.apache.maven.model.Model;
-import org.apache.maven.project.ProjectBuilderConfiguration;
-import org.apache.maven.project.path.PathTranslator;
+import org.apache.maven.model.ModelBuildingRequest;
+import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
 import org.codehaus.plexus.interpolation.Interpolator;
 import org.codehaus.plexus.interpolation.StringSearchInterpolator;
 import org.codehaus.plexus.interpolation.ValueSource;
-import org.codehaus.plexus.logging.Logger;
 
 import java.io.File;
 import java.lang.reflect.Array;
@@ -21,6 +39,7 @@
 import java.util.Map;
 import java.util.WeakHashMap;
 
+@Component( role = ModelInterpolator.class )
 public class StringSearchModelInterpolator
     extends AbstractStringBasedModelInterpolator
 {
@@ -28,25 +47,15 @@
     private static final Map<Class<?>, Field[]> fieldsByClass = new WeakHashMap<Class<?>,
Field[]>();
     private static final Map<Class<?>, Boolean> fieldIsPrimitiveByClass = new
WeakHashMap<Class<?>, Boolean>();
 
-    public StringSearchModelInterpolator()
-    {
-    }
-
-    public StringSearchModelInterpolator( PathTranslator pathTranslator )
-    {
-        super( pathTranslator );
-    }
-
-    public Model interpolate( Model model, File projectDir, ProjectBuilderConfiguration config,
boolean debugEnabled )
+    public Model interpolateModel( Model model, File projectDir, ModelBuildingRequest config
)
         throws ModelInterpolationException
     {
-        interpolateObject( model, model, projectDir, config, debugEnabled );
+        interpolateObject( model, model, projectDir, config );
         
         return model;
     }
     
-    protected void interpolateObject( Object obj, Model model, File projectDir, ProjectBuilderConfiguration
config,
-                                      boolean debugEnabled )
+    protected void interpolateObject( Object obj, Model model, File projectDir, ModelBuildingRequest
config )
         throws ModelInterpolationException
     {
         try
@@ -55,11 +64,9 @@
             List<InterpolationPostProcessor> postProcessors = createPostProcessors(
model, projectDir, config );
             
             InterpolateObjectAction action =
-                new InterpolateObjectAction( obj, valueSources, postProcessors, debugEnabled,
-                                             this, getLogger() );
+                new InterpolateObjectAction( obj, valueSources, postProcessors, this );
             
-            ModelInterpolationException error =
-                (ModelInterpolationException) AccessController.doPrivileged( action );
+            ModelInterpolationException error = AccessController.doPrivileged( action );
             
             if ( error != null )
             {
@@ -83,26 +90,22 @@
     private static final class InterpolateObjectAction implements PrivilegedAction<ModelInterpolationException>
     {
 
-        private final boolean debugEnabled;
         private final LinkedList<Object> interpolationTargets;
         private final StringSearchModelInterpolator modelInterpolator;
-        private final Logger logger;
         private final List<ValueSource> valueSources;
         private final List<InterpolationPostProcessor> postProcessors;
         
         public InterpolateObjectAction( Object target, List<ValueSource> valueSources,
-                                        List<InterpolationPostProcessor> postProcessors,
boolean debugEnabled,
-                                        StringSearchModelInterpolator modelInterpolator,
Logger logger )
+                                        List<InterpolationPostProcessor> postProcessors,
+                                        StringSearchModelInterpolator modelInterpolator )
         {
             this.valueSources = valueSources;
             this.postProcessors = postProcessors;
-            this.debugEnabled = debugEnabled;
             
             this.interpolationTargets = new LinkedList<Object>();
             interpolationTargets.add( target );
             
             this.modelInterpolator = modelInterpolator;
-            this.logger = logger;
         }
 
         public ModelInterpolationException run()
@@ -140,7 +143,7 @@
             }
             else if ( isQualifiedForInterpolation( cls ) )
             {
-                Field[] fields = (Field[]) fieldsByClass.get( cls );
+                Field[] fields = fieldsByClass.get( cls );
                 if ( fields == null )
                 {
                     fields = cls.getDeclaredFields();
@@ -163,7 +166,7 @@
                                     String value = (String) fields[i].get( target );
                                     if ( value != null )
                                     {
-                                        String interpolated = modelInterpolator.interpolateInternal(
value, valueSources, postProcessors, debugEnabled );
+                                        String interpolated = modelInterpolator.interpolateInternal(
value, valueSources, postProcessors );
                                         
                                         if ( !interpolated.equals( value ) )
                                         {
@@ -183,10 +186,6 @@
                                         }
                                         catch( UnsupportedOperationException e )
                                         {
-                                            if ( debugEnabled && logger != null )
-                                            {
-                                                logger.debug( "Skipping interpolation of
field: " + fields[i] + " in: " + cls.getName() + "; it is an unmodifiable collection." );
-                                            }
                                             continue;
                                         }
                                         
@@ -196,7 +195,7 @@
                                             {
                                                 if( String.class == value.getClass() )
                                                 {
-                                                    String interpolated = modelInterpolator.interpolateInternal(
(String) value, valueSources, postProcessors, debugEnabled );
+                                                    String interpolated = modelInterpolator.interpolateInternal(
(String) value, valueSources, postProcessors );
                                                     
                                                     if ( !interpolated.equals( value ) )
                                                     {
@@ -241,7 +240,7 @@
                                             {
                                                 if( String.class == value.getClass() )
                                                 {
-                                                    String interpolated = modelInterpolator.interpolateInternal(
(String) value, valueSources, postProcessors, debugEnabled );
+                                                    String interpolated = modelInterpolator.interpolateInternal(
(String) value, valueSources, postProcessors );
                                                     
                                                     if ( !interpolated.equals( value ) )
                                                     {
@@ -251,10 +250,6 @@
                                                         }
                                                         catch( UnsupportedOperationException
e )
                                                         {
-                                                            if ( debugEnabled &&
logger != null )
-                                                            {
-                                                                logger.debug( "Skipping interpolation
of field: " + fields[i] + " (key: " + entry.getKey() + ") in: " + cls.getName() + "; it is
an unmodifiable collection." );
-                                                            }
                                                             continue;
                                                         }
                                                     }
@@ -322,7 +317,7 @@
                 fieldIsPrimitiveByClass.put( fieldType, Boolean.valueOf( fieldType.isPrimitive()
) );
             }
             
-            if ( ((Boolean) fieldIsPrimitiveByClass.get( fieldType )).booleanValue() )
+            if ( fieldIsPrimitiveByClass.get( fieldType ).booleanValue() )
             {
                 return false;
             }
@@ -351,7 +346,7 @@
                 {
                     if ( String.class == value.getClass() )
                     {
-                        String interpolated = modelInterpolator.interpolateInternal( (String)
value, valueSources, postProcessors, debugEnabled );
+                        String interpolated = modelInterpolator.interpolateInternal( (String)
value, valueSources, postProcessors );
                         
                         if ( !interpolated.equals( value ) )
                         {

Modified: maven/components/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/pom.xml?rev=780749&r1=780748&r2=780749&view=diff
==============================================================================
--- maven/components/trunk/pom.xml (original)
+++ maven/components/trunk/pom.xml Mon Jun  1 17:49:34 2009
@@ -52,7 +52,7 @@
     <easyMockVersion>1.2_Java1.3</easyMockVersion>
     <junitVersion>3.8.1</junitVersion>
     <plexusVersion>1.0-beta-3.0.8-SNAPSHOT</plexusVersion>
-    <plexusInterpolationVersion>1.1</plexusInterpolationVersion>
+    <plexusInterpolationVersion>1.8.1</plexusInterpolationVersion>
     <plexusPluginManagerVersion>1.0-alpha-1</plexusPluginManagerVersion>
     <plexusUtilsVersion>1.5.8</plexusUtilsVersion>
     <plexusJetty6Version>1.6</plexusJetty6Version>



Mime
View raw message