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:
brett 2005-05-15 06:14:09 +00:00
parent 8cfcd90d8b
commit f81b049ae6
3 changed files with 37 additions and 23 deletions

View File

@ -35,7 +35,7 @@ import org.apache.maven.repository.ArtifactTypeHandler;
* In case of snapshots the process in even more complex. * In case of snapshots the process in even more complex.
* *
* @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a> * @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 public interface ArtifactDeployer
{ {

View File

@ -30,6 +30,7 @@ import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.TransferFailedException;
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.observers.ChecksumObserver; import org.apache.maven.wagon.observers.ChecksumObserver;
import org.apache.maven.wagon.providers.file.FileWagon; import org.apache.maven.wagon.providers.file.FileWagon;
@ -51,6 +52,7 @@ import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import java.security.NoSuchAlgorithmException;
/** /**
* Default implementation of Artifact Deployer interface. * Default implementation of Artifact Deployer interface.
@ -247,7 +249,7 @@ public class DefaultArtifactDeployer
{ {
Repository repository = new Repository( "local", "file:" + project.getContext().getMavenRepoLocal() ); Repository repository = new Repository( "local", "file:" + project.getContext().getMavenRepoLocal() );
String repositoryPath = handler.constructRepositoryFullPath( type, project, version ); String repositoryPath = handler.constructRepositoryFullPath( type, project, version );
deployFiles( repository, Collections.singletonList( file ), Collections.singletonList( repositoryPath ) ); deployFile( repository, file, repositoryPath );
} }
catch ( Exception e ) catch ( Exception e )
{ {
@ -351,9 +353,10 @@ public class DefaultArtifactDeployer
String repo = repos[i].trim(); String repo = repos[i].trim();
LOG.info( "Deploying to repository: " + repo ); LOG.info( "Deploying to repository: " + repo );
Repository repository = RepositoryBuilder.getRepository( project, repo ); Repository repository = RepositoryBuilder.getRepository( project, repo );
AuthenticationInfo authenticationInfo = RepositoryBuilder.getAuthenticationInfo( project, repo );
try try
{ {
deployFiles( repository, srcFiles, destFiles ); deployFiles( repository, srcFiles, destFiles, authenticationInfo );
success = true; success = true;
} }
catch ( Exception e ) 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, throws ConnectionException, AuthenticationException, ResourceDoesNotExistException, TransferFailedException,
AuthorizationException, MalformedURLException AuthorizationException, MalformedURLException, NoSuchAlgorithmException
{ {
if ( srcFiles.size() != destFiles.size() ) if ( srcFiles.size() != destFiles.size() )
@ -389,7 +400,7 @@ public class DefaultArtifactDeployer
try try
{ {
wagon.connect( repository ); wagon.connect( repository, authenticationInfo );
Iterator srcIterator = srcFiles.iterator(); Iterator srcIterator = srcFiles.iterator();
Iterator destIterator = destFiles.iterator(); Iterator destIterator = destFiles.iterator();
while ( srcIterator.hasNext() ) while ( srcIterator.hasNext() )

View File

@ -44,23 +44,6 @@ public class RepositoryBuilder
Repository repository = new Repository( id, url ); 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" ); String dir = (String) project.getContext().getVariable( "maven.repo." + id + ".directory" );
repository.setBasedir( dir ); repository.setBasedir( dir );
@ -177,4 +160,24 @@ public class RepositoryBuilder
proxyInfo.setPassword( proxyPassword ); 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;
}
} }