maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khmarba...@apache.org
Subject maven git commit: [MNG-6090] CI friendly properties break submodule builds [MNG-6057] Problem with CI friendly usage of ${..} reactor order is changed o Based on the missing replacement of the versions ${revision} ${changelist} or ${sha1} within the [Forced Update!]
Date Sun, 12 Mar 2017 22:30:34 GMT
Repository: maven
Updated Branches:
  refs/heads/MNG-6057 3c00dd10e -> 41e4b3240 (forced update)


[MNG-6090] CI friendly properties break submodule builds
[MNG-6057] Problem with CI friendly usage of ${..} reactor order is changed
 o Based on the missing replacement of the versions ${revision}
   ${changelist} or ${sha1} within the parent element the order
   of the reactor changes.
[MNG-5895] Problem with CI friendly usage of ${..} which is already
defined via property in pom file.


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/41e4b324
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/41e4b324
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/41e4b324

Branch: refs/heads/MNG-6057
Commit: 41e4b32405dfdea3b28a4e235e54a651db98154a
Parents: ab2e24f
Author: Karl Heinz Marbaise <khmarbaise@apache.org>
Authored: Tue Sep 29 11:46:48 2015 +0200
Committer: Karl Heinz Marbaise <khmarbaise@apache.org>
Committed: Sun Mar 12 23:30:10 2017 +0100

----------------------------------------------------------------------
 .../resolver/DefaultArtifactResolver.java       |  3 +-
 .../model/building/DefaultModelBuilder.java     | 35 ++++++++++++++++++--
 .../AbstractStringBasedModelInterpolator.java   | 20 +++++++++++
 .../model/validation/DefaultModelValidator.java |  7 ++--
 4 files changed, 59 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/41e4b324/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
----------------------------------------------------------------------
diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
index b78846b..7fcc290 100644
--- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
+++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
@@ -376,7 +376,7 @@ public class DefaultArtifactResolver
         ArtifactFilter resolutionFilter = request.getResolutionFilter();
         RepositorySystemSession session = getSession( request.getLocalRepository() );
 
-        // TODO hack because metadata isn't generated in m2e correctly and i want to run
the maven i have in the
+        // TODO: hack because metadata isn't generated in m2e correctly and i want to run
the maven i have in the
         // workspace
         if ( source == null )
         {
@@ -506,6 +506,7 @@ public class DefaultArtifactResolver
         if ( result.hasMetadataResolutionExceptions() || result.hasVersionRangeViolations()
             || result.hasCircularDependencyExceptions() )
         {
+            logger.info( "Failure detected." );
             return result;
         }
 

http://git-wip-us.apache.org/repos/asf/maven/blob/41e4b324/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..463bf1c 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
@@ -62,6 +62,8 @@ import org.apache.maven.model.superpom.SuperPomProvider;
 import org.apache.maven.model.validation.ModelValidator;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.interpolation.MapBasedValueSource;
+import org.codehaus.plexus.interpolation.StringSearchInterpolator;
 
 import java.io.File;
 import java.io.IOException;
@@ -766,13 +768,40 @@ public class DefaultModelBuilder
         // save profile activations before interpolation, since they are evaluated with limited
scope
         Map<String, Activation> originalActivations = getProfileActivations( model,
true );
 
-        Model result = modelInterpolator.interpolateModel( model, model.getProjectDirectory(),
request, problems );
-        result.setPomFile( model.getPomFile() );
+        Model interpolatedModel =
+            modelInterpolator.interpolateModel( model, model.getProjectDirectory(), request,
problems );
+        if ( interpolatedModel.getParent() != null )
+        {
+            StringSearchInterpolator ssi = new StringSearchInterpolator();
+            ssi.addValueSource( new MapBasedValueSource( request.getUserProperties() ) );
+
+            ssi.addValueSource( new MapBasedValueSource( model.getProperties() ) );
+
+            ssi.addValueSource( new MapBasedValueSource( request.getSystemProperties() )
);
+
+            try
+            {
+                String interpolated = ssi.interpolate( interpolatedModel.getParent().getVersion()
);
+                interpolatedModel.getParent().setVersion( interpolated );
+            }
+            catch ( Exception e )
+            {
+                ModelProblemCollectorRequest mpcr =
+                    new ModelProblemCollectorRequest( Severity.ERROR,
+                                                      Version.BASE ).setMessage( "Failed
to interpolate field: "
+                                                          + interpolatedModel.getParent().getVersion()
+                                                          + " on class: " ).setException(
e );
+                problems.add( mpcr );
+            }
+
+            
+        }
+        interpolatedModel.setPomFile( model.getPomFile() );
 
         // restore profiles with file activation to their value before full interpolation
         injectProfileActivations( model, originalActivations );
 
-        return result;
+        return interpolatedModel;
     }
 
     private ModelData readParent( Model childModel, ModelSource childSource, ModelBuildingRequest
request,

http://git-wip-us.apache.org/repos/asf/maven/blob/41e4b324/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
----------------------------------------------------------------------
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 cee376f..b47edbe 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
@@ -56,6 +56,12 @@ import org.codehaus.plexus.interpolation.ValueSource;
 public abstract class AbstractStringBasedModelInterpolator
     implements ModelInterpolator
 {
+    public static final String SHA1_PROPERTY = "sha1";
+
+    public static final String CHANGELIST_PROPERTY = "changelist";
+
+    public static final String REVISION_PROPERTY = "revision";
+
     private static final List<String> PROJECT_PREFIXES = Arrays.asList( "pom.", "project."
);
 
     private static final Collection<String> TRANSLATED_PATH_EXPRESSIONS;
@@ -165,6 +171,20 @@ public abstract class AbstractStringBasedModelInterpolator
 
         valueSources.add( new MapBasedValueSource( config.getUserProperties() ) );
 
+        // 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 ) )
+        {
+            modelProperties.put( REVISION_PROPERTY, config.getSystemProperties().get( REVISION_PROPERTY
) );
+        }
+        if ( config.getSystemProperties().containsKey( CHANGELIST_PROPERTY ) )
+        {
+            modelProperties.put( CHANGELIST_PROPERTY, config.getSystemProperties().get( CHANGELIST_PROPERTY
) );
+        }
+        if ( config.getSystemProperties().containsKey( SHA1_PROPERTY ) )
+        {
+            modelProperties.put( SHA1_PROPERTY, config.getSystemProperties().get( SHA1_PROPERTY
) );
+        }
         valueSources.add( new MapBasedValueSource( modelProperties ) );
 
         valueSources.add( new MapBasedValueSource( config.getSystemProperties() ) );

http://git-wip-us.apache.org/repos/asf/maven/blob/41e4b324/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
index 59b0532..e790f21 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
@@ -53,6 +53,7 @@ import org.apache.maven.model.building.ModelProblem.Severity;
 import org.apache.maven.model.building.ModelProblem.Version;
 import org.apache.maven.model.building.ModelProblemCollector;
 import org.apache.maven.model.building.ModelProblemCollectorRequest;
+import org.apache.maven.model.interpolation.AbstractStringBasedModelInterpolator;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -806,8 +807,10 @@ public class DefaultModelValidator
         // revision
         // sha1
         //
-        if ( string.trim().contains( "${changelist}" ) || string.trim().contains( "${revision}"
)
-            || string.trim().contains( "${sha1}" ) )
+        string = string.trim();
+        if ( string.contains( "${" + AbstractStringBasedModelInterpolator.CHANGELIST_PROPERTY
+ "}" )
+            || string.contains( "${" + AbstractStringBasedModelInterpolator.REVISION_PROPERTY
+ "}" )
+            || string.contains( "${" + AbstractStringBasedModelInterpolator.SHA1_PROPERTY
+ "}" ) )
         {
             return true;
         }


Mime
View raw message