Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.8.4
-
None
Description
A sample case for this bug is DefaultArtifactDescriptorReader:
When Resolver needs to resolve a transitive dependency it consults Maven Resolver Provider to create data. Here the properties of the repository system session are not properly passed with their respective scopes down to the model building request. When a POM now needs to be interpolated, the interpolation can fail.
For long time Maven, unfortunately, promoted user properties to system properties making the available everywhere (expect this to be cleaned up in Maven 4). A prime example where this is broken: DefaultModelVersionProcessor uses for some strange reason system properties although CI Friendly Versions are user properties only. Fixing this component with:
--- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/DefaultModelVersionProcessor.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/DefaultModelVersionProcessor.java @@ -52,17 +52,17 @@ public boolean isValidProperty( String property ) @Override public void overwriteModelProperties( Properties modelProperties, ModelBuildingRequest request ) { - if ( request.getSystemProperties().containsKey( REVISION_PROPERTY ) ) + if ( request.getUserProperties().containsKey( REVISION_PROPERTY ) ) { - modelProperties.put( REVISION_PROPERTY, request.getSystemProperties().get( REVISION_PROPERTY ) ); + modelProperties.put( REVISION_PROPERTY, request.getUserProperties().get( REVISION_PROPERTY ) ); } - if ( request.getSystemProperties().containsKey( CHANGELIST_PROPERTY ) ) + if ( request.getUserProperties().containsKey( CHANGELIST_PROPERTY ) ) { - modelProperties.put( CHANGELIST_PROPERTY, request.getSystemProperties().get( CHANGELIST_PROPERTY ) ); + modelProperties.put( CHANGELIST_PROPERTY, request.getUserProperties().get( CHANGELIST_PROPERTY ) ); } - if ( request.getSystemProperties().containsKey( SHA1_PROPERTY ) ) + if ( request.getUserProperties().containsKey( SHA1_PROPERTY ) ) { - modelProperties.put( SHA1_PROPERTY, request.getSystemProperties().get( SHA1_PROPERTY ) ); + modelProperties.put( SHA1_PROPERTY, request.getUserProperties().get( SHA1_PROPERTY ) ); } }
and running ITs makes several of them fail:
... mng6090 CIFriendly.itShouldResolveTheDependenciesWithBuildConsumer() FAILURE (10.4 s) mng6090 CIFriendly.itShouldResolveTheDependenciesWithoutBuildConsumer() FAILURE (1.2 s) ... mng5895 CIFriendlyUsageWithProperty.itShouldResolveTheDependenciesWithBuildConsumer() FAILURE (0.5 s) mng5895 CIFriendlyUsageWithProperty.itShouldResolveTheDependenciesWithoutBuildConsumer() FAILURE (0.5 s) ...
The reason is simple:
modelRequest.setSystemProperties( toProperties( session.getUserProperties(), session.getSystemProperties() ) );
Properties from user are not available. The are likely other usecases affected by this bug.
Yet another problem is that plugins which resolve dependencies, e.g., MASSEMBLY will also fail even if this bug is fixed since they rely on an old version of the Maven Resolver Provider and don't use provided scope to use the fixed one from Maven Core. This is a separate problem to be solved.
Attachments
Attachments
Issue Links
- causes
-
MNG-7563 REGRESSION: User properties now override model properties in dependencies
- Closed
- fixes
-
MNG-5982 The POM for ... is invalid, transitive dependencies ... while property was overriden
- Closed
- is related to
-
MNG-7407 Introduce a ModelVersionProcessor component to make CI Friendly Versions pluggable
- Closed
- is superceded by
-
MNG-7634 Revert MNG-5982 and MNG-7417
- Closed
- relates to
-
MNG-6564 Lack of ability to overwrite properties of specified dependencies
- Open
- links to