Repository: maven Updated Branches: refs/heads/master ec14b8ad4 -> bd8725862
[MNG-5840] The fix for parent version validation caused a regression in the parent version range - With this change we basically unwind MNG-5840 for the rumoured validation in the workspace resolver when dealing with a parent version range. Not ideal but only way for now to retain the version range feature Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/bd872586 Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/bd872586 Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/bd872586 Branch: refs/heads/master Commit: bd87258629db8e3fcc7aa04777afc16314c3cde0 Parents: ec14b8a Author: Stephen Connolly <stephen.alan.conno...@gmail.com> Authored: Wed Jul 22 09:52:01 2015 +0100 Committer: Stephen Connolly <stephen.alan.conno...@gmail.com> Committed: Wed Jul 22 13:02:51 2015 +0100 ---------------------------------------------------------------------- maven-model-builder/pom.xml | 4 ++ .../model/building/DefaultModelBuilder.java | 50 +++++++++++--------- 2 files changed, 32 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven/blob/bd872586/maven-model-builder/pom.xml ---------------------------------------------------------------------- diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index 0af97b8..1071557 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -49,6 +49,10 @@ </dependency> <dependency> <groupId>org.apache.maven</groupId> + <artifactId>maven-artifact</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> <artifactId>maven-builder-support</artifactId> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/maven/blob/bd872586/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java index 673a50f..ab00fef 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java @@ -20,20 +20,9 @@ package org.apache.maven.model.building; */ -import static org.apache.maven.model.building.Result.error; -import static org.apache.maven.model.building.Result.newResult; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; - +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; +import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Activation; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; @@ -73,6 +62,20 @@ import org.apache.maven.model.validation.ModelValidator; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import static org.apache.maven.model.building.Result.error; +import static org.apache.maven.model.building.Result.newResult; + /** * @author Benjamin Bentmann */ @@ -921,15 +924,18 @@ public class DefaultModelBuilder } if ( version != null && parent.getVersion() != null && !version.equals( parent.getVersion() ) ) { - // - // If the parent version is a range we will let it through here as we do not have the classes - // for determining if the parent is within the range in scope. This may lead to MNG-5840 style - // regressions in the range, but without this the parent version range will not work at all. - // - - if ( !parent.getVersion().startsWith( "[" ) && !parent.getVersion().startsWith( "(" ) ) + try + { + VersionRange parentRange = VersionRange.createFromVersionSpec( parent.getVersion() ); + if ( !parentRange.containsVersion( new DefaultArtifactVersion( version ) ) ) + { + // version skew drop back to resolution from the repository + return null; + } + } + catch ( InvalidVersionSpecificationException e ) { - // version skew drop back to resolution from the repository + // invalid version range, so drop back to resolution from the repository return null; } }