[MNG-4837] Interpolation error due to cyclic expression for one of the POM coordinates gets needlessly repeated

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1000601 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-09-23 20:05:09 +00:00
parent 0707794c27
commit 3fca2bb2d6
2 changed files with 30 additions and 0 deletions

View File

@ -324,6 +324,11 @@ public class StringSearchModelInterpolator
private boolean isQualifiedForInterpolation( Field field, Class<?> fieldType ) private boolean isQualifiedForInterpolation( Field field, Class<?> fieldType )
{ {
if ( Map.class.equals( fieldType ) && "locations".equals( field.getName() ) )
{
return false;
}
Boolean primitive = fieldIsPrimitiveByClass.get( fieldType ); Boolean primitive = fieldIsPrimitiveByClass.get( fieldType );
if ( primitive == null ) if ( primitive == null )
{ {

View File

@ -19,6 +19,8 @@ package org.apache.maven.model.interpolation;
* under the License. * under the License.
*/ */
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.InputSource;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.model.building.DefaultModelBuildingRequest; import org.apache.maven.model.building.DefaultModelBuildingRequest;
import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.ModelBuildingRequest;
@ -482,4 +484,27 @@ public class StringSearchModelInterpolatorTest
{ {
public static final String CONSTANT = "${expression}"; public static final String CONSTANT = "${expression}";
} }
public void testLocationTrackerShouldBeExcludedFromInterpolation()
{
Properties props = new Properties();
props.setProperty( "expression", "value" );
DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
request.setUserProperties( props );
InputSource source = new InputSource();
source.setLocation( "${expression}" );
source.setModelId( "${expression}" );
Model model = new Model();
model.setLocation( "", new InputLocation( 1, 1, source ) );
SimpleProblemCollector problems = new SimpleProblemCollector();
StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator();
interpolator.interpolateObject( model, model, null, request, problems );
assertProblemFree( problems );
assertEquals( "${expression}", source.getLocation() );
assertEquals( "${expression}", source.getModelId() );
}
} }