This commit introduces the 'include' scope - aka fixes the import scope without breaking backwards compatibility. As I am getting tired of discussing the same issue over and over again, in case there are objections, just set the 'DEPENDENCY_MANAGEMENT_IMPORT_INHERITANCE_PROCESSING' constant in class 'DefaultModelBuilder' to 'false'. There is no way to support the requested use-cases in a backwards compatible way without introducing something only Maven 3.4+ can handle. We cannot bump the model version, because older Maven versions will not support such POMs. We cannot change the import scope behaviour without breaking backwards compatibility. Introducing a POM property to control model building behaviour is not different to introducing a new scope. Older maven versions will just use the 'runtime' scope when encountering some unknown scope. Since the 'include' scope is POM only, older Maven versions shouldn't run into any issue. Still, they will build a different effective model. I am done with this. Just someone set that constant to 'false' and stop supporting those use-cases, if this won't pass a release vote.
Am 12/10/16 um 19:58 schrieb [email protected]: > [MNG-5971] Imported dependencies should be available to inheritance processing > > o Updated to remove the system property controlling the feature. > This introduces the 'include' scope feature and leaves the > 'import' scope feature in a backwards compatible way. If this > does not pass a release vote, the feature can be disabled by > simply settings the constant to 'false'. If no-one objects, > the 'include' scope feature will be supported as of Maven 3.4.0. > > > Project: http://git-wip-us.apache.org/repos/asf/maven/repo > Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/5785d6f1 > Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/5785d6f1 > Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/5785d6f1 > > Branch: refs/heads/master > Commit: 5785d6f1dc7c494445eedc49a537c5537ede8865 > Parents: ef4e4b4 > Author: Christian Schulte <[email protected]> > Authored: Sat Dec 10 19:55:22 2016 +0100 > Committer: Christian Schulte <[email protected]> > Committed: Sat Dec 10 19:55:22 2016 +0100 > > ---------------------------------------------------------------------- > .../model/building/DefaultModelBuilder.java | 20 +++++++++++--------- > .../DefaultDependencyManagementImporter.java | 13 +++++++------ > 2 files changed, 18 insertions(+), 15 deletions(-) > ---------------------------------------------------------------------- > > > http://git-wip-us.apache.org/repos/asf/maven/blob/5785d6f1/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 27d24f3..74f435b 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 > @@ -164,10 +164,12 @@ public class DefaultModelBuilder > */ > private static final boolean DEPENDENCY_MANAGEMENT_IMPORT_RELOCATIONS = > true; > > - // [MNG-5971] Imported dependencies should be available to inheritance > processing. > - private static final boolean > DEPENDENCY_MANAGEMENT_IMPORT_INHERITANCE_PROCESSING = > - System.getProperty( DefaultModelBuilder.class.getName() > - + > ".disableDependencyManagementImportInheritanceProcessing" ) == null; > + /** > + * [MNG-5971] Imported dependencies should be available to inheritance > processing. > + * > + * @since 3.4.0 > + */ > + private static final boolean > DEPENDENCY_MANAGEMENT_IMPORT_INHERITANCE_PROCESSING = true; > > public DefaultModelBuilder setModelProcessor( ModelProcessor > modelProcessor ) > { > @@ -496,7 +498,7 @@ public class DefaultModelBuilder > if ( DEPENDENCY_MANAGEMENT_IMPORT_INHERITANCE_PROCESSING ) > { > // [MNG-5971] Imported dependencies should be available to > inheritance processing. > - this.processImports( lineage, request, problems ); > + this.processImports( lineage, "include", "pom", request, > problems ); > } > > problems.setSource( resultModel ); > @@ -839,8 +841,8 @@ public class DefaultModelBuilder > } > } > > - private void processImports( final List<Model> lineage, final > ModelBuildingRequest request, > - final DefaultModelProblemCollector problems > ) > + private void processImports( final List<Model> lineage, final String > scope, final String packaging, > + final ModelBuildingRequest request, final > DefaultModelProblemCollector problems ) > { > // [MNG-5971] Imported dependencies should be available to > inheritance processing > // It's not possible to support all ${project.xyz} properties in > dependency management import declarations > @@ -915,7 +917,7 @@ public class DefaultModelBuilder > { > final Dependency dependency = > model.getDependencyManagement().getDependencies().get( j ); > > - if ( "import".equals( dependency.getScope() ) && > "pom".equals( dependency.getType() ) ) > + if ( scope.equals( dependency.getScope() ) && > packaging.equals( dependency.getType() ) ) > { > final Dependency interpolated = > intermediateLineage.get( i > ).getDependencyManagement().getDependencies().get( j ); > @@ -947,7 +949,7 @@ public class DefaultModelBuilder > { > final Model model = lineage.get( i ); > this.configureResolver( lenientRequest.getModelResolver(), > intermediateLineage.get( i ), problems, true ); > - this.importDependencyManagement( model, "import", > lenientRequest, problems, new HashSet<String>() ); > + this.importDependencyManagement( model, scope, lenientRequest, > problems, new HashSet<String>() ); > } > } > > > http://git-wip-us.apache.org/repos/asf/maven/blob/5785d6f1/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java > ---------------------------------------------------------------------- > diff --git > a/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java > > b/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java > index ad5513d..967c81d 100644 > --- > a/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java > +++ > b/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java > @@ -121,12 +121,13 @@ public class DefaultDependencyManagementImporter > ModelProblem.Version.V20 ). > setMessage( String.format( > "Dependency '%1$s' has conflicting dependency > management in model '%2$s'%3$s%4$s. " > - + "To resolve the conflicts, either declare > the dependency management for dependency " > - + "'%1$s' directly in the dependency > management of model '%2$s' to override what gets " > - + "imported or - as of model version 4.1.0 - > rearrange the causing imports in the " > - + "inheritance hierarchy to apply standard > override logic based on artifact " > - + "coordinates. Without resolving the > conflicts, your build relies on indeterministic " > - + "behaviour.", > + + "To resolve the conflicts, declare the > dependency management for dependency '%1$s' " > + + "directly in the dependency management of > model '%2$s' to override what gets " > + + "imported, add exclusions for the > conflicting dependencies or, if the Maven version " > + + "in use supports the include scope > feature, use that feature to rearrange the " > + + "causing dependencies in the inheritance > hierarchy to apply standard override logic " > + + "based on artifact coordinates. Without > resolving the conflicts, your build relies " > + + "on indeterministic behaviour.", > conflictingDependencies.get( 0 > ).getManagementKey(), target.getId(), > target.getPomFile() != null > ? " @ '" + > target.getPomFile().getAbsolutePath() + "' " > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
