From cac8f6eedff570c312409d31fa44338c326346f8 Mon Sep 17 00:00:00 2001 From: Britton Isbell Date: Wed, 12 Nov 2008 05:17:42 +0000 Subject: [PATCH] Fix for IT 3833. New implementation does multiple interpolation iterations, until it detects that there is no longer a change in the list. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@713266 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/shared/model/ModelProperty.java | 7 ++++-- .../shared/model/ModelTransformerContext.java | 24 +++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelProperty.java b/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelProperty.java index 3e9a7026c7..641fee22db 100644 --- a/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelProperty.java +++ b/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelProperty.java @@ -210,7 +210,7 @@ public final class ModelProperty * * @param property the interpolator property used to resolve */ - public void resolveWith( InterpolatorProperty property ) + public boolean resolveWith( InterpolatorProperty property ) { if ( property == null ) { @@ -218,12 +218,14 @@ public final class ModelProperty } if ( isResolved() ) { - return; + return false; } + boolean resolved = false; for ( String expression : unresolvedExpressions ) { if ( property.getKey().equals( expression ) ) { + resolved = true; resolvedValue = resolvedValue.replace( property.getKey(), property.getValue() ); unresolvedExpressions.clear(); Matcher matcher = EXPRESSION_PATTERN.matcher( resolvedValue ); @@ -234,6 +236,7 @@ public final class ModelProperty break; } } + return resolved; } public String toString() diff --git a/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java b/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java index f914b177f2..ef4abb7614 100644 --- a/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java +++ b/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelTransformerContext.java @@ -147,24 +147,24 @@ public final class ModelTransformerContext LinkedHashSet ips = new LinkedHashSet(); ips.addAll(interpolatorProperties); - - for ( InterpolatorProperty ip : ips) + boolean continueInterpolation = true; + while(continueInterpolation) { - for ( ModelProperty mp : unresolvedProperties ) + continueInterpolation = false; + for ( InterpolatorProperty ip : ips) { - mp.resolveWith(ip); - } - } - - for ( InterpolatorProperty ip : ips ) - { - for ( ModelProperty mp : unresolvedProperties ) - { - mp.resolveWith(ip); + for ( ModelProperty mp : unresolvedProperties ) + { + if(mp.resolveWith(ip) && !continueInterpolation ) + { + continueInterpolation = true; + } + } } } } + /** * Transforms the specified model properties using the specified transformers. *