mirror of https://github.com/apache/maven.git
o restoring auth
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@794767 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
df47b11957
commit
1ceae0f25e
|
@ -53,7 +53,12 @@ public interface ArtifactRepository
|
||||||
|
|
||||||
String getKey();
|
String getKey();
|
||||||
|
|
||||||
|
//
|
||||||
// New interface methods for the repository system.
|
// New interface methods for the repository system.
|
||||||
|
//
|
||||||
Artifact find( Artifact artifact );
|
Artifact find( Artifact artifact );
|
||||||
|
|
||||||
|
void setAuthentication( Authentication authentication );
|
||||||
|
|
||||||
|
Authentication getAuthentication();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,11 @@ public interface ArtifactRepositoryFactory
|
||||||
|
|
||||||
String LOCAL_REPOSITORY_ID = "local";
|
String LOCAL_REPOSITORY_ID = "local";
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
ArtifactRepositoryLayout getLayout( String layoutId )
|
ArtifactRepositoryLayout getLayout( String layoutId )
|
||||||
throws UnknownRepositoryLayoutException;
|
throws UnknownRepositoryLayoutException;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
ArtifactRepository createDeploymentArtifactRepository( String id, String url, String layoutId, boolean uniqueVersion )
|
ArtifactRepository createDeploymentArtifactRepository( String id, String url, String layoutId, boolean uniqueVersion )
|
||||||
throws UnknownRepositoryLayoutException;
|
throws UnknownRepositoryLayoutException;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.apache.maven.repository;
|
package org.apache.maven.artifact.repository;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@ -21,6 +21,12 @@ package org.apache.maven.repository;
|
||||||
|
|
||||||
public class Authentication
|
public class Authentication
|
||||||
{
|
{
|
||||||
|
public Authentication( String userName, String password )
|
||||||
|
{
|
||||||
|
this.userName = userName;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Username used to login to the host
|
* Username used to login to the host
|
||||||
*/
|
*/
|
|
@ -203,4 +203,17 @@ public class DefaultArtifactRepository
|
||||||
|
|
||||||
return artifact;
|
return artifact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// This implementation does not support authentication
|
||||||
|
//
|
||||||
|
public Authentication getAuthentication()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthentication( Authentication authentication )
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
|
|
||||||
//TODO: http://jira.codehaus.org/browse/MNG-4215
|
|
||||||
//TODO: completely separate local and remote artifact repositories
|
//TODO: completely separate local and remote artifact repositories
|
||||||
public class MavenArtifactRepository
|
public class MavenArtifactRepository
|
||||||
implements ArtifactRepository
|
implements ArtifactRepository
|
||||||
|
@ -44,6 +43,8 @@ public class MavenArtifactRepository
|
||||||
|
|
||||||
private ArtifactRepositoryPolicy releases;
|
private ArtifactRepositoryPolicy releases;
|
||||||
|
|
||||||
|
private Authentication authentication;
|
||||||
|
|
||||||
public MavenArtifactRepository()
|
public MavenArtifactRepository()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -343,4 +344,13 @@ public class MavenArtifactRepository
|
||||||
return s1 != null ? s1.equals( s2 ) : s2 == null;
|
return s1 != null ? s1.equals( s2 ) : s2 == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Authentication getAuthentication()
|
||||||
|
{
|
||||||
|
return authentication;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthentication( Authentication authentication )
|
||||||
|
{
|
||||||
|
this.authentication = authentication;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,25 @@
|
||||||
package org.apache.maven.repository;
|
package org.apache.maven.repository;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* agreements. See the NOTICE file distributed with this work for additional information regarding
|
||||||
* distributed with this work for additional information
|
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* copy of the License at
|
||||||
* "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
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||||
* software distributed under the License is distributed on an
|
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* or implied. See the License for the specific language governing permissions and limitations under
|
||||||
* KIND, either express or implied. See the License for the
|
* the License.
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -33,6 +30,7 @@ import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||||
|
import org.apache.maven.artifact.repository.Authentication;
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||||
|
@ -63,7 +61,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
|
||||||
/**
|
/**
|
||||||
* @author Jason van Zyl
|
* @author Jason van Zyl
|
||||||
*/
|
*/
|
||||||
@Component( role = RepositorySystem.class, hint = "default" )
|
@Component(role = RepositorySystem.class, hint = "default")
|
||||||
public class LegacyRepositorySystem
|
public class LegacyRepositorySystem
|
||||||
implements RepositorySystem
|
implements RepositorySystem
|
||||||
{
|
{
|
||||||
|
@ -79,6 +77,9 @@ public class LegacyRepositorySystem
|
||||||
@Requirement
|
@Requirement
|
||||||
private ArtifactRepositoryLayout defaultArtifactRepositoryLayout;
|
private ArtifactRepositoryLayout defaultArtifactRepositoryLayout;
|
||||||
|
|
||||||
|
@Requirement
|
||||||
|
private Map<String,ArtifactRepositoryLayout> layouts;
|
||||||
|
|
||||||
@Requirement
|
@Requirement
|
||||||
private MirrorBuilder mirrorBuilder;
|
private MirrorBuilder mirrorBuilder;
|
||||||
|
|
||||||
|
@ -120,9 +121,7 @@ public class LegacyRepositorySystem
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Artifact artifact =
|
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, d.getType(), d.getClassifier(), d.getScope(), d.isOptional() );
|
||||||
artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, d.getType(),
|
|
||||||
d.getClassifier(), d.getScope(), d.isOptional() );
|
|
||||||
|
|
||||||
if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) && d.getSystemPath() != null )
|
if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) && d.getSystemPath() != null )
|
||||||
{
|
{
|
||||||
|
@ -179,27 +178,6 @@ public class LegacyRepositorySystem
|
||||||
return artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange );
|
return artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactRepository buildArtifactRepository( Repository repo )
|
|
||||||
throws InvalidRepositoryException
|
|
||||||
{
|
|
||||||
if ( repo != null )
|
|
||||||
{
|
|
||||||
String id = repo.getId();
|
|
||||||
|
|
||||||
String url = repo.getUrl();
|
|
||||||
|
|
||||||
ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() );
|
|
||||||
|
|
||||||
ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() );
|
|
||||||
|
|
||||||
return artifactRepositoryFactory.createArtifactRepository( id, url, repo.getLayout(), snapshots, releases );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArtifactRepositoryPolicy buildArtifactRepositoryPolicy( RepositoryPolicy policy )
|
public ArtifactRepositoryPolicy buildArtifactRepositoryPolicy( RepositoryPolicy policy )
|
||||||
{
|
{
|
||||||
boolean enabled = true;
|
boolean enabled = true;
|
||||||
|
@ -234,28 +212,21 @@ public class LegacyRepositorySystem
|
||||||
public ArtifactRepository createLocalRepository( File localRepository )
|
public ArtifactRepository createLocalRepository( File localRepository )
|
||||||
throws InvalidRepositoryException
|
throws InvalidRepositoryException
|
||||||
{
|
{
|
||||||
return createRepository( "file://" + localRepository.toURI().getRawPath(),
|
return createRepository( "file://" + localRepository.toURI().getRawPath(), RepositorySystem.DEFAULT_LOCAL_REPO_ID, true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, true,
|
||||||
RepositorySystem.DEFAULT_LOCAL_REPO_ID, true,
|
ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
|
||||||
ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, true,
|
|
||||||
ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
|
|
||||||
ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactRepository createDefaultRemoteRepository()
|
public ArtifactRepository createDefaultRemoteRepository()
|
||||||
throws InvalidRepositoryException
|
throws InvalidRepositoryException
|
||||||
{
|
{
|
||||||
return createRepository( RepositorySystem.DEFAULT_REMOTE_REPO_URL, RepositorySystem.DEFAULT_REMOTE_REPO_ID,
|
return createRepository( RepositorySystem.DEFAULT_REMOTE_REPO_URL, RepositorySystem.DEFAULT_REMOTE_REPO_ID, true, ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER, false,
|
||||||
true, ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER, false,
|
ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
|
||||||
ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY,
|
|
||||||
ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactRepository createLocalRepository( String url, String repositoryId )
|
public ArtifactRepository createLocalRepository( String url, String repositoryId )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
return createRepository( canonicalFileUrl( url ), repositoryId, true,
|
return createRepository( canonicalFileUrl( url ), repositoryId, true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
|
||||||
ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, true,
|
|
||||||
ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
|
|
||||||
ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
|
ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,22 +259,6 @@ public class LegacyRepositorySystem
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArtifactRepository createRepository( String url, String repositoryId, boolean releases,
|
|
||||||
String releaseUpdates, boolean snapshots, String snapshotUpdates,
|
|
||||||
String checksumPolicy )
|
|
||||||
{
|
|
||||||
ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy( snapshots, snapshotUpdates, checksumPolicy );
|
|
||||||
|
|
||||||
ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy( releases, releaseUpdates, checksumPolicy );
|
|
||||||
|
|
||||||
return artifactRepositoryFactory.createArtifactRepository( repositoryId, url, defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy );
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases )
|
|
||||||
{
|
|
||||||
return artifactRepositoryFactory.createArtifactRepository( id, url, repositoryLayout, snapshots, releases );
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
|
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -372,23 +327,7 @@ public class LegacyRepositorySystem
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
public void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey, String passphrase )
|
|
||||||
{
|
|
||||||
AuthenticationInfo authInfo = new AuthenticationInfo();
|
|
||||||
authInfo.setUserName( username );
|
|
||||||
authInfo.setPassword( password );
|
|
||||||
authInfo.setPrivateKey( privateKey );
|
|
||||||
authInfo.setPassphrase( passphrase );
|
|
||||||
|
|
||||||
authenticationInfoMap.put( repositoryId, authInfo );
|
|
||||||
|
|
||||||
wagonManager.addAuthenticationInfo( repositoryId, username, password, privateKey, passphrase );
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Mirror
|
// Mirror
|
||||||
|
|
||||||
public void addMirror( String id, String mirrorOf, String url )
|
public void addMirror( String id, String mirrorOf, String url )
|
||||||
{
|
{
|
||||||
mirrorBuilder.addMirror( id, mirrorOf, url );
|
mirrorBuilder.addMirror( id, mirrorOf, url );
|
||||||
|
@ -427,8 +366,7 @@ public class LegacyRepositorySystem
|
||||||
|
|
||||||
for ( List<ArtifactRepository> aliasedRepos : reposByKey.values() )
|
for ( List<ArtifactRepository> aliasedRepos : reposByKey.values() )
|
||||||
{
|
{
|
||||||
List<ArtifactRepositoryPolicy> releasePolicies =
|
List<ArtifactRepositoryPolicy> releasePolicies = new ArrayList<ArtifactRepositoryPolicy>( aliasedRepos.size() );
|
||||||
new ArrayList<ArtifactRepositoryPolicy>( aliasedRepos.size() );
|
|
||||||
|
|
||||||
for ( ArtifactRepository aliasedRepo : aliasedRepos )
|
for ( ArtifactRepository aliasedRepo : aliasedRepos )
|
||||||
{
|
{
|
||||||
|
@ -437,8 +375,7 @@ public class LegacyRepositorySystem
|
||||||
|
|
||||||
ArtifactRepositoryPolicy releasePolicy = getEffectivePolicy( releasePolicies );
|
ArtifactRepositoryPolicy releasePolicy = getEffectivePolicy( releasePolicies );
|
||||||
|
|
||||||
List<ArtifactRepositoryPolicy> snapshotPolicies =
|
List<ArtifactRepositoryPolicy> snapshotPolicies = new ArrayList<ArtifactRepositoryPolicy>( aliasedRepos.size() );
|
||||||
new ArrayList<ArtifactRepositoryPolicy>( aliasedRepos.size() );
|
|
||||||
|
|
||||||
for ( ArtifactRepository aliasedRepo : aliasedRepos )
|
for ( ArtifactRepository aliasedRepo : aliasedRepos )
|
||||||
{
|
{
|
||||||
|
@ -450,9 +387,7 @@ public class LegacyRepositorySystem
|
||||||
ArtifactRepository aliasedRepo = aliasedRepos.get( 0 );
|
ArtifactRepository aliasedRepo = aliasedRepos.get( 0 );
|
||||||
|
|
||||||
ArtifactRepository effectiveRepository =
|
ArtifactRepository effectiveRepository =
|
||||||
artifactRepositoryFactory.createArtifactRepository( aliasedRepo.getId(), aliasedRepo.getUrl(),
|
createArtifactRepository( aliasedRepo.getId(), aliasedRepo.getUrl(), aliasedRepo.getLayout(), snapshotPolicy, releasePolicy );
|
||||||
aliasedRepo.getLayout(), snapshotPolicy,
|
|
||||||
releasePolicy );
|
|
||||||
|
|
||||||
effectiveRepositories.add( effectiveRepository );
|
effectiveRepositories.add( effectiveRepository );
|
||||||
}
|
}
|
||||||
|
@ -468,9 +403,7 @@ public class LegacyRepositorySystem
|
||||||
{
|
{
|
||||||
if ( effectivePolicy == null )
|
if ( effectivePolicy == null )
|
||||||
{
|
{
|
||||||
effectivePolicy =
|
effectivePolicy = new ArtifactRepositoryPolicy( policy.isEnabled(), policy.getUpdatePolicy(), policy.getChecksumPolicy() );
|
||||||
new ArtifactRepositoryPolicy( policy.isEnabled(), policy.getUpdatePolicy(),
|
|
||||||
policy.getChecksumPolicy() );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -533,17 +466,17 @@ public class LegacyRepositorySystem
|
||||||
public MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request )
|
public MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request )
|
||||||
{
|
{
|
||||||
|
|
||||||
// ArtifactResolutionResult collect( Set<Artifact> artifacts,
|
// ArtifactResolutionResult collect( Set<Artifact> artifacts,
|
||||||
// Artifact originatingArtifact,
|
// Artifact originatingArtifact,
|
||||||
// Map managedVersions,
|
// Map managedVersions,
|
||||||
// ArtifactRepository localRepository,
|
// ArtifactRepository localRepository,
|
||||||
// List<ArtifactRepository> remoteRepositories,
|
// List<ArtifactRepository> remoteRepositories,
|
||||||
// ArtifactMetadataSource source,
|
// ArtifactMetadataSource source,
|
||||||
// ArtifactFilter filter,
|
// ArtifactFilter filter,
|
||||||
// List<ResolutionListener> listeners,
|
// List<ResolutionListener> listeners,
|
||||||
// List<ConflictResolver> conflictResolvers )
|
// List<ConflictResolver> conflictResolvers )
|
||||||
|
|
||||||
// ArtifactResolutionResult result = artifactCollector.
|
// ArtifactResolutionResult result = artifactCollector.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,4 +491,67 @@ public class LegacyRepositorySystem
|
||||||
{
|
{
|
||||||
wagonManager.putRemoteFile( repository, source, remotePath, downloadMonitor );
|
wagonManager.putRemoteFile( repository, source, remotePath, downloadMonitor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, Authentication> authentications = new HashMap<String, Authentication>();
|
||||||
|
|
||||||
|
//
|
||||||
|
// serverId = repository id
|
||||||
|
//
|
||||||
|
public void addAuthenticationForArtifactRepository( String repositoryId, String username, String password )
|
||||||
|
{
|
||||||
|
Authentication authentication = new Authentication( username, password );
|
||||||
|
authentications.put( repositoryId, authentication );
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Artifact Repository Creation
|
||||||
|
//
|
||||||
|
public ArtifactRepository buildArtifactRepository( Repository repo )
|
||||||
|
throws InvalidRepositoryException
|
||||||
|
{
|
||||||
|
if ( repo != null )
|
||||||
|
{
|
||||||
|
String id = repo.getId();
|
||||||
|
|
||||||
|
String url = repo.getUrl();
|
||||||
|
|
||||||
|
ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() );
|
||||||
|
|
||||||
|
ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() );
|
||||||
|
|
||||||
|
return createArtifactRepository( id, url, layouts.get( repo.getLayout() ), snapshots, releases );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArtifactRepository createRepository( String url, String repositoryId, boolean releases, String releaseUpdates, boolean snapshots, String snapshotUpdates, String checksumPolicy )
|
||||||
|
{
|
||||||
|
ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy( snapshots, snapshotUpdates, checksumPolicy );
|
||||||
|
|
||||||
|
ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy( releases, releaseUpdates, checksumPolicy );
|
||||||
|
|
||||||
|
return createArtifactRepository( repositoryId, url, defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArtifactRepository createArtifactRepository( String repositoryId, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases )
|
||||||
|
{
|
||||||
|
if ( repositoryLayout == null )
|
||||||
|
{
|
||||||
|
repositoryLayout = defaultArtifactRepositoryLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArtifactRepository artifactRepository = artifactRepositoryFactory.createArtifactRepository( repositoryId, url, repositoryLayout, snapshots, releases );
|
||||||
|
|
||||||
|
Authentication authentication = authentications.get( repositoryId );
|
||||||
|
|
||||||
|
if ( authentication != null )
|
||||||
|
{
|
||||||
|
artifactRepository.setAuthentication( authentication );
|
||||||
|
}
|
||||||
|
|
||||||
|
return artifactRepository;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,4 +113,6 @@ public interface RepositorySystem
|
||||||
|
|
||||||
void retrieve( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor )
|
void retrieve( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor )
|
||||||
throws TransferFailedException, ResourceDoesNotExistException;
|
throws TransferFailedException, ResourceDoesNotExistException;
|
||||||
|
|
||||||
|
void addAuthenticationForArtifactRepository( String repositoryId, String username, String password );
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,11 @@ import org.apache.maven.wagon.TransferFailedException;
|
||||||
import org.apache.maven.wagon.UnsupportedProtocolException;
|
import org.apache.maven.wagon.UnsupportedProtocolException;
|
||||||
import org.apache.maven.wagon.Wagon;
|
import org.apache.maven.wagon.Wagon;
|
||||||
import org.apache.maven.wagon.authentication.AuthenticationException;
|
import org.apache.maven.wagon.authentication.AuthenticationException;
|
||||||
|
import org.apache.maven.wagon.authentication.AuthenticationInfo;
|
||||||
import org.apache.maven.wagon.authorization.AuthorizationException;
|
import org.apache.maven.wagon.authorization.AuthorizationException;
|
||||||
import org.apache.maven.wagon.events.TransferListener;
|
import org.apache.maven.wagon.events.TransferListener;
|
||||||
import org.apache.maven.wagon.observers.ChecksumObserver;
|
import org.apache.maven.wagon.observers.ChecksumObserver;
|
||||||
|
import org.apache.maven.wagon.proxy.ProxyInfo;
|
||||||
import org.apache.maven.wagon.repository.Repository;
|
import org.apache.maven.wagon.repository.Repository;
|
||||||
import org.codehaus.plexus.PlexusContainer;
|
import org.codehaus.plexus.PlexusContainer;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
|
@ -208,6 +210,38 @@ public class DefaultWagonManager
|
||||||
getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true );
|
getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deal with connecting to a wagon repository taking into account authentication and proxies.
|
||||||
|
*
|
||||||
|
* @param wagon
|
||||||
|
* @param repository
|
||||||
|
* @throws ConnectionException
|
||||||
|
* @throws AuthenticationException
|
||||||
|
*/
|
||||||
|
private void connectWagon( Wagon wagon, ArtifactRepository repository )
|
||||||
|
throws ConnectionException, AuthenticationException
|
||||||
|
{
|
||||||
|
if ( repository.getAuthentication() != null )
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// We have authentication we have been asked to deal with.
|
||||||
|
//
|
||||||
|
AuthenticationInfo ai = new AuthenticationInfo();
|
||||||
|
ai.setUserName( repository.getAuthentication().getUserName() );
|
||||||
|
ai.setPassword( repository.getAuthentication().getPassword() );
|
||||||
|
|
||||||
|
wagon.connect( new Repository( repository.getId(), repository.getUrl() ), ai );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wagon.connect( new Repository( repository.getId(), repository.getUrl() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// ProxyInfo proxyInfo = new ProxyInfo();
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
public void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor, String checksumPolicy, boolean force )
|
public void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor, String checksumPolicy, boolean force )
|
||||||
throws TransferFailedException, ResourceDoesNotExistException
|
throws TransferFailedException, ResourceDoesNotExistException
|
||||||
{
|
{
|
||||||
|
@ -237,7 +271,7 @@ public class DefaultWagonManager
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
wagon.connect( new Repository( repository.getId(), repository.getUrl() ) );
|
connectWagon( wagon, repository );
|
||||||
|
|
||||||
boolean firstRun = true;
|
boolean firstRun = true;
|
||||||
boolean retry = true;
|
boolean retry = true;
|
||||||
|
@ -467,7 +501,7 @@ public class DefaultWagonManager
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
wagon.connect( new Repository( repository.getId(), repository.getUrl() ) );
|
connectWagon( wagon, repository );
|
||||||
|
|
||||||
wagon.put( source, remotePath );
|
wagon.put( source, remotePath );
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
import org.apache.maven.repository.RepositorySystem;
|
import org.apache.maven.repository.RepositorySystem;
|
||||||
import org.apache.maven.settings.MavenSettingsBuilder;
|
import org.apache.maven.settings.MavenSettingsBuilder;
|
||||||
import org.apache.maven.settings.Mirror;
|
import org.apache.maven.settings.Mirror;
|
||||||
|
import org.apache.maven.settings.Server;
|
||||||
import org.apache.maven.settings.Settings;
|
import org.apache.maven.settings.Settings;
|
||||||
import org.apache.maven.settings.SettingsUtils;
|
import org.apache.maven.settings.SettingsUtils;
|
||||||
import org.apache.maven.toolchain.ToolchainsBuilder;
|
import org.apache.maven.toolchain.ToolchainsBuilder;
|
||||||
|
@ -199,27 +200,14 @@ public class DefaultMavenExecutionRequestPopulator
|
||||||
|
|
||||||
repositorySystem.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(), proxy.getPassword(), proxy.getNonProxyHosts() );
|
repositorySystem.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(), proxy.getPassword(), proxy.getNonProxyHosts() );
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
for ( Server server : settings.getServers() )
|
for ( Server server : settings.getServers() )
|
||||||
{
|
{
|
||||||
String password;
|
repositorySystem.addAuthenticationForArtifactRepository( server.getId(), server.getUsername(), server.getPassword() );
|
||||||
String passPhrase;
|
|
||||||
|
|
||||||
try
|
//repositorySystem.addPermissionInfo( server.getId(), server.getFilePermissions(), server.getDirectoryPermissions() );
|
||||||
{
|
|
||||||
password = securityDispatcher.decrypt( server.getPassword() );
|
|
||||||
passPhrase = securityDispatcher.decrypt( server.getPassphrase() );
|
|
||||||
}
|
}
|
||||||
catch ( SecDispatcherException e )
|
|
||||||
{
|
|
||||||
throw new MavenEmbedderException( "Error decrypting server password/passphrase.", e );
|
|
||||||
}
|
|
||||||
|
|
||||||
repositorySystem.addAuthenticationInfo( server.getId(), server.getUsername(), password, server.getPrivateKey(), passPhrase );
|
|
||||||
|
|
||||||
repositorySystem.addPermissionInfo( server.getId(), server.getFilePermissions(), server.getDirectoryPermissions() );
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
for ( Mirror mirror : settings.getMirrors() )
|
for ( Mirror mirror : settings.getMirrors() )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue