You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2017/01/29 13:06:22 UTC

[1/9] maven git commit: [MNG-5946] Fix links etc. in README.txt which is part of the delivery - Changed consistently to https cause all links are available via https. - Fixed link to shutdown codehaus jira - Fixed link to git repository. [Forced Update!]

Repository: maven
Updated Branches:
  refs/heads/MNG-6078 7e78b97db -> 03d9d600b (forced update)


[MNG-5946] Fix links etc. in README.txt which is part of the delivery
- Changed consistently to https cause all links are available via https.
- Fixed link to shutdown codehaus jira
- Fixed link to git repository.


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

Branch: refs/heads/MNG-6078
Commit: c794c2a393855ad4d247783876613f1bb289e77f
Parents: a99a789
Author: Karl Heinz Marbaise <kh...@apache.org>
Authored: Fri Dec 11 19:52:38 2015 +0100
Committer: Karl Heinz Marbaise <kh...@apache.org>
Committed: Wed Jan 25 21:15:39 2017 +0100

----------------------------------------------------------------------
 apache-maven/README.txt | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/c794c2a3/apache-maven/README.txt
----------------------------------------------------------------------
diff --git a/apache-maven/README.txt b/apache-maven/README.txt
index 6a1bafd..935aa67 100644
--- a/apache-maven/README.txt
+++ b/apache-maven/README.txt
@@ -69,11 +69,11 @@
   Maven URLS
   ----------
 
-  Home Page:          http://maven.apache.org/
-  Downloads:          http://maven.apache.org/download.html
-  Release Notes:      http://maven.apache.org/release-notes.html
-  Mailing Lists:      http://maven.apache.org/mail-lists.html
-  Source Code:        https://git-wip-us.apache.org/repos/asf/maven.git/apache-maven
-  Issue Tracking:     http://jira.codehaus.org/browse/MNG
+  Home Page:          https://maven.apache.org/
+  Downloads:          https://maven.apache.org/download.html
+  Release Notes:      https://maven.apache.org/docs/history.html
+  Mailing Lists:      https://maven.apache.org/mail-lists.html
+  Source Code:        https://git-wip-us.apache.org/repos/asf/maven.git
+  Issue Tracking:     https://issues.apache.org/jira/browse/MNG
   Wiki:               https://cwiki.apache.org/confluence/display/MAVEN/
-  Available Plugins:  http://maven.apache.org/plugins/index.html
+  Available Plugins:  https://maven.apache.org/plugins/index.html


[6/9] maven git commit: [MNG-6144] DefaultWagonManagerTest#testGetMissingJarForced() passed incorrect value

Posted by kh...@apache.org.
[MNG-6144] DefaultWagonManagerTest#testGetMissingJarForced() passed incorrect value

This closes #86


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

Branch: refs/heads/MNG-6078
Commit: 920f10a561dee3c3bc34d356082dafd1457a8647
Parents: 5b4b8bd
Author: Michael Osipov <mi...@apache.org>
Authored: Sun Oct 16 12:27:41 2016 +0200
Committer: Michael Osipov <mi...@apache.org>
Committed: Sat Jan 28 17:09:30 2017 +0100

----------------------------------------------------------------------
 .../apache/maven/repository/legacy/DefaultWagonManagerTest.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/920f10a5/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java
----------------------------------------------------------------------
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java
index b9bcf9b..aa5dd68 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java
@@ -138,7 +138,7 @@ public class DefaultWagonManagerTest
 
         try
         {
-            wagonManager.getArtifact( artifact, repo, null, false );
+            wagonManager.getArtifact( artifact, repo, null, true );
 
             fail();
         }


[7/9] maven git commit: [MNG-6147] MetadataResolutionResult#getGraph() contains duplicate if clause

Posted by kh...@apache.org.
[MNG-6147] MetadataResolutionResult#getGraph() contains duplicate if clause


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

Branch: refs/heads/MNG-6078
Commit: f53f1547a16fb0f7e288de5c4684c599652ee601
Parents: 920f10a
Author: Michael Osipov <mi...@apache.org>
Authored: Sat Jan 28 15:26:52 2017 +0100
Committer: Michael Osipov <mi...@apache.org>
Committed: Sat Jan 28 17:09:30 2017 +0100

----------------------------------------------------------------------
 .../maven/repository/metadata/MetadataResolutionResult.java      | 4 ----
 1 file changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/f53f1547/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionResult.java
----------------------------------------------------------------------
diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionResult.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionResult.java
index 1d9e9c4..814b66c 100644
--- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionResult.java
+++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionResult.java
@@ -119,10 +119,6 @@ public class MetadataResolutionResult
         {
             return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.test );
         }
-        else if ( requestType.equals( MetadataResolutionRequestTypeEnum.classpathRuntime ) )
-        {
-            return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.test );
-        }
         else if ( requestType.equals( MetadataResolutionRequestTypeEnum.graph ) )
         {
             return getGraph();


[4/9] maven git commit: [MNG-5883] Silence unnecessary legacy local repository warning

Posted by kh...@apache.org.
[MNG-5883] Silence unnecessary legacy local repository warning

o Updated to decrease logging level from 'warning' to 'info'.


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

Branch: refs/heads/MNG-6078
Commit: 1e2a80eced0f01c182458a2c7e7919634fa632f6
Parents: 6b31c4a
Author: Christian Schulte <sc...@apache.org>
Authored: Mon Jan 25 02:40:03 2016 +0100
Committer: Christian Schulte <sc...@apache.org>
Committed: Thu Jan 26 20:30:37 2017 +0100

----------------------------------------------------------------------
 .../aether/DefaultRepositorySystemSessionFactory.java        | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/1e2a80ec/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
index 0c91cf9..a0c5444 100644
--- a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
+++ b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
@@ -132,16 +132,16 @@ public class DefaultRepositorySystemSessionFactory
 
         if ( request.isUseLegacyLocalRepository() )
         {
-            logger.warn( "Disabling enhanced local repository: using legacy is strongly discouraged to ensure"
-                             + " build reproducibility." );
             try
             {
                 session.setLocalRepositoryManager( simpleLocalRepoMgrFactory.newInstance( session, localRepo ) );
+                logger.info( "Disabling enhanced local repository: using legacy is strongly discouraged to ensure"
+                                 + " build reproducibility." );
+
             }
             catch ( NoLocalRepositoryManagerException e )
             {
-
-                logger.warn( "Failed to configure legacy local repository: back to default" );
+                logger.error( "Failed to configure legacy local repository: falling back to default" );
                 session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( session, localRepo ) );
             }
         }


[8/9] maven git commit: [MNG-6145] Remove non-existent m2 include in component.xml

Posted by kh...@apache.org.
[MNG-6145] Remove non-existent m2 include in component.xml


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

Branch: refs/heads/MNG-6078
Commit: aecccf9a2a0a5d2db1fcb602cc972284fd573a4a
Parents: f53f154
Author: Michael Osipov <mi...@apache.org>
Authored: Fri Oct 7 21:39:24 2016 +0200
Committer: Michael Osipov <mi...@apache.org>
Committed: Sat Jan 28 18:19:31 2017 +0100

----------------------------------------------------------------------
 apache-maven/src/main/assembly/component.xml | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/aecccf9a/apache-maven/src/main/assembly/component.xml
----------------------------------------------------------------------
diff --git a/apache-maven/src/main/assembly/component.xml b/apache-maven/src/main/assembly/component.xml
index 8ccf02a..ca4dcb6 100644
--- a/apache-maven/src/main/assembly/component.xml
+++ b/apache-maven/src/main/assembly/component.xml
@@ -68,7 +68,6 @@ under the License.
       <directory>src/bin</directory>
       <outputDirectory>bin</outputDirectory>
       <includes>
-        <include>m2</include>
         <include>mvn</include>
         <include>mvnDebug</include>
         <!-- This is so that CI systems can periodically run the profiler -->


[3/9] maven git commit: [MNG-5958] restore binary compatibility of Lifecycle.setPhases

Posted by kh...@apache.org.
[MNG-5958] restore binary compatibility of Lifecycle.setPhases

While MNG-5805 restored binary compatibility of Lifecycle.getPhases
it didn't do the same for Lifecycle.setPhases. This breaks plugins
like flexmojos-maven-plugin which have their own lifecycle mapping
implementations.

This closes #77


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

Branch: refs/heads/MNG-6078
Commit: 6b31c4a556f51cd1c2064fe773550c0acf14d307
Parents: f20a5d9
Author: Stuart McCulloch <mc...@gmail.com>
Authored: Wed Jan 6 11:23:06 2016 +0000
Committer: Christian Schulte <sc...@apache.org>
Committed: Thu Jan 26 20:19:57 2017 +0100

----------------------------------------------------------------------
 .../java/org/apache/maven/lifecycle/mapping/Lifecycle.java  | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/6b31c4a5/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java
index d2b6d6c..c14cf94 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java
@@ -106,8 +106,13 @@ public class Lifecycle
     }
 
     @Deprecated
-    public void setPhases( Map<String, LifecyclePhase> phases )
+    public void setPhases( Map<String, String> phases )
     {
-        setLifecyclePhases( phases );
+        Map<String, LifecyclePhase> lphases = new LinkedHashMap<>();
+        for ( Map.Entry<String, String> e: phases.entrySet() )
+        {
+            lphases.put( e.getKey(), new LifecyclePhase( e.getValue() ) );
+        }
+        setLifecyclePhases( lphases );
     }
 }


[2/9] maven git commit: [MNG-5931] Fixing documentation Removing references to ejb3-lifecycle and par-lifecycle cause they have been removed with Maven 3.3.9.

Posted by kh...@apache.org.
[MNG-5931] Fixing documentation
Removing references to ejb3-lifecycle and par-lifecycle
cause they have been removed with Maven 3.3.9.


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

Branch: refs/heads/MNG-6078
Commit: f20a5d940bf055ea49c5cc1ecbdba07a3a27fbe6
Parents: c794c2a
Author: Karl Heinz Marbaise <kh...@apache.org>
Authored: Wed Nov 18 03:48:06 2015 +0100
Committer: Karl Heinz Marbaise <kh...@apache.org>
Committed: Wed Jan 25 21:30:02 2017 +0100

----------------------------------------------------------------------
 maven-core/src/site/apt/default-bindings.apt.vm | 7 -------
 1 file changed, 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/f20a5d94/maven-core/src/site/apt/default-bindings.apt.vm
----------------------------------------------------------------------
diff --git a/maven-core/src/site/apt/default-bindings.apt.vm b/maven-core/src/site/apt/default-bindings.apt.vm
index 02d6c4a..50c4654 100644
--- a/maven-core/src/site/apt/default-bindings.apt.vm
+++ b/maven-core/src/site/apt/default-bindings.apt.vm
@@ -42,10 +42,6 @@ Plugin Bindings for <<<default>>> Lifecycle Reference
 
 %{snippet|id=ejb-lifecycle|file=${project.basedir}/src/main/resources/META-INF/plexus/default-bindings.xml}
 
-* Plugin bindings for <<<ejb3>>> packaging
-
-%{snippet|id=ejb3-lifecycle|file=${project.basedir}/src/main/resources/META-INF/plexus/default-bindings.xml}
-
 * Plugin bindings for <<<maven-plugin>>> packaging
 
 %{snippet|id=maven-plugin-lifecycle|file=${project.basedir}/src/main/resources/META-INF/plexus/default-bindings.xml}
@@ -62,6 +58,3 @@ Plugin Bindings for <<<default>>> Lifecycle Reference
 
 %{snippet|id=rar-lifecycle|file=${project.basedir}/src/main/resources/META-INF/plexus/default-bindings.xml}
 
-* Plugin bindings for <<<par>>> packaging
-
-%{snippet|id=par-lifecycle|file=${project.basedir}/src/main/resources/META-INF/plexus/default-bindings.xml}


[9/9] maven git commit: [MNG-6078] Can't overwrite properties which have been defined in .mvn/maven.config o Reversed the order of properties only to get the properties from command line at the end of the properties list which results in correct b

Posted by kh...@apache.org.
[MNG-6078] Can't overwrite properties which have been defined in
.mvn/maven.config
 o Reversed the order of properties only to get the properties from
   command line at the end of the properties list which results
   in correct behaviour to be able to overwrite properties from
   command line for properties which have been defined in
   .mvn/maven.config file.


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

Branch: refs/heads/MNG-6078
Commit: 03d9d600b5f37cd61b478370f0b698e241e7ff79
Parents: aecccf9
Author: Karl Heinz Marbaise <kh...@apache.org>
Authored: Sun Aug 7 12:21:01 2016 +0200
Committer: Karl Heinz Marbaise <kh...@apache.org>
Committed: Sun Jan 29 14:05:58 2017 +0100

----------------------------------------------------------------------
 .../java/org/apache/maven/cli/MavenCli.java     | 12 ++++-
 .../java/org/apache/maven/cli/MavenCliTest.java | 53 ++++++++++++++++++--
 .../mavenConfigProperties/.mvn/maven.config     |  3 ++
 3 files changed, 62 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/03d9d600/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
index c0b0dcf..57b0f63 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -27,6 +27,7 @@ import com.google.inject.AbstractModule;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.ParseException;
 import org.apache.commons.cli.UnrecognizedOptionException;
+import org.apache.commons.lang3.ArrayUtils;
 import org.apache.maven.BuildAbort;
 import org.apache.maven.InternalErrorException;
 import org.apache.maven.Maven;
@@ -543,7 +544,9 @@ public class MavenCli
         }
     }
 
-    private void properties( CliRequest cliRequest )
+    //Needed to make this method package visible to make writing a unit test possible
+    //Maybe it's better to move some of those methods to separate class (SoC).
+    void properties( CliRequest cliRequest )
     {
         populateProperties( cliRequest.commandLine, cliRequest.systemProperties, cliRequest.userProperties );
     }
@@ -1582,9 +1585,14 @@ public class MavenCli
         if ( commandLine.hasOption( CLIManager.SET_SYSTEM_PROPERTY ) )
         {
             String[] defStrs = commandLine.getOptionValues( CLIManager.SET_SYSTEM_PROPERTY );
-
+            
             if ( defStrs != null )
             {
+                //The following is needed to get precedence
+                //of properties which are defined on command line
+                //over properties defined in the .mvn/maven.config. 
+                ArrayUtils.reverse( defStrs );
+                
                 for ( String defStr : defStrs )
                 {
                     setCliProperty( defStr, userProperties );

http://git-wip-us.apache.org/repos/asf/maven/blob/03d9d600/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
index c8d75b1..d926624 100644
--- a/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
+++ b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
@@ -21,10 +21,10 @@ package org.apache.maven.cli;
 
 import java.io.File;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.cli.ParseException;
 
+import junit.framework.TestCase;
+
 public class MavenCliTest
     extends TestCase
 {
@@ -81,8 +81,8 @@ public class MavenCliTest
         // read .mvn/maven.config
         cli.initialize( request );
         cli.cli( request );
-        assertEquals( "multithreaded", request.commandLine.getOptionValue( "builder" ) );
-        assertEquals( "8", request.commandLine.getOptionValue( "threads" ) );
+        assertEquals( "multithreaded", request.commandLine.getOptionValue( CLIManager.BUILDER ) );
+        assertEquals( "8", request.commandLine.getOptionValue( CLIManager.THREADS ) );
 
         // override from command line
         request = new CliRequest( new String[] { "--builder", "foobar" }, null );
@@ -107,4 +107,49 @@ public class MavenCliTest
 
         }
     }
+    
+    /**
+     * Read .mvn/maven.config with the following definitions:
+     * <pre>
+     *   -T 3
+     *   -Drevision=1.3.0
+     * </pre>
+     * and check if the {@code -T 3} option can be overwritten via command line
+     * argument.
+     * @throws Exception in case of failure.
+     */
+    public void testMVNConfigurationThreadCanBeOverwrittenViaCommandLine() throws Exception {
+        System.setProperty( MavenCli.MULTIMODULE_PROJECT_DIRECTORY, new File( "src/test/projects/mavenConfigProperties" ).getCanonicalPath() );
+        CliRequest request = new CliRequest( new String[]{ "-T", "5" }, null );
+
+        cli.initialize( request );
+        // read .mvn/maven.config
+        cli.cli( request );
+        
+        assertEquals( "5", request.commandLine.getOptionValue( CLIManager.THREADS ) );
+    }
+    
+    /**
+     * Read .mvn/maven.config with the following definitions:
+     * <pre>
+     *   -T 3
+     *   -Drevision=1.3.0
+     * </pre>
+     * and check if the {@code -Drevision-1.3.0} option can be overwritten via command line
+     * argument.
+     * @throws Exception
+     */
+    public void testMVNConfigurationDefinedPropertiesCanBeOverwrittenViaCommandLine() throws Exception {
+        System.setProperty( MavenCli.MULTIMODULE_PROJECT_DIRECTORY, new File( "src/test/projects/mavenConfigProperties" ).getCanonicalPath() );
+        CliRequest request = new CliRequest( new String[]{ "-Drevision=8.1.0"}, null );
+
+        cli.initialize( request );
+        // read .mvn/maven.config
+        cli.cli( request );
+        cli.properties( request );
+        
+        String revision = System.getProperty( "revision" );
+        assertEquals( "8.1.0", revision );
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/03d9d600/maven-embedder/src/test/projects/mavenConfigProperties/.mvn/maven.config
----------------------------------------------------------------------
diff --git a/maven-embedder/src/test/projects/mavenConfigProperties/.mvn/maven.config b/maven-embedder/src/test/projects/mavenConfigProperties/.mvn/maven.config
new file mode 100644
index 0000000..c73de53
--- /dev/null
+++ b/maven-embedder/src/test/projects/mavenConfigProperties/.mvn/maven.config
@@ -0,0 +1,3 @@
+-T 3
+-Drevision=1.3.0
+


[5/9] maven git commit: [MNG-6105] properties.internal.SystemProperties.addSystemProperties() is not really thread-safe

Posted by kh...@apache.org.
[MNG-6105] properties.internal.SystemProperties.addSystemProperties() is not really thread-safe

Refactoring the current code setting system properties to synchronize correctly on the given ones: avoids ConcurrentModificationException and NullPointerException if the properties is modified by another thread.


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

Branch: refs/heads/MNG-6078
Commit: 5b4b8bd94c87afd2a1527d6a860e9673bdaf4a22
Parents: 1e2a80e
Author: Guillaume Bou� <gb...@apache.org>
Authored: Sun Oct 16 01:40:46 2016 +0200
Committer: Guillaume Bou� <gb...@apache.org>
Committed: Sat Jan 28 14:07:59 2017 +0100

----------------------------------------------------------------------
 .../internal/MavenRepositorySystemUtils.java    | 14 +++++----
 .../execution/DefaultMavenExecutionRequest.java |  4 +--
 .../project/DefaultProjectBuildingRequest.java  |  7 ++---
 .../properties/internal/SystemProperties.java   | 30 ++++++++++++++------
 .../building/DefaultModelBuildingRequest.java   |  5 +++-
 .../DefaultSettingsBuildingRequest.java         |  7 ++---
 6 files changed, 42 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/5b4b8bd9/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
index 5b240ef..1b11cb3 100644
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
+++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java
@@ -126,14 +126,18 @@ public final class MavenRepositorySystemUtils
 
         session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) );
 
+        final Properties systemProperties = new Properties();
+        
         // MNG-5670 guard against ConcurrentModificationException
-        Properties sysProps = new Properties();
-        for ( String key : System.getProperties().stringPropertyNames() )
+        // MNG-6053 guard against key without value
+        Properties sysProp = System.getProperties();
+        synchronized ( sysProp )
         {
-            sysProps.put( key, System.getProperty( key ) );
+            systemProperties.putAll( sysProp );
         }
-        session.setSystemProperties( sysProps );
-        session.setConfigProperties( sysProps );
+
+        session.setSystemProperties( systemProperties );
+        session.setConfigProperties( systemProperties );
 
         return session;
     }

http://git-wip-us.apache.org/repos/asf/maven/blob/5b4b8bd9/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
index 71a6894..d67061f 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
@@ -33,6 +33,7 @@ import org.apache.maven.eventspy.internal.EventSpyDispatcher;
 import org.apache.maven.model.Profile;
 import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.properties.internal.SystemProperties;
 import org.apache.maven.settings.Mirror;
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Server;
@@ -535,8 +536,7 @@ public class DefaultMavenExecutionRequest
     {
         if ( properties != null )
         {
-            this.systemProperties = new Properties();
-            this.systemProperties.putAll( properties );
+            this.systemProperties = SystemProperties.copyProperties( properties );
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/maven/blob/5b4b8bd9/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
index f439240..f1b271b 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
@@ -28,6 +28,7 @@ import org.apache.commons.lang3.Validate;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.model.Profile;
 import org.apache.maven.model.building.ModelBuildingRequest;
+import org.apache.maven.properties.internal.SystemProperties;
 import org.eclipse.aether.RepositorySystemSession;
 
 public class DefaultProjectBuildingRequest
@@ -165,11 +166,7 @@ public class DefaultProjectBuildingRequest
     {
         if ( systemProperties != null )
         {
-            this.systemProperties = new Properties();
-            synchronized ( systemProperties )
-            { // avoid concurrentmodification if someone else sets/removes an unrelated system property
-                this.systemProperties.putAll( systemProperties );
-            }
+            this.systemProperties = SystemProperties.copyProperties( systemProperties );
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/maven/blob/5b4b8bd9/maven-core/src/main/java/org/apache/maven/properties/internal/SystemProperties.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/properties/internal/SystemProperties.java b/maven-core/src/main/java/org/apache/maven/properties/internal/SystemProperties.java
index aa5fed9..3d6a969 100644
--- a/maven-core/src/main/java/org/apache/maven/properties/internal/SystemProperties.java
+++ b/maven-core/src/main/java/org/apache/maven/properties/internal/SystemProperties.java
@@ -33,19 +33,33 @@ public class SystemProperties
      */
     public static void addSystemProperties( Properties props )
     {
-        for ( String key : System.getProperties().stringPropertyNames() )
-        {
-            props.put( key, System.getProperty( key ) );
-        }
+        props.putAll( getSystemProperties() );
     }
 
     /**
-     * Returns System.properties copy.
+     * Returns a copy of {@link System#getProperties()} in a thread-safe manner.
+     * 
+     * @return {@link System#getProperties()} obtained in a thread-safe manner. 
      */
     public static Properties getSystemProperties()
     {
-        Properties systemProperties = new Properties();
-        addSystemProperties( systemProperties );
-        return systemProperties;
+        return copyProperties( System.getProperties() );
+    }
+
+    /**
+     * Copies the given {@link Properties} object into a new {@link Properties} object, in a thread-safe manner.
+     * @param properties Properties to copy.
+     * @return Copy of the given properties.
+     */
+    public static Properties copyProperties( Properties properties )
+    {
+        final Properties copyProperties = new Properties();
+        // guard against modification/removal of keys in the given properties (MNG-5670, MNG-6053, MNG-6105)
+        synchronized ( properties )
+        {
+            copyProperties.putAll( properties );
+        }
+        return copyProperties;
     }
+
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/5b4b8bd9/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java
index a3505c9..84a68f7 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java
@@ -286,7 +286,10 @@ public class DefaultModelBuildingRequest
         if ( systemProperties != null )
         {
             this.systemProperties = new Properties();
-            this.systemProperties.putAll( systemProperties );
+            synchronized ( systemProperties )
+            { // avoid concurrentmodification if someone else sets/removes an unrelated system property
+                this.systemProperties.putAll( systemProperties );
+            }
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/maven/blob/5b4b8bd9/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuildingRequest.java
----------------------------------------------------------------------
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuildingRequest.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuildingRequest.java
index 5a4824e..4bb691b 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuildingRequest.java
+++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuildingRequest.java
@@ -116,10 +116,9 @@ public class DefaultSettingsBuildingRequest
         if ( systemProperties != null )
         {
             this.systemProperties = new Properties();
-            // MNG-5670 guard against ConcurrentModificationException
-            for ( String key : System.getProperties().stringPropertyNames() )
-            {
-                this.systemProperties.put( key, System.getProperty( key ) );
+            synchronized ( systemProperties )
+            { // avoid concurrentmodification if someone else sets/removes an unrelated system property
+                this.systemProperties.putAll( systemProperties );
             }
         }
         else