boolean connected = false;
try
{
- wagon.connect( repository, repository.getProxy() );
+ if ( repository.isProxied() )
+ {
+ wagon.connect( repository, config.getHttpProxy() );
+ }
+ else
+ {
+ wagon.connect( repository );
+ }
connected = true;
}
catch ( ConnectionException e )
{
HttpRepoConfiguration httpRepo = (HttpRepoConfiguration) repoConfig;
MavenProxyConfiguration httpProxy = httpRepo.getProxy();
- repo.setProxy( httpProxy.getHost(), httpProxy.getPort(), httpProxy.getUsername(),
- httpProxy.getPassword() );
+ //todo put into the configuration the proxy
+ if ( httpProxy != null )
+ {
+ repo.setProxied( true );
+ }
}
repoList.add( repo );
*/
import org.apache.maven.repository.proxy.repository.ProxyRepository;
-import org.codehaus.plexus.PlexusContainer;
+import org.apache.maven.wagon.proxy.ProxyInfo;
import java.io.File;
import java.util.ArrayList;
{
public static final String ROLE = ProxyConfiguration.class.getName();
- private PlexusContainer container;
-
private List repositories = new ArrayList();
private String cachePath;
private String layout;
+ private ProxyInfo httpProxy;
+
/**
* Used to set the location where the proxy should cache the configured repositories
*
return cachePath;
}
+ public void setHttpProxy( ProxyInfo httpProxy )
+ {
+ this.httpProxy = httpProxy;
+ }
+
+ public void setHttpProxy( String host, int port )
+ {
+ ProxyInfo proxyInfo = new ProxyInfo();
+ proxyInfo.setHost( host );
+ proxyInfo.setPort( port );
+
+ setHttpProxy( proxyInfo );
+ }
+
+ public void setHttpProxy( String host, int port, String username, String password )
+ {
+ setHttpProxy( host, port );
+ httpProxy.setUserName( username );
+ httpProxy.setPassword( password );
+ }
+
+ public void setHttpProxy( String host, int port, String username, String password, String ntlmHost, String ntlmDomain )
+ {
+ setHttpProxy( host, port );
+ httpProxy.setUserName( username );
+ httpProxy.setPassword( password );
+ httpProxy.setNtlmHost( ntlmHost );
+ httpProxy.setNtlmDomain( ntlmDomain );
+ }
+
+ public ProxyInfo getHttpProxy()
+ {
+ return httpProxy;
+ }
+
/**
* Used to add proxied repositories.
*
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.wagon.proxy.ProxyInfo;
/**
* Class to represent the Proxy repository. Currently does not provide additional methods from
public class ProxyRepository
extends DefaultArtifactRepository
{
- // zero does not cache
+ // zero caches forever
private long cachePeriod = 0;
private boolean cacheFailures = false;
private boolean hardfail = false;
- private ProxyInfo proxy;
+ private boolean proxied = false;
public ProxyRepository( String id, String url, ArtifactRepositoryLayout layout, boolean cacheFailures,
long cachePeriod )
public boolean isProxied()
{
- return ( proxy != null );
+ return proxied;
}
- public ProxyInfo getProxy()
+ public void setProxied( boolean proxied )
{
- return proxy;
- }
-
- public void setProxy( String host, int port )
- {
- ProxyInfo proxyInfo = new ProxyInfo();
- proxyInfo.setHost( host );
- proxyInfo.setPort( port );
-
- setProxy( proxyInfo );
- }
-
- public void setProxy( String host, int port, String username, String password )
- {
- ProxyInfo proxyInfo = new ProxyInfo();
- proxyInfo.setHost( host );
- proxyInfo.setPort( port );
- proxyInfo.setUserName( username );
- proxyInfo.setPassword( password );
-
- setProxy( proxyInfo );
- }
-
- public void setProxy( String host, int port, String username, String password, String ntlmHost, String ntlmDomain )
- {
- ProxyInfo proxyInfo = new ProxyInfo();
- proxyInfo.setHost( host );
- proxyInfo.setPort( port );
- proxyInfo.setUserName( username );
- proxyInfo.setPassword( password );
- proxyInfo.setNtlmHost( ntlmHost );
- proxyInfo.setNtlmDomain( ntlmDomain );
-
- setProxy( proxyInfo );
- }
-
- public void setProxy( ProxyInfo proxy )
- {
- this.proxy = proxy;
+ this.proxied = proxied;
}
/**
ProxyRepository repo2 = new ProxyRepository( "repo2", "http://www.ibiblio.org/maven", legacyLayout );\r
repo2.setCacheFailures( false );\r
repo2.setCachePeriod( 3600 );\r
- repo2.setProxy( "some.local.proxy", 80, "username", "password" );\r
+ repo2.setProxied( true );\r
+ config.setHttpProxy( "some.local.proxy", 80, "username", "password" );\r
config.addRepository( repo2 );\r
assertEquals( 2, config.getRepositories().size() );\r
\r
assertEquals( repo2, repo );\r
assertTrue( repo.isProxied() );\r
\r
- ProxyInfo proxyInfo = repo.getProxy();\r
+ ProxyInfo proxyInfo = config.getHttpProxy();\r
assertNotNull( proxyInfo );\r
assertEquals( "some.local.proxy", proxyInfo.getHost() );\r
assertEquals( 80, proxyInfo.getPort() );\r