[MNG-4463] Dependency management import should support version ranges. Closes #64 without merging. ITs are pending to be committed.
Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/d0911ac5 Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/d0911ac5 Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/d0911ac5 Branch: refs/heads/DEPMGMT-IMPORT Commit: d0911ac57dccb758435cdfd3495121ec9f0ae1b4 Parents: 34afec6 Author: Christian Schulte <schu...@apache.org> Authored: Sat Jan 30 19:17:34 2016 +0100 Committer: Christian Schulte <schu...@apache.org> Committed: Wed Mar 8 19:40:30 2017 +0100 ---------------------------------------------------------------------- .../model/building/DefaultModelBuilder.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven/blob/d0911ac5/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 4ebb033..3699bd9 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 @@ -1213,7 +1213,25 @@ public class DefaultModelBuilder final ModelSource importSource; try { - importSource = modelResolver.resolveModel( groupId, artifactId, version ); + dependency = dependency.clone(); + importSource = modelResolver.resolveModel( dependency ); + final String resolvedId = + dependency.getGroupId() + ':' + dependency.getArtifactId() + ':' + dependency.getVersion(); + + if ( !imported.equals( resolvedId ) && importIds.contains( resolvedId ) ) + { + // A version range has been resolved to a cycle. + String message = "The dependencies of type=pom and with scope=import form a cycle: "; + for ( String modelId : importIds ) + { + message += modelId + " -> "; + } + message += resolvedId; + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ). + setMessage( message ) ); + + continue; + } } catch ( UnresolvableModelException e ) {