stagingSiteURL = getStagingSiteURL( project, reactorProjects, stagingSiteURL );
getLog().info( "Using this URL for staging: " + stagingSiteURL );
Repository repository = new Repository( stagingRepositoryId, stagingSiteURL );
Wagon wagon;
try
{
wagon = wagonManager.getWagon( repository );
SiteDeployMojo.configureWagon( wagon, stagingRepositoryId, settings, plexusContainer, getLog() );
wagon.connect( repository );
}
catch ( UnsupportedProtocolException e )
{
throw new MojoExecutionException( "Unsupported protocol: '" + repository.getProtocol() + "'", e );
}
catch ( WagonConfigurationException e )
{
throw new MojoExecutionException( "Unable to configure Wagon: '" + repository.getProtocol() + "'", e );
} catch (AuthenticationException e)
{
throw new MojoExecutionException( "AuthenticationException : Unable to connect Wagon to repository : '" + repository.getProtocol() + "'", e );
}
catch ( ConnectionException e )
{
throw new MojoExecutionException( "Unable to connect Wagon to repository : '" + repository.getProtocol() + "'", e );
}
if ( !wagon.supportsDirectoryCopy() )
{
throw new MojoExecutionException(
"Wagon protocol '" + repository.getProtocol() + "' doesn't support directory copying" );
}
try
{
Debug debug = new Debug();
wagon.addSessionListener( debug );
wagon.addTransferListener( debug );
/*
ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
if ( proxyInfo != null )
{
wagon.connect( repository, wagonManager.getAuthenticationInfo( stagingRepositoryId ), proxyInfo );
}
else
{
wagon.connect( repository, wagonManager.getAuthenticationInfo( stagingRepositoryId ) );
}
*/
wagon.connect( repository );
wagon.putDirectory( new File( stagingDirectory, getStructure( project, false ) ), "." );
getLog().debug( "putDirectory end ok " );
if ( chmod && wagon instanceof CommandExecutor )
{
CommandExecutor exec = (CommandExecutor) wagon;
exec.executeCommand( "chmod " + chmodOptions + " " + chmodMode + " " + repository.getBasedir() );
}
}
catch ( ResourceDoesNotExistException e )
{
throw new MojoExecutionException( "Error uploading site", e );
}
catch ( TransferFailedException e )
{
throw new MojoExecutionException( "Error uploading site", e );
}
catch ( AuthorizationException e )
{
throw new MojoExecutionException( "Error uploading site", e );
}
catch ( ConnectionException e )
{
throw new MojoExecutionException( "Error uploading site", e );
}
catch ( AuthenticationException e )
{
throw new MojoExecutionException( "Error uploading site", e );
}
catch ( CommandExecutionException e )
{
throw new MojoExecutionException( "Error uploading site", e );
}
finally
{
try
{
wagon.disconnect();
}
catch ( ConnectionException e )
{
getLog().error( "Error disconnecting wagon - ignored", e );
}