maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From schu...@apache.org
Subject maven git commit: [MNG-4645] Move central repo definition out of Maven's core so it can be more easily changed.
Date Thu, 30 Jun 2016 06:19:43 GMT
Repository: maven
Updated Branches:
  refs/heads/master 5077f2216 -> 15a9c32f6


[MNG-4645] Move central repo definition out of Maven's core so it can be more easily changed.

o Updated to stop falling back to some hard-coded default 'central' repository,
  if no such repository is setup in the settings or the POM. This means there
  is no such thing as a default repository other than what is shipped with
  the default settings anymore.


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

Branch: refs/heads/master
Commit: 15a9c32f6775f10fb5317ad6cddfafd72d7f9e8d
Parents: 5077f22
Author: Christian Schulte <schulte@apache.org>
Authored: Thu Jun 30 08:12:52 2016 +0200
Committer: Christian Schulte <schulte@apache.org>
Committed: Thu Jun 30 08:18:08 2016 +0200

----------------------------------------------------------------------
 apache-maven/src/conf/settings.xml              |  6 ++
 .../maven/bridge/MavenRepositorySystem.java     | 33 +++++-----
 .../DefaultMavenExecutionRequestPopulator.java  | 67 +++-----------------
 .../maven/repository/RepositorySystem.java      | 15 +++++
 .../project/AbstractMavenProjectTestCase.java   | 13 +++-
 .../artifact/DefaultMavenMetadataCacheTest.java | 36 +++++++++--
 .../maven/repository/TestRepositorySystem.java  | 10 +--
 7 files changed, 95 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/15a9c32f/apache-maven/src/conf/settings.xml
----------------------------------------------------------------------
diff --git a/apache-maven/src/conf/settings.xml b/apache-maven/src/conf/settings.xml
index 81f3560..8d903f2 100644
--- a/apache-maven/src/conf/settings.xml
+++ b/apache-maven/src/conf/settings.xml
@@ -245,6 +245,9 @@ under the License.
     </profile>
     -->
 
+    <!--
+    | Default profile holding various defaults.
+    |-->
     <profile>
       <id>default</id>
 
@@ -257,6 +260,9 @@ under the License.
           <snapshots>
             <enabled>false</enabled>
           </snapshots>
+          <releases>
+            <updatePolicy>never</updatePolicy>
+          </releases>
         </repository>
       </repositories>
 

http://git-wip-us.apache.org/repos/asf/maven/blob/15a9c32f/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
index 9331710..428ade0 100644
--- a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
+++ b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
@@ -416,8 +416,8 @@ public class MavenRepositorySystem
         }
 
         return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy );
-    }    
-    
+    }
+
     public ArtifactRepository createArtifactRepository( String id, String url, String layoutId,
                                                         ArtifactRepositoryPolicy snapshots,
                                                         ArtifactRepositoryPolicy releases
)
@@ -439,7 +439,7 @@ public class MavenRepositorySystem
                                                 repositoryId ) );
         }
     }
-    
+
     public static ArtifactRepository createArtifactRepository( String id, String url,
                                                         ArtifactRepositoryLayout repositoryLayout,
                                                         ArtifactRepositoryPolicy snapshots,
@@ -564,20 +564,21 @@ public class MavenRepositorySystem
         return new DefaultArtifact( groupId, artifactId, versionRange, desiredScope, type,
classifier, handler,
                                     optional );
     }
-    
+
     //
     // Code taken from LegacyRepositorySystem
     //
-        
+    /**
+     * @deprecation As of 3.4, Maven no longer falls back to a hard-coded default repository
with identifier
+     * {@code central} if such a repository is not provided in the settings or the POM.
+     */
+    @Deprecated
     public ArtifactRepository createDefaultRemoteRepository( MavenExecutionRequest request
)
         throws Exception
     {
-        return createRepository( RepositorySystem.DEFAULT_REMOTE_REPO_URL, RepositorySystem.DEFAULT_REMOTE_REPO_ID,
-                                 true, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, false,
-                                 ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY,
-                                 ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
+        throw new UnsupportedOperationException();
     }
-    
+
     public ArtifactRepository createRepository( String url, String repositoryId, boolean
releases,
                                                  String releaseUpdates, boolean snapshots,
String snapshotUpdates,
                                                  String checksumPolicy ) throws Exception
@@ -590,7 +591,7 @@ public class MavenRepositorySystem
 
         return createArtifactRepository( repositoryId, url, "default", snapshotsPolicy, releasesPolicy
);
     }
-        
+
     public Set<String> getRepoIds( List<ArtifactRepository> repositories )
     {
         Set<String> repoIds = new HashSet<>();
@@ -605,8 +606,8 @@ public class MavenRepositorySystem
 
         return repoIds;
     }
-    
-    
+
+
     public ArtifactRepository createLocalRepository( MavenExecutionRequest request, File
localRepository )
         throws Exception
     {
@@ -615,8 +616,8 @@ public class MavenRepositorySystem
                                  ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, true,
                                  ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
                                  ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
-    }    
-    
+    }
+
     private static final String WILDCARD = "*";
 
     private static final String EXTERNAL_WILDCARD = "external:*";
@@ -781,5 +782,5 @@ public class MavenRepositorySystem
         }
 
         return result;
-    }    
+    }
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/15a9c32f/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java
b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java
index ba5630e..2bed92f 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java
@@ -24,7 +24,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import javax.inject.Inject;
 import javax.inject.Named;
@@ -33,18 +32,12 @@ import org.apache.maven.artifact.InvalidRepositoryException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.bridge.MavenRepositorySystem;
 import org.apache.maven.repository.RepositorySystem;
-//
-// All of this needs to go away and be couched in terms of the execution request
-//
 import org.apache.maven.settings.Mirror;
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Repository;
 import org.apache.maven.settings.Server;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.settings.SettingsUtils;
-//
-// Settings in core
-//
 import org.apache.maven.toolchain.model.PersistedToolchains;
 import org.apache.maven.toolchain.model.ToolchainModel;
 import org.codehaus.plexus.util.StringUtils;
@@ -53,9 +46,9 @@ import org.codehaus.plexus.util.StringUtils;
 public class DefaultMavenExecutionRequestPopulator
     implements MavenExecutionRequestPopulator
 {
-            
+
     private final MavenRepositorySystem repositorySystem;
-    
+
     @Inject
     public DefaultMavenExecutionRequestPopulator( MavenRepositorySystem repositorySystem
)
     {
@@ -85,7 +78,7 @@ public class DefaultMavenExecutionRequestPopulator
         }
         return request;
     }
-    
+
     @Override
     public MavenExecutionRequest populateDefaults( MavenExecutionRequest request )
         throws MavenExecutionRequestPopulationException
@@ -96,59 +89,19 @@ public class DefaultMavenExecutionRequestPopulator
 
         populateDefaultPluginGroups( request );
 
-        injectDefaultRepositories( request );
-
-        injectDefaultPluginRepositories( request );
-
         return request;
     }
-    
+
     //
     //
     //
-    
+
     private void populateDefaultPluginGroups( MavenExecutionRequest request )
     {
         request.addPluginGroup( "org.apache.maven.plugins" );
         request.addPluginGroup( "org.codehaus.mojo" );
     }
 
-    private void injectDefaultRepositories( MavenExecutionRequest request )
-        throws MavenExecutionRequestPopulationException
-    {
-        Set<String> definedRepositories = repositorySystem.getRepoIds( request.getRemoteRepositories()
);
-
-        if ( !definedRepositories.contains( RepositorySystem.DEFAULT_REMOTE_REPO_ID ) )
-        {
-            try
-            {
-                request.addRemoteRepository( repositorySystem.createDefaultRemoteRepository(
request ) );
-            }
-            catch ( Exception e )
-            {
-                throw new MavenExecutionRequestPopulationException( "Cannot create default
remote repository.", e );
-            }
-        }
-    }
-
-    private void injectDefaultPluginRepositories( MavenExecutionRequest request )
-        throws MavenExecutionRequestPopulationException
-    {
-        Set<String> definedRepositories = repositorySystem.getRepoIds( request.getPluginArtifactRepositories()
);
-
-        if ( !definedRepositories.contains( RepositorySystem.DEFAULT_REMOTE_REPO_ID ) )
-        {
-            try
-            {
-                request.addPluginArtifactRepository( repositorySystem.createDefaultRemoteRepository(
request ) );
-            }
-            catch ( Exception e )
-            {
-                throw new MavenExecutionRequestPopulationException( "Cannot create default
remote repository.", e );
-            }
-        }
-    }
-
     private void localRepository( MavenExecutionRequest request )
         throws MavenExecutionRequestPopulationException
     {
@@ -206,10 +159,10 @@ public class DefaultMavenExecutionRequestPopulator
         {
             request.setBaseDirectory( request.getPom().getAbsoluteFile().getParentFile()
);
         }
-    }   
-    
+    }
+
     /*if_not[MAVEN4]*/
-    
+
     @Override
     @Deprecated
     public MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings
settings )
@@ -311,8 +264,8 @@ public class DefaultMavenExecutionRequestPopulator
         }
 
         return request;
-    }    
-    
+    }
+
     /*end[MAVEN4]*/
 
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/15a9c32f/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java b/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java
index fcc0f77..5766b98 100644
--- a/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java
+++ b/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java
@@ -50,8 +50,18 @@ public interface RepositorySystem
 
     File defaultUserLocalRepository = new File( userMavenConfigurationHome, "repository"
);
 
+    /**
+     * @deprecation As of 3.4, Maven no longer falls back to a hard-coded default repository
with identifier
+     * {@code central} if such a repository is not provided in the settings or the POM.
+     */
+    @Deprecated
     String DEFAULT_REMOTE_REPO_ID = "central";
 
+    /**
+     * @deprecation As of 3.4, Maven no longer falls back to a hard-coded default repository
with identifier
+     * {@code central} if such a repository is not provided in the settings or the POM.
+     */
+    @Deprecated
     String DEFAULT_REMOTE_REPO_URL = "https://repo.maven.apache.org/maven2";
 
     Artifact createArtifact( String groupId, String artifactId, String version, String packaging
);
@@ -70,6 +80,11 @@ public interface RepositorySystem
     ArtifactRepository buildArtifactRepository( Repository repository )
         throws InvalidRepositoryException;
 
+    /**
+     * @deprecation As of 3.4, Maven no longer falls back to a hard-coded default repository
with identifier
+     * {@code central} if such a repository is not provided in the settings or the POM.
+     */
+    @Deprecated
     ArtifactRepository createDefaultRemoteRepository()
         throws InvalidRepositoryException;
 

http://git-wip-us.apache.org/repos/asf/maven/blob/15a9c32f/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
b/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
index 71616fa..7db65d8 100644
--- a/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
+++ b/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
@@ -23,7 +23,10 @@ import java.net.URL;
 import java.util.Arrays;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
 import org.apache.maven.model.building.ModelBuildingException;
 import org.apache.maven.model.building.ModelProblem;
 import org.apache.maven.repository.RepositorySystem;
@@ -172,9 +175,17 @@ public abstract class AbstractMavenProjectTestCase
     protected MavenProject getProjectFromRemoteRepository( final File pom )
         throws Exception
     {
+        final ArtifactRepository testRepository =
+            new MavenArtifactRepository( "test",
+                                         "file://" + new File( System.getProperty( "basedir",
"" ),
+                                                               "src/test/remote-repo" ).toURI().getPath(),
+                                         new DefaultRepositoryLayout(),
+                                         new ArtifactRepositoryPolicy(),
+                                         new ArtifactRepositoryPolicy() );
+
         final ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
         configuration.setLocalRepository( this.getLocalRepository() );
-        configuration.setRemoteRepositories( Arrays.asList( this.repositorySystem.createDefaultRemoteRepository()
) );
+        configuration.setRemoteRepositories( Arrays.asList( testRepository ) );
         initRepoSession( configuration );
 
         return projectBuilder.build( pom, configuration ).getProject();

http://git-wip-us.apache.org/repos/asf/maven/blob/15a9c32f/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java
b/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java
index 6b103b2..dde864a 100644
--- a/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java
+++ b/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java
@@ -19,11 +19,15 @@ package org.apache.maven.project.artifact;
  * under the License.
  */
 
+import java.io.File;
 import java.util.Arrays;
 import java.util.Collections;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
 import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
 import org.apache.maven.project.artifact.DefaultMavenMetadataCache.CacheKey;
 import org.apache.maven.repository.DelegatingLocalArtifactRepository;
@@ -53,19 +57,36 @@ public class DefaultMavenMetadataCacheTest
         super.tearDown();
     }
 
+    @SuppressWarnings( "deprecation" )
     public void testCacheKey()
         throws Exception
     {
         Artifact a1 = repositorySystem.createArtifact( "testGroup", "testArtifact", "1.2.3",
"jar" );
-        @SuppressWarnings( "deprecation" )
-        ArtifactRepository lr1 = new DelegatingLocalArtifactRepository( repositorySystem.createDefaultLocalRepository()
);
-        ArtifactRepository rr1 = repositorySystem.createDefaultRemoteRepository();
+        ArtifactRepository lr1 =
+            new DelegatingLocalArtifactRepository( repositorySystem.createDefaultLocalRepository()
);
+
+        ArtifactRepository rr1 = new MavenArtifactRepository( "test",
+                                                              "file://" + new File( System.getProperty(
"basedir", "" ),
+                                                                                    "src/test/remote-repo"
).toURI().
+                                                              getPath(),
+                                                              new DefaultRepositoryLayout(),
+                                                              new ArtifactRepositoryPolicy(),
+                                                              new ArtifactRepositoryPolicy()
);
+
         a1.setDependencyFilter( new ExcludesArtifactFilter( Arrays.asList( "foo" ) ) );
 
         Artifact a2 = repositorySystem.createArtifact( "testGroup", "testArtifact", "1.2.3",
"jar" );
-        @SuppressWarnings( "deprecation" )
-        ArtifactRepository lr2 = new DelegatingLocalArtifactRepository( repositorySystem.createDefaultLocalRepository()
);
-        ArtifactRepository rr2 = repositorySystem.createDefaultRemoteRepository();
+        ArtifactRepository lr2 =
+            new DelegatingLocalArtifactRepository( repositorySystem.createDefaultLocalRepository()
);
+
+        ArtifactRepository rr2 = new MavenArtifactRepository( "test",
+                                                              "file://" + new File( System.getProperty(
"basedir", "" ),
+                                                                                    "src/test/remote-repo"
).toURI().
+                                                              getPath(),
+                                                              new DefaultRepositoryLayout(),
+                                                              new ArtifactRepositoryPolicy(),
+                                                              new ArtifactRepositoryPolicy()
);
+
         a2.setDependencyFilter( new ExcludesArtifactFilter( Arrays.asList( "foo" ) ) );
 
         // sanity checks
@@ -76,6 +97,7 @@ public class DefaultMavenMetadataCacheTest
         CacheKey k1 = new CacheKey( a1, false, lr1, Collections.singletonList( rr1 ) );
         CacheKey k2 = new CacheKey( a2, false, lr2, Collections.singletonList( rr2 ) );
 
-        assertEquals(k1.hashCode(), k2.hashCode());
+        assertEquals( k1.hashCode(), k2.hashCode() );
     }
+
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/15a9c32f/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java
b/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java
index 0e054c6..5a76b26 100644
--- a/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java
+++ b/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java
@@ -106,13 +106,15 @@ public class TestRepositorySystem
         return createLocalRepository( new File( System.getProperty( "basedir", "" ), "target/local-repo"
).getAbsoluteFile() );
     }
 
+    /**
+     * @deprecation As of 3.4, Maven no longer falls back to a hard-coded default repository
with identifier
+     * {@code central} if such a repository is not provided in the settings or the POM.
+     */
+    @Deprecated
     public ArtifactRepository createDefaultRemoteRepository()
         throws InvalidRepositoryException
     {
-        return new MavenArtifactRepository( DEFAULT_REMOTE_REPO_ID, "file://"
-            + new File( System.getProperty( "basedir", "" ), "src/test/remote-repo" ).toURI().getPath(),
-                                            new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(),
-                                            new ArtifactRepositoryPolicy() );
+        throw new UnsupportedOperationException();
     }
 
     public Artifact createDependencyArtifact( Dependency dependency )


Mime
View raw message