You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/10/10 11:54:15 UTC

[maven] 01/01: [MNG-6846] conditional overwrite version

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MNG-6846
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 131a75d96d7cde3629471a10f7c44b0a6e55f91a
Author: zhaoyunxing92 <23...@qq.com>
AuthorDate: Fri Jan 10 20:54:21 2020 +0800

    [MNG-6846] conditional overwrite version
    
    
    Closes #314
---
 .../model/interpolation/AbstractStringBasedModelInterpolator.java  | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
index 588b913..35efeb8 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
@@ -151,15 +151,16 @@ public abstract class AbstractStringBasedModelInterpolator
 
         // Overwrite existing values in model properties. Otherwise it's not possible
         // to define the version via command line: mvn -Drevision=6.5.7 ...
-        if ( config.getSystemProperties().containsKey( REVISION_PROPERTY ) )
+        // I think this overwrite is conditional and only overwrite current projects
+        if ( config.getSystemProperties().containsKey( REVISION_PROPERTY ) && projectDir != null )
         {
             modelProperties.put( REVISION_PROPERTY, config.getSystemProperties().get( REVISION_PROPERTY ) );
         }
-        if ( config.getSystemProperties().containsKey( CHANGELIST_PROPERTY ) )
+        if ( config.getSystemProperties().containsKey( CHANGELIST_PROPERTY ) && projectDir != null )
         {
             modelProperties.put( CHANGELIST_PROPERTY, config.getSystemProperties().get( CHANGELIST_PROPERTY ) );
         }
-        if ( config.getSystemProperties().containsKey( SHA1_PROPERTY ) )
+        if ( config.getSystemProperties().containsKey( SHA1_PROPERTY ) && projectDir != null )
         {
             modelProperties.put( SHA1_PROPERTY, config.getSystemProperties().get( SHA1_PROPERTY ) );
         }