api updates for wagon
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@170199 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8cfcd90d8b
commit
f81b049ae6
@ -35,7 +35,7 @@ import org.apache.maven.repository.ArtifactTypeHandler;
|
||||
* In case of snapshots the process in even more complex.
|
||||
*
|
||||
* @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: ArtifactDeployer.java,v 1.6 2004/09/06 04:26:10 felipeal Exp $
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ArtifactDeployer
|
||||
{
|
||||
|
||||
@ -30,6 +30,7 @@ import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
import org.apache.maven.wagon.TransferFailedException;
|
||||
import org.apache.maven.wagon.Wagon;
|
||||
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.observers.ChecksumObserver;
|
||||
import org.apache.maven.wagon.providers.file.FileWagon;
|
||||
@ -51,6 +52,7 @@ import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* Default implementation of Artifact Deployer interface.
|
||||
@ -247,7 +249,7 @@ public class DefaultArtifactDeployer
|
||||
{
|
||||
Repository repository = new Repository( "local", "file:" + project.getContext().getMavenRepoLocal() );
|
||||
String repositoryPath = handler.constructRepositoryFullPath( type, project, version );
|
||||
deployFiles( repository, Collections.singletonList( file ), Collections.singletonList( repositoryPath ) );
|
||||
deployFile( repository, file, repositoryPath );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
@ -351,9 +353,10 @@ public class DefaultArtifactDeployer
|
||||
String repo = repos[i].trim();
|
||||
LOG.info( "Deploying to repository: " + repo );
|
||||
Repository repository = RepositoryBuilder.getRepository( project, repo );
|
||||
AuthenticationInfo authenticationInfo = RepositoryBuilder.getAuthenticationInfo( project, repo );
|
||||
try
|
||||
{
|
||||
deployFiles( repository, srcFiles, destFiles );
|
||||
deployFiles( repository, srcFiles, destFiles, authenticationInfo );
|
||||
success = true;
|
||||
}
|
||||
catch ( Exception e )
|
||||
@ -371,9 +374,17 @@ public class DefaultArtifactDeployer
|
||||
}
|
||||
}
|
||||
|
||||
private void deployFiles( Repository repository, List srcFiles, List destFiles )
|
||||
private void deployFile( Repository repository, File src, String dest )
|
||||
throws ResourceDoesNotExistException, MalformedURLException, NoSuchAlgorithmException, TransferFailedException,
|
||||
ConnectionException, AuthenticationException, AuthorizationException
|
||||
{
|
||||
deployFiles( repository, Collections.singletonList( src ), Collections.singletonList( dest ), null );
|
||||
}
|
||||
|
||||
private void deployFiles( Repository repository, List srcFiles, List destFiles,
|
||||
AuthenticationInfo authenticationInfo )
|
||||
throws ConnectionException, AuthenticationException, ResourceDoesNotExistException, TransferFailedException,
|
||||
AuthorizationException, MalformedURLException
|
||||
AuthorizationException, MalformedURLException, NoSuchAlgorithmException
|
||||
{
|
||||
|
||||
if ( srcFiles.size() != destFiles.size() )
|
||||
@ -389,7 +400,7 @@ public class DefaultArtifactDeployer
|
||||
|
||||
try
|
||||
{
|
||||
wagon.connect( repository );
|
||||
wagon.connect( repository, authenticationInfo );
|
||||
Iterator srcIterator = srcFiles.iterator();
|
||||
Iterator destIterator = destFiles.iterator();
|
||||
while ( srcIterator.hasNext() )
|
||||
|
||||
@ -44,23 +44,6 @@ public class RepositoryBuilder
|
||||
|
||||
Repository repository = new Repository( id, url );
|
||||
|
||||
String username = (String) project.getContext().getVariable( "maven.repo." + id + ".username" );
|
||||
String password = (String) project.getContext().getVariable( "maven.repo." + id + ".password" );
|
||||
String passphrase = (String) project.getContext().getVariable( "maven.repo." + id + ".passphrase" );
|
||||
String privateKey = (String) project.getContext().getVariable( "maven.repo." + id + ".privatekey" );
|
||||
|
||||
if ( username == null )
|
||||
{
|
||||
username = (String) project.getContext().getVariable( "maven.username" );
|
||||
}
|
||||
|
||||
AuthenticationInfo authenticationInfo = new AuthenticationInfo();
|
||||
authenticationInfo.setUserName( username );
|
||||
authenticationInfo.setPassword( password );
|
||||
authenticationInfo.setPrivateKey( privateKey );
|
||||
authenticationInfo.setPassphrase( passphrase );
|
||||
repository.setAuthenticationInfo( authenticationInfo );
|
||||
|
||||
String dir = (String) project.getContext().getVariable( "maven.repo." + id + ".directory" );
|
||||
repository.setBasedir( dir );
|
||||
|
||||
@ -177,4 +160,24 @@ public class RepositoryBuilder
|
||||
proxyInfo.setPassword( proxyPassword );
|
||||
}
|
||||
|
||||
public static AuthenticationInfo getAuthenticationInfo( Project project, String id )
|
||||
{
|
||||
String username = (String) project.getContext().getVariable( "maven.repo." + id + ".username" );
|
||||
String password = (String) project.getContext().getVariable( "maven.repo." + id + ".password" );
|
||||
String passphrase = (String) project.getContext().getVariable( "maven.repo." + id + ".passphrase" );
|
||||
String privateKey = (String) project.getContext().getVariable( "maven.repo." + id + ".privatekey" );
|
||||
|
||||
if ( username == null )
|
||||
{
|
||||
username = (String) project.getContext().getVariable( "maven.username" );
|
||||
}
|
||||
|
||||
AuthenticationInfo authenticationInfo = new AuthenticationInfo();
|
||||
authenticationInfo.setUserName( username );
|
||||
authenticationInfo.setPassword( password );
|
||||
authenticationInfo.setPrivateKey( privateKey );
|
||||
authenticationInfo.setPassphrase( passphrase );
|
||||
|
||||
return authenticationInfo;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user