mirror of
https://github.com/apache/archiva.git
synced 2025-02-08 11:06:03 +00:00
avoid using plexus-sisu bridge to get wagon instances: use now spring
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1235559 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5eed5ccf55
commit
37382ef788
@ -57,6 +57,11 @@
|
|||||||
<groupId>org.codehaus.plexus</groupId>
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
<artifactId>plexus-i18n</artifactId>
|
<artifactId>plexus-i18n</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
|
<artifactId>wagon-http</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-simple</artifactId>
|
<artifactId>slf4j-simple</artifactId>
|
||||||
|
@ -36,6 +36,11 @@
|
|||||||
<groupId>org.apache.maven.wagon</groupId>
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
<artifactId>wagon-provider-api</artifactId>
|
<artifactId>wagon-provider-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
|
<artifactId>wagon-http</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.wagon</groupId>
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
<artifactId>wagon-file</artifactId>
|
<artifactId>wagon-file</artifactId>
|
||||||
@ -79,6 +84,8 @@
|
|||||||
org.apache.archiva.common.plexusbridge;version=${project.version},
|
org.apache.archiva.common.plexusbridge;version=${project.version},
|
||||||
org.apache.commons.lang;version="[2.4,3)",
|
org.apache.commons.lang;version="[2.4,3)",
|
||||||
org.springframework.stereotype;version="[3,4)",
|
org.springframework.stereotype;version="[3,4)",
|
||||||
|
org.springframework.context;version="[3,4)",
|
||||||
|
org.springframework.beans;version="[3,4)",
|
||||||
org.apache.maven.wagon*,
|
org.apache.maven.wagon*,
|
||||||
org.slf4j;resolution:=optional
|
org.slf4j;resolution:=optional
|
||||||
</Import-Package>
|
</Import-Package>
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
|
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.maven.wagon.Wagon;
|
import org.apache.maven.wagon.Wagon;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -38,12 +40,15 @@ public class DefaultWagonFactory
|
|||||||
|
|
||||||
private PlexusSisuBridge plexusSisuBridge;
|
private PlexusSisuBridge plexusSisuBridge;
|
||||||
|
|
||||||
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
private DebugTransferListener debugTransferListener = new DebugTransferListener();
|
private DebugTransferListener debugTransferListener = new DebugTransferListener();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DefaultWagonFactory( PlexusSisuBridge plexusSisuBridge )
|
public DefaultWagonFactory( PlexusSisuBridge plexusSisuBridge, ApplicationContext applicationContext )
|
||||||
{
|
{
|
||||||
this.plexusSisuBridge = plexusSisuBridge;
|
this.plexusSisuBridge = plexusSisuBridge;
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Wagon getWagon( String protocol )
|
public Wagon getWagon( String protocol )
|
||||||
@ -53,12 +58,17 @@ public Wagon getWagon( String protocol )
|
|||||||
{
|
{
|
||||||
// with sisu inject bridge hint is file or http
|
// with sisu inject bridge hint is file or http
|
||||||
// so remove wagon#
|
// so remove wagon#
|
||||||
protocol = StringUtils.remove( protocol, "wagon#" );
|
//protocol = StringUtils.remove( protocol, "wagon#" );
|
||||||
Wagon wagon = plexusSisuBridge.lookup( Wagon.class, protocol );
|
// spring beans will be named wagon#protocol (http, https, file )
|
||||||
|
protocol = StringUtils.startsWith( protocol, "wagon#" ) ? protocol : "wagon#" + protocol;
|
||||||
|
//Wagon wagon = plexusSisuBridge.lookup( Wagon.class, protocol );
|
||||||
|
|
||||||
|
Wagon wagon = applicationContext.getBean( protocol, Wagon.class );
|
||||||
wagon.addTransferListener( debugTransferListener );
|
wagon.addTransferListener( debugTransferListener );
|
||||||
return wagon;
|
return wagon;
|
||||||
}
|
}
|
||||||
catch ( PlexusSisuBridgeException e )
|
//catch ( PlexusSisuBridgeException e )
|
||||||
|
catch ( BeansException e )
|
||||||
{
|
{
|
||||||
throw new WagonFactoryException( e.getMessage(), e );
|
throw new WagonFactoryException( e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
@ -30,5 +30,8 @@
|
|||||||
<context:annotation-config/>
|
<context:annotation-config/>
|
||||||
<context:component-scan base-package="org.apache.archiva.proxy.common"/>
|
<context:component-scan base-package="org.apache.archiva.proxy.common"/>
|
||||||
|
|
||||||
|
<bean name="wagon#http" scope="prototype" class="org.apache.maven.wagon.providers.http.HttpWagon"/>
|
||||||
|
|
||||||
|
<bean name="wagon#https" scope="prototype" class="org.apache.maven.wagon.providers.http.HttpWagon"/>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@ -27,4 +27,6 @@
|
|||||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
|
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
|
||||||
default-lazy-init="true">
|
default-lazy-init="true">
|
||||||
|
|
||||||
|
<bean name="wagon#file" scope="prototype" class="org.apache.maven.wagon.providers.file.FileWagon"/>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@ -73,6 +73,11 @@
|
|||||||
<groupId>org.apache.archiva</groupId>
|
<groupId>org.apache.archiva</groupId>
|
||||||
<artifactId>archiva-plexus-bridge</artifactId>
|
<artifactId>archiva-plexus-bridge</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
|
<artifactId>wagon-http</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.wagon</groupId>
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
<artifactId>wagon-file</artifactId>
|
<artifactId>wagon-file</artifactId>
|
||||||
|
@ -1042,8 +1042,8 @@ private boolean connectToRepository( ProxyConnector connector, Wagon wagon,
|
|||||||
{
|
{
|
||||||
boolean connected = false;
|
boolean connected = false;
|
||||||
|
|
||||||
final ProxyInfo networkProxy = this.networkProxyMap.get( connector.getProxyId() );
|
final ProxyInfo networkProxy =
|
||||||
|
connector.getProxyId() == null ? null : this.networkProxyMap.get( connector.getProxyId() );
|
||||||
|
|
||||||
if ( log.isDebugEnabled() )
|
if ( log.isDebugEnabled() )
|
||||||
{
|
{
|
||||||
|
@ -135,7 +135,7 @@ public abstract class AbstractProxyTestCase
|
|||||||
protected ManagedRepositoryAdmin managedRepositoryAdmin;
|
protected ManagedRepositoryAdmin managedRepositoryAdmin;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
PlexusSisuBridge plexusSisuBridge;
|
protected PlexusSisuBridge plexusSisuBridge;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp()
|
public void setUp()
|
||||||
@ -208,7 +208,7 @@ public void setUp()
|
|||||||
wagonMockControl = MockControl.createNiceControl( Wagon.class );
|
wagonMockControl = MockControl.createNiceControl( Wagon.class );
|
||||||
wagonMock = (Wagon) wagonMockControl.getMock();
|
wagonMock = (Wagon) wagonMockControl.getMock();
|
||||||
|
|
||||||
delegate = (WagonDelegate) plexusSisuBridge.lookup( Wagon.class, "test" );
|
delegate = (WagonDelegate) applicationContext.getBean( "wagon#test", Wagon.class );
|
||||||
|
|
||||||
delegate.setDelegate( wagonMock );
|
delegate.setDelegate( wagonMock );
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ public void setUp()
|
|||||||
public void shutdown()
|
public void shutdown()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
removeMavenIndexes();
|
removeMavenIndexes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,10 +19,6 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.maven.wagon.ConnectionException;
|
import org.apache.maven.wagon.ConnectionException;
|
||||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||||
@ -40,16 +36,21 @@
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A dummy wagon implementation
|
* A dummy wagon implementation
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Service("wagon#test")
|
@Service( "wagon#test" )
|
||||||
public class WagonDelegate
|
public class WagonDelegate
|
||||||
implements Wagon
|
implements Wagon
|
||||||
{
|
{
|
||||||
private Logger log = LoggerFactory.getLogger( WagonDelegate.class );
|
private Logger log = LoggerFactory.getLogger( WagonDelegate.class );
|
||||||
|
|
||||||
private Wagon delegate;
|
private Wagon delegate;
|
||||||
|
|
||||||
private String contentToGet;
|
private String contentToGet;
|
||||||
@ -90,7 +91,7 @@ public boolean resourceExists( String resourceName )
|
|||||||
return delegate.resourceExists( resourceName );
|
return delegate.resourceExists( resourceName );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings( "unchecked" )
|
||||||
public List<String> getFileList( String destinationDirectory )
|
public List<String> getFileList( String destinationDirectory )
|
||||||
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
|
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
|
||||||
{
|
{
|
||||||
@ -102,15 +103,15 @@ public boolean supportsDirectoryCopy()
|
|||||||
return delegate.supportsDirectoryCopy();
|
return delegate.supportsDirectoryCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTimeout(int val)
|
public void setTimeout( int val )
|
||||||
{
|
{
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTimeout()
|
public int getTimeout()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Repository getRepository()
|
public Repository getRepository()
|
||||||
{
|
{
|
||||||
@ -153,7 +154,7 @@ public void connect( Repository source, AuthenticationInfo authenticationInfo, P
|
|||||||
delegate.connect( source, authenticationInfo, proxyInfoProvider );
|
delegate.connect( source, authenticationInfo, proxyInfoProvider );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings( "deprecation" )
|
||||||
public void openConnection()
|
public void openConnection()
|
||||||
throws ConnectionException, AuthenticationException
|
throws ConnectionException, AuthenticationException
|
||||||
{
|
{
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
<!--
|
|
||||||
~ Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
~ or more contributor license agreements. See the NOTICE file
|
|
||||||
~ distributed with this work for additional information
|
|
||||||
~ regarding copyright ownership. The ASF licenses this file
|
|
||||||
~ to you under the Apache License, Version 2.0 (the
|
|
||||||
~ "License"); you may not use this file except in compliance
|
|
||||||
~ with the License. You may obtain a copy of the License at
|
|
||||||
~
|
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
~
|
|
||||||
~ Unless required by applicable law or agreed to in writing,
|
|
||||||
~ software distributed under the License is distributed on an
|
|
||||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
~ KIND, either express or implied. See the License for the
|
|
||||||
~ specific language governing permissions and limitations
|
|
||||||
~ under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<component-set>
|
|
||||||
<components>
|
|
||||||
<component>
|
|
||||||
<role>org.apache.maven.wagon.Wagon</role>
|
|
||||||
<role-hint>test</role-hint>
|
|
||||||
<implementation>org.apache.archiva.proxy.WagonDelegate</implementation>
|
|
||||||
</component>
|
|
||||||
</components>
|
|
||||||
</component-set>
|
|
@ -27,4 +27,6 @@
|
|||||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
|
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
|
||||||
default-lazy-init="true">
|
default-lazy-init="true">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@ -80,5 +80,7 @@
|
|||||||
<property name="timeToLiveSeconds" value="1800"/>
|
<property name="timeToLiveSeconds" value="1800"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean name="wagon#test" class="org.apache.archiva.proxy.WagonDelegate" scope="singleton"/>
|
||||||
|
<bean name="wagon#file" scope="prototype" class="org.apache.maven.wagon.providers.file.FileWagon"/>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@ -75,6 +75,11 @@
|
|||||||
<groupId>org.apache.archiva</groupId>
|
<groupId>org.apache.archiva</groupId>
|
||||||
<artifactId>maven2-repository</artifactId>
|
<artifactId>maven2-repository</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
|
<artifactId>wagon-http</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -130,7 +130,6 @@ public void run()
|
|||||||
final Wagon wagon = wagonFactory.getWagon( new URL( this.remoteRepository.getUrl() ).getProtocol() );
|
final Wagon wagon = wagonFactory.getWagon( new URL( this.remoteRepository.getUrl() ).getProtocol() );
|
||||||
setupWagonReadTimeout( wagon );
|
setupWagonReadTimeout( wagon );
|
||||||
|
|
||||||
// TODO transferListener
|
|
||||||
wagon.addTransferListener( new DownloadListener() );
|
wagon.addTransferListener( new DownloadListener() );
|
||||||
ProxyInfo proxyInfo = null;
|
ProxyInfo proxyInfo = null;
|
||||||
if ( this.networkProxy != null )
|
if ( this.networkProxy != null )
|
||||||
|
@ -62,6 +62,11 @@
|
|||||||
<groupId>org.apache.archiva</groupId>
|
<groupId>org.apache.archiva</groupId>
|
||||||
<artifactId>archiva-repository-scanner</artifactId>
|
<artifactId>archiva-repository-scanner</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
|
<artifactId>wagon-http</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.archiva</groupId>
|
<groupId>org.apache.archiva</groupId>
|
||||||
<artifactId>archiva-repository-layer</artifactId>
|
<artifactId>archiva-repository-layer</artifactId>
|
||||||
|
@ -99,6 +99,11 @@
|
|||||||
<groupId>org.apache.maven.wagon</groupId>
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
<artifactId>wagon-provider-api</artifactId>
|
<artifactId>wagon-provider-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
|
<artifactId>wagon-http</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-test</artifactId>
|
<artifactId>spring-test</artifactId>
|
||||||
|
@ -19,20 +19,15 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
|
|
||||||
import org.apache.archiva.proxy.common.WagonFactory;
|
|
||||||
import org.apache.archiva.proxy.common.WagonFactoryException;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.archiva.common.utils.VersionUtil;
|
import org.apache.archiva.common.utils.VersionUtil;
|
||||||
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
|
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
|
||||||
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
|
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
|
||||||
|
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
|
||||||
|
import org.apache.archiva.proxy.common.WagonFactory;
|
||||||
|
import org.apache.archiva.proxy.common.WagonFactoryException;
|
||||||
import org.apache.archiva.xml.XMLException;
|
import org.apache.archiva.xml.XMLException;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.maven.model.Repository;
|
import org.apache.maven.model.Repository;
|
||||||
import org.apache.maven.model.building.FileModelSource;
|
import org.apache.maven.model.building.FileModelSource;
|
||||||
import org.apache.maven.model.building.ModelSource;
|
import org.apache.maven.model.building.ModelSource;
|
||||||
@ -50,6 +45,11 @@
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class RepositoryModelResolver
|
public class RepositoryModelResolver
|
||||||
implements ModelResolver
|
implements ModelResolver
|
||||||
{
|
{
|
||||||
@ -77,9 +77,10 @@ public RepositoryModelResolver( File basedir, RepositoryPathTranslator pathTrans
|
|||||||
this.pathTranslator = pathTranslator;
|
this.pathTranslator = pathTranslator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RepositoryModelResolver( File basedir, RepositoryPathTranslator pathTranslator,
|
public RepositoryModelResolver( File basedir, RepositoryPathTranslator pathTranslator, WagonFactory wagonFactory,
|
||||||
WagonFactory wagonFactory, List<RemoteRepositoryConfiguration> remoteRepositories,
|
List<RemoteRepositoryConfiguration> remoteRepositories,
|
||||||
Map<String, ProxyInfo> networkProxiesMap, ManagedRepositoryConfiguration targetRepository )
|
Map<String, ProxyInfo> networkProxiesMap,
|
||||||
|
ManagedRepositoryConfiguration targetRepository )
|
||||||
{
|
{
|
||||||
this( basedir, pathTranslator );
|
this( basedir, pathTranslator );
|
||||||
|
|
||||||
@ -100,24 +101,25 @@ public ModelSource resolveModel( String groupId, String artifactId, String versi
|
|||||||
|
|
||||||
File model = pathTranslator.toFile( basedir, groupId, artifactId, version, filename );
|
File model = pathTranslator.toFile( basedir, groupId, artifactId, version, filename );
|
||||||
|
|
||||||
if( !model.exists() )
|
if ( !model.exists() )
|
||||||
{
|
{
|
||||||
for( RemoteRepositoryConfiguration remoteRepository : remoteRepositories )
|
for ( RemoteRepositoryConfiguration remoteRepository : remoteRepositories )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boolean success = getModelFromProxy( remoteRepository, groupId, artifactId, version, filename );
|
boolean success = getModelFromProxy( remoteRepository, groupId, artifactId, version, filename );
|
||||||
if( success && model.exists() )
|
if ( success && model.exists() )
|
||||||
{
|
{
|
||||||
log.info( "Model '" + model.getAbsolutePath() + "' successfully retrieved from remote repository '"
|
log.info(
|
||||||
+ remoteRepository.getId() + "'" );
|
"Model '" + model.getAbsolutePath() + "' successfully retrieved from remote repository '"
|
||||||
|
+ remoteRepository.getId() + "'" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
log.warn( "An exception was caught while attempting to retrieve model '" + model.getAbsolutePath()
|
log.warn( "An exception was caught while attempting to retrieve model '" + model.getAbsolutePath()
|
||||||
+ "' from remote repository '" + remoteRepository.getId() + "'.", e );
|
+ "' from remote repository '" + remoteRepository.getId() + "'.", e );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,7 +144,7 @@ public ModelResolver newCopy()
|
|||||||
// FIXME: we need to do some refactoring, we cannot re-use the proxy components of archiva-proxy in maven2-repository
|
// FIXME: we need to do some refactoring, we cannot re-use the proxy components of archiva-proxy in maven2-repository
|
||||||
// because it's causing a cyclic dependency
|
// because it's causing a cyclic dependency
|
||||||
private boolean getModelFromProxy( RemoteRepositoryConfiguration remoteRepository, String groupId,
|
private boolean getModelFromProxy( RemoteRepositoryConfiguration remoteRepository, String groupId,
|
||||||
String artifactId, String version, String filename )
|
String artifactId, String version, String filename )
|
||||||
throws AuthorizationException, TransferFailedException, ResourceDoesNotExistException, WagonFactoryException,
|
throws AuthorizationException, TransferFailedException, ResourceDoesNotExistException, WagonFactoryException,
|
||||||
XMLException
|
XMLException
|
||||||
{
|
{
|
||||||
@ -177,7 +179,8 @@ private boolean getModelFromProxy( RemoteRepositoryConfiguration remoteRepositor
|
|||||||
// get the metadata first!
|
// get the metadata first!
|
||||||
File tmpMetadataResource = new File( workingDirectory, METADATA_FILENAME );
|
File tmpMetadataResource = new File( workingDirectory, METADATA_FILENAME );
|
||||||
|
|
||||||
String metadataPath = StringUtils.substringBeforeLast( artifactPath, "/" ) + "/" + METADATA_FILENAME;
|
String metadataPath =
|
||||||
|
StringUtils.substringBeforeLast( artifactPath, "/" ) + "/" + METADATA_FILENAME;
|
||||||
|
|
||||||
wagon.get( metadataPath, tmpMetadataResource );
|
wagon.get( metadataPath, tmpMetadataResource );
|
||||||
|
|
||||||
@ -190,10 +193,10 @@ private boolean getModelFromProxy( RemoteRepositoryConfiguration remoteRepositor
|
|||||||
String timestampVersion = version;
|
String timestampVersion = version;
|
||||||
if ( snapshotVersion != null )
|
if ( snapshotVersion != null )
|
||||||
{
|
{
|
||||||
timestampVersion =
|
timestampVersion = timestampVersion.substring( 0, timestampVersion.length()
|
||||||
timestampVersion.substring( 0, timestampVersion.length() - 8 ); // remove SNAPSHOT from end
|
- 8 ); // remove SNAPSHOT from end
|
||||||
timestampVersion =
|
timestampVersion = timestampVersion + snapshotVersion.getTimestamp() + "-"
|
||||||
timestampVersion + snapshotVersion.getTimestamp() + "-" + snapshotVersion.getBuildNumber();
|
+ snapshotVersion.getBuildNumber();
|
||||||
|
|
||||||
filename = artifactId + "-" + timestampVersion + ".pom";
|
filename = artifactId + "-" + timestampVersion + ".pom";
|
||||||
|
|
||||||
@ -209,10 +212,10 @@ private boolean getModelFromProxy( RemoteRepositoryConfiguration remoteRepositor
|
|||||||
|
|
||||||
log.debug( "Downloaded successfully." );
|
log.debug( "Downloaded successfully." );
|
||||||
|
|
||||||
tmpSha1 =
|
tmpSha1 = transferChecksum( wagon, remoteRepository, artifactPath, tmpResource, workingDirectory,
|
||||||
transferChecksum( wagon, remoteRepository, artifactPath, tmpResource, workingDirectory, ".sha1" );
|
".sha1" );
|
||||||
tmpMd5 =
|
tmpMd5 = transferChecksum( wagon, remoteRepository, artifactPath, tmpResource, workingDirectory,
|
||||||
transferChecksum( wagon, remoteRepository, artifactPath, tmpResource, workingDirectory, ".md5" );
|
".md5" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@ -267,9 +270,8 @@ private boolean connectToRepository( Wagon wagon, RemoteRepositoryConfiguration
|
|||||||
|
|
||||||
if ( networkProxy != null )
|
if ( networkProxy != null )
|
||||||
{
|
{
|
||||||
String msg =
|
String msg = "Using network proxy " + networkProxy.getHost() + ":" + networkProxy.getPort()
|
||||||
"Using network proxy " + networkProxy.getHost() + ":" + networkProxy.getPort()
|
+ " to connect to remote repository " + remoteRepository.getUrl();
|
||||||
+ " to connect to remote repository " + remoteRepository.getUrl();
|
|
||||||
if ( networkProxy.getNonProxyHosts() != null )
|
if ( networkProxy.getNonProxyHosts() != null )
|
||||||
{
|
{
|
||||||
msg += "; excluding hosts: " + networkProxy.getNonProxyHosts();
|
msg += "; excluding hosts: " + networkProxy.getNonProxyHosts();
|
||||||
@ -289,7 +291,7 @@ private boolean connectToRepository( Wagon wagon, RemoteRepositoryConfiguration
|
|||||||
|
|
||||||
if ( StringUtils.isNotBlank( username ) && StringUtils.isNotBlank( password ) )
|
if ( StringUtils.isNotBlank( username ) && StringUtils.isNotBlank( password ) )
|
||||||
{
|
{
|
||||||
log.debug( "Using username " + username + " to connect to remote repository " + remoteRepository.getUrl() );
|
log.debug( "Using username {} to connect to remote repository {}", username, remoteRepository.getUrl() );
|
||||||
authInfo = new AuthenticationInfo();
|
authInfo = new AuthenticationInfo();
|
||||||
authInfo.setUserName( username );
|
authInfo.setUserName( username );
|
||||||
authInfo.setPassword( password );
|
authInfo.setPassword( password );
|
||||||
@ -366,7 +368,8 @@ private void moveFileIfExists( File fileToMove, File directory )
|
|||||||
File newLocation = new File( directory, fileToMove.getName() );
|
File newLocation = new File( directory, fileToMove.getName() );
|
||||||
if ( newLocation.exists() && !newLocation.delete() )
|
if ( newLocation.exists() && !newLocation.delete() )
|
||||||
{
|
{
|
||||||
throw new RuntimeException( "Unable to overwrite existing target file: " + newLocation.getAbsolutePath() );
|
throw new RuntimeException(
|
||||||
|
"Unable to overwrite existing target file: " + newLocation.getAbsolutePath() );
|
||||||
}
|
}
|
||||||
|
|
||||||
newLocation.getParentFile().mkdirs();
|
newLocation.getParentFile().mkdirs();
|
||||||
@ -383,12 +386,12 @@ private void moveFileIfExists( File fileToMove, File directory )
|
|||||||
if ( newLocation.exists() )
|
if ( newLocation.exists() )
|
||||||
{
|
{
|
||||||
log.error( "Tried to copy file " + fileToMove.getName() + " to " + newLocation.getAbsolutePath()
|
log.error( "Tried to copy file " + fileToMove.getName() + " to " + newLocation.getAbsolutePath()
|
||||||
+ " but file with this name already exists." );
|
+ " but file with this name already exists." );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new RuntimeException( "Cannot copy tmp file " + fileToMove.getAbsolutePath()
|
throw new RuntimeException(
|
||||||
+ " to its final location", e );
|
"Cannot copy tmp file " + fileToMove.getAbsolutePath() + " to its final location", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
Loading…
x
Reference in New Issue
Block a user