maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khmarba...@apache.org
Subject [2/2] 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} withi
Date Fri, 24 Feb 2017 21:57:19 GMT
[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/07ea2335
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/07ea2335
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/07ea2335

Branch: refs/heads/mvn-3.5.1/MNG-6057
Commit: 07ea233584c9feddcc79a60e31aa52693a8d3407
Parents: 0b9a30f
Author: Karl Heinz Marbaise <khmarbaise@apache.org>
Authored: Tue Sep 29 11:46:48 2015 +0200
Committer: Karl Heinz Marbaise <khmarbaise@apache.org>
Committed: Fri Feb 24 22:56:57 2017 +0100

----------------------------------------------------------------------
 .../resolver/DefaultArtifactResolver.java       | 47 ++++++++------------
 .../model/building/DefaultModelBuilder.java     | 35 +++++++++++++--
 .../AbstractStringBasedModelInterpolator.java   | 27 ++++++++---
 3 files changed, 72 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/07ea2335/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..9bc37c3 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
@@ -22,10 +22,12 @@ package org.apache.maven.artifact.resolver;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
@@ -149,21 +151,21 @@ public class DefaultArtifactResolver
 
     public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories,
                          ArtifactRepository localRepository, TransferListener resolutionListener
)
-                             throws ArtifactResolutionException, ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException
     {
         resolve( artifact, remoteRepositories, getSession( localRepository ) );
     }
 
     public void resolveAlways( Artifact artifact, List<ArtifactRepository> remoteRepositories,
                                ArtifactRepository localRepository )
-                                   throws ArtifactResolutionException, ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException
     {
         resolve( artifact, remoteRepositories, getSession( localRepository ) );
     }
 
     private void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories,
                           RepositorySystemSession session )
-                              throws ArtifactResolutionException, ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException
     {
         if ( artifact == null )
         {
@@ -255,8 +257,7 @@ public class DefaultArtifactResolver
                                                          ArtifactRepository localRepository,
                                                          List<ArtifactRepository> remoteRepositories,
                                                          ArtifactMetadataSource source, ArtifactFilter
filter )
-                                                             throws ArtifactResolutionException,
-                                                             ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException
     {
         return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP,
localRepository,
                                     remoteRepositories, source, filter );
@@ -268,8 +269,7 @@ public class DefaultArtifactResolver
                                                          ArtifactRepository localRepository,
                                                          List<ArtifactRepository> remoteRepositories,
                                                          ArtifactMetadataSource source )
-                                                             throws ArtifactResolutionException,
-                                                             ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException
     {
         return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
                                     remoteRepositories, source, null );
@@ -280,8 +280,7 @@ public class DefaultArtifactResolver
                                                          ArtifactRepository localRepository,
                                                          List<ArtifactRepository> remoteRepositories,
                                                          ArtifactMetadataSource source, ArtifactFilter
filter )
-                                                             throws ArtifactResolutionException,
-                                                             ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException
     {
         return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
                                     remoteRepositories, source, filter, null );
@@ -291,8 +290,7 @@ public class DefaultArtifactResolver
                                                          List<ArtifactRepository> remoteRepositories,
                                                          ArtifactRepository localRepository,
                                                          ArtifactMetadataSource source )
-                                                             throws ArtifactResolutionException,
-                                                             ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException
     {
         return resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories,
source, null );
     }
@@ -302,8 +300,7 @@ public class DefaultArtifactResolver
                                                          ArtifactRepository localRepository,
                                                          ArtifactMetadataSource source,
                                                          List<ResolutionListener> listeners
)
-                                                             throws ArtifactResolutionException,
-                                                             ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException
     {
         return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP,
localRepository,
                                     remoteRepositories, source, null, listeners );
@@ -315,8 +312,7 @@ public class DefaultArtifactResolver
                                                          List<ArtifactRepository> remoteRepositories,
                                                          ArtifactMetadataSource source, ArtifactFilter
filter,
                                                          List<ResolutionListener> listeners
)
-                                                             throws ArtifactResolutionException,
-                                                             ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException
     {
         return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
                                     remoteRepositories, source, filter, listeners, null );
@@ -329,19 +325,12 @@ public class DefaultArtifactResolver
                                                          ArtifactMetadataSource source, ArtifactFilter
filter,
                                                          List<ResolutionListener> listeners,
                                                          List<ConflictResolver> conflictResolvers
)
-                                                             throws ArtifactResolutionException,
-                                                             ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException
     {
-        ArtifactResolutionRequest request = new ArtifactResolutionRequest().
-            setArtifact( originatingArtifact ).
-            setResolveRoot( false ).
+        ArtifactResolutionRequest request =
+            new ArtifactResolutionRequest().setArtifact( originatingArtifact ).setResolveRoot(
false ).
             // This is required by the surefire plugin
-            setArtifactDependencies( artifacts ).
-            setManagedVersionMap( managedVersions ).
-            setLocalRepository( localRepository ).
-            setRemoteRepositories( remoteRepositories ).
-            setCollectionFilter( filter ).
-            setListeners( listeners );
+                                           setArtifactDependencies( artifacts ).setManagedVersionMap(
managedVersions ).setLocalRepository( localRepository ).setRemoteRepositories( remoteRepositories
).setCollectionFilter( filter ).setListeners( listeners );
 
         injectSession2( request, legacySupport.getSession() );
 
@@ -376,7 +365,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 +495,7 @@ public class DefaultArtifactResolver
         if ( result.hasMetadataResolutionExceptions() || result.hasVersionRangeViolations()
             || result.hasCircularDependencyExceptions() )
         {
+            logger.info( "Failure detected." );
             return result;
         }
 
@@ -519,6 +509,7 @@ public class DefaultArtifactResolver
             {
                 Artifact artifact = node.getArtifact();
 
+                Iterator<ResolutionNode> childrenIterator = node.getChildrenIterator();
                 if ( resolutionFilter == null || resolutionFilter.include( artifact ) )
                 {
                     executor.execute( new ResolveTask( classLoader, latch, artifact, session,
@@ -556,7 +547,7 @@ public class DefaultArtifactResolver
 
     public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories,
                          ArtifactRepository localRepository )
-                             throws ArtifactResolutionException, ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException
     {
         resolve( artifact, remoteRepositories, localRepository, null );
     }

http://git-wip-us.apache.org/repos/asf/maven/blob/07ea2335/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/07ea2335/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..08a430b 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
@@ -165,9 +165,23 @@ 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" ) )
+        {
+            modelProperties.put( "revision", config.getSystemProperties().get( "revision"
) );
+        }
+        if ( config.getSystemProperties().containsKey( "changelist" ) )
+        {
+            modelProperties.put( "changelist", config.getSystemProperties().get( "changelist"
) );
+        }
+        if ( config.getSystemProperties().containsKey( "sha1" ) )
+        {
+            modelProperties.put( "sha1", config.getSystemProperties().get( "sha1" ) );
+        }
         valueSources.add( new MapBasedValueSource( modelProperties ) );
 
-        valueSources.add( new MapBasedValueSource( config.getSystemProperties() ) );
+        valueSources.add( new MapBasedValueSource   ( config.getSystemProperties() ) );
 
         valueSources.add( new AbstractValueSource( false )
         {
@@ -183,15 +197,14 @@ public abstract class AbstractStringBasedModelInterpolator
         return valueSources;
     }
 
-    protected List<? extends InterpolationPostProcessor> createPostProcessors( final
Model model,
-                                                                               final File
projectDir,
+    protected List<? extends InterpolationPostProcessor> createPostProcessors( final
Model model, final File projectDir,
                                                                                final ModelBuildingRequest
config )
     {
         List<InterpolationPostProcessor> processors = new ArrayList<>( 2 );
         if ( projectDir != null )
         {
-            processors.add( new PathTranslatingPostProcessor( PROJECT_PREFIXES, TRANSLATED_PATH_EXPRESSIONS,
-                                                              projectDir, pathTranslator
) );
+            processors.add( new PathTranslatingPostProcessor( PROJECT_PREFIXES, TRANSLATED_PATH_EXPRESSIONS,
projectDir,
+                                                              pathTranslator ) );
         }
         processors.add( new UrlNormalizingPostProcessor( urlNormalizer ) );
         return processors;
@@ -228,8 +241,10 @@ public abstract class AbstractStringBasedModelInterpolator
                 }
                 catch ( InterpolationException e )
                 {
+                    //@formatter:off
                     problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE
)
-                        .setMessage( e.getMessage() ).setException( e ) );
+                                  .setMessage( e.getMessage() ).setException( e ) );
+                    //@formatter:on
                 }
 
                 interpolator.clearFeedback();


Mime
View raw message