Author: brett
Date: Thu May 5 00:16:07 2005
New Revision: 168292
URL: http://svn.apache.org/viewcvs?rev=168292&view=rev
Log:
PR: MNG-145
Implement and document repository download mirrors
Modified:
maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/WagonManager.java
maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/MavenSettingsBuilder.java
maven/components/trunk/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
maven/components/trunk/maven-site/src/site/xdoc/configuration.xml
Modified:
maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java?rev=168292&r1=168291&r2=168292&view=diff
==============================================================================
---
maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
(original)
+++
maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
Thu May 5 00:16:07 2005
@@ -33,6 +33,7 @@
import org.apache.maven.wagon.events.TransferListener;
import org.apache.maven.wagon.observers.ChecksumObserver;
import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.repository.Repository;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import
org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
@@ -57,11 +58,14 @@
{
private PlexusContainer container;
- // TODO: proxies and authentication are via settings, and should come in
via an alternate method - perhaps attached to ArtifactRepository before the
method is called (so AR would be composed of WR, not inherit it)
+ // TODO: proxies, authentication and mirrors are via settings, and should
come in via an alternate method - perhaps
+ // attached to ArtifactRepository before the method is called (so AR would
be composed of WR, not inherit it)
private Map proxies = new HashMap();
private Map authenticationInfoMap = new HashMap();
+ private Map mirrors = new HashMap();
+
private TransferListener downloadMonitor;
private ArtifactHandlerManager artifactHandlerManager;
@@ -115,10 +119,12 @@
TransferListener downloadMonitor )
throws TransferFailedException
{
+ String protocol = repository.getProtocol();
+
Wagon wagon = null;
try
{
- wagon = getWagon( repository.getProtocol() );
+ wagon = getWagon( protocol );
}
catch ( UnsupportedProtocolException e )
{
@@ -149,8 +155,7 @@
try
{
- wagon.connect( repository, getAuthenticationInfo(
repository.getId() ),
- getProxy( repository.getProtocol() ) );
+ wagon.connect( repository, getAuthenticationInfo(
repository.getId() ), getProxy( protocol ) );
wagon.put( source, remotePath );
@@ -271,9 +276,10 @@
Wagon wagon;
+ String protocol = repository.getProtocol();
try
{
- wagon = getWagon( repository.getProtocol() );
+ wagon = getWagon( protocol );
}
catch ( UnsupportedProtocolException e )
{
@@ -308,8 +314,13 @@
try
{
- wagon.connect( repository, getAuthenticationInfo(
repository.getId() ),
- getProxy( repository.getProtocol() ) );
+ Repository mirror = getMirror( repository.getId() );
+ if ( mirror != null )
+ {
+ repository = repository.createMirror( mirror );
+ }
+
+ wagon.connect( repository, getAuthenticationInfo(
repository.getId() ), getProxy( protocol ) );
wagon.get( remotePath, temp );
@@ -421,6 +432,11 @@
return (AuthenticationInfo) authenticationInfoMap.get( id );
}
+ private Repository getMirror( String mirrorOf )
+ {
+ return (Repository) mirrors.get( mirrorOf );
+ }
+
/**
* Set the proxy used for a particular protocol.
*
@@ -475,5 +491,12 @@
authInfo.setPassphrase( passphrase );
authenticationInfoMap.put( repositoryId, authInfo );
+ }
+
+ public void addMirror( String id, String mirrorOf, String url )
+ {
+ Repository mirror = new Repository( id, url );
+
+ mirrors.put( mirrorOf, mirror );
}
}
Modified:
maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/WagonManager.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/WagonManager.java?rev=168292&r1=168291&r2=168292&view=diff
==============================================================================
---
maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/WagonManager.java
(original)
+++
maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/WagonManager.java
Thu May 5 00:16:07 2005
@@ -59,5 +59,7 @@
void addAuthenticationInfo( String repositoryId, String username, String
password, String privateKey,
String passphrase );
+ void addMirror( String id, String mirrorOf, String url );
+
void setDownloadMonitor( TransferListener downloadMonitor );
}
Modified:
maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java?rev=168292&r1=168291&r2=168292&view=diff
==============================================================================
---
maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java
(original)
+++
maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java
Thu May 5 00:16:07 2005
@@ -75,4 +75,9 @@
{
return snapshotPolicy;
}
+
+ public ArtifactRepository createMirror( Repository mirror )
+ {
+ return new ArtifactRepository( mirror.getId(), mirror.getUrl(),
layout, snapshotPolicy );
+ }
}
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=168292&r1=168291&r2=168292&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
Thu May 5 00:16:07 2005
@@ -36,6 +36,7 @@
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Server;
import org.apache.maven.settings.Settings;
+import org.apache.maven.settings.Mirror;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@@ -87,6 +88,15 @@
getLogger().info( "Maven is running in offline mode." );
}
+ try
+ {
+ resolveParameters( request.getSettings() );
+ }
+ catch ( ComponentLookupException e )
+ {
+ throw new ReactorException( "Unable to configure Maven for
execution", e );
+ }
+
EventDispatcher dispatcher = request.getEventDispatcher();
String event = MavenEvents.REACTOR_EXECUTION;
@@ -200,15 +210,6 @@
MavenSession session = createSession( request, project );
- try
- {
- resolveParameters( request );
- }
- catch ( ComponentLookupException e )
- {
- throw new LifecycleExecutionException( "Unable to configure Maven
for execution", e );
- }
-
// !! This is ripe for refactoring to an aspect.
// Event monitoring.
String event = MavenEvents.PROJECT_EXECUTION;
@@ -304,13 +305,11 @@
* @todo [JC] we should at least provide a mapping of protocol-to-proxy for
* the wagons, shouldn't we?
*/
- private void resolveParameters( MavenExecutionRequest request )
+ private void resolveParameters( Settings settings )
throws ComponentLookupException
{
WagonManager wagonManager = (WagonManager) container.lookup(
WagonManager.ROLE );
- Settings settings = request.getSettings();
-
Proxy proxy = settings.getActiveProxy();
if ( proxy != null )
@@ -325,6 +324,13 @@
wagonManager.addAuthenticationInfo( server.getId(),
server.getUsername(), server.getPassword(),
server.getPrivateKey(),
server.getPassphrase() );
+ }
+
+ for ( Iterator i = settings.getMirrors().iterator(); i.hasNext(); )
+ {
+ Mirror mirror = (Mirror) i.next();
+
+ wagonManager.addMirror( mirror.getId(), mirror.getMirrorOf(),
mirror.getUrl() );
}
}
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/MavenSettingsBuilder.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/MavenSettingsBuilder.java?rev=168292&r1=168291&r2=168292&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/MavenSettingsBuilder.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/MavenSettingsBuilder.java
Thu May 5 00:16:07 2005
@@ -1,9 +1,5 @@
package org.apache.maven.settings;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-import java.io.IOException;
-
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
@@ -19,6 +15,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.IOException;
/**
* @author jdcasey
Modified:
maven/components/trunk/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml?rev=168292&r1=168291&r2=168292&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
(original)
+++
maven/components/trunk/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
Thu May 5 00:16:07 2005
@@ -13,7 +13,7 @@
<pluginRepositories>
<pluginRepository>
- <id>plugin-central</id>
+ <id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
Modified: maven/components/trunk/maven-site/src/site/xdoc/configuration.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-site/src/site/xdoc/configuration.xml?rev=168292&r1=168291&r2=168292&view=diff
==============================================================================
--- maven/components/trunk/maven-site/src/site/xdoc/configuration.xml (original)
+++ maven/components/trunk/maven-site/src/site/xdoc/configuration.xml Thu May
5 00:16:07 2005
@@ -93,7 +93,7 @@
.
.]]></source>
<p style="font-weight: bold; font-size: larger">
- Deployment Settings
+ Security and Deployment Settings
</p>
<p>
Repositories to deploy to are defined in a project in the
<code><distributionManagement></code> section.
@@ -102,6 +102,10 @@
deployment repository in the project.
</p>
<p>
+ In addition, some repositories may require authorisation to download
from, so the corresponding settings can
+ be specified in a <code>server</code> element in the same way.
+ </p>
+ <p>
Which settings are required will depend on the type of repository you
are deploying to. As of the first release,
only SCP deployments and file deployments are supported by default, so
only the following SCP configuration
is needed:
@@ -123,6 +127,47 @@
</servers>
.
.]]></source>
+ <p style="font-weight: bold; font-size: larger">
+ Using Mirrors for Repositories
+ </p>
+ <p>
+ Repositories are declared inside a project, which means that if you
have your own custom repositories, those
+ sharing your project easily get the right settings out of the box.
However, you may want to use an alternative
+ mirror for a particular repository without changing the project files.
+ </p>
+ <p>
+ Some reasons to use a mirror are:
+ </p>
+ <ul>
+ <li>There is a synchronized mirror on the internet that is
geographically closer and faster</li>
+ <li>You want to replace a particular repository with your own internal
repository which you have greater
+ control over</li>
+ <li>You want to run maven-proxy to provide a local cache to a mirror
and need to use it's URL instead</li>
+ </ul>
+ <p>
+ To configure a mirror of a given repository, you provide it in your
settings file, giving the new repository
+ it's own <code>id</code> and <code>url</code>, and specify the
<code>mirrorOf</code> setting that is the ID of
+ the repository you are using a mirror of. For example, the ID of the
main Maven repository included by default is
+ <code>central</code>, so to use an Australian mirror, you would
configure the following:
+ </p>
+ <source><![CDATA[
+<settings>
+ .
+ .
+ <mirrors>
+ <mirror>
+ <id>planetmirror</id>
+ <name>Australian Mirror of http://repo1.maven.org/maven2/</name>
+ <url>http://public.planetmirror.com/maven2/</url>
+ <mirrorOf>central</mirrorOf>
+ </mirror>
+ </mirrors>
+ .
+ .]]></source>
+ <p>
+ <i>Please note:</i> this particular is not actually set up for Maven 2
yet, so this should be treated as an
+ example only.
+ </p>
</section>
</body>
</document>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]