PR: MNG-484

Submitted by: Binyan
Reviewed by:  Brett Porter
add file:// deployment mechanism to site:deploy

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@292366 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-09-29 01:18:09 +00:00
parent 456a6eb042
commit 39b9565855
1 changed files with 45 additions and 5 deletions

View File

@ -37,11 +37,12 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
/** /**
* Deploys website using scp protocol. * Deploys website using scp/file protocol.
* First website files are packaged into zip archive, * For scp protocol, website files are packaged into zip archive,
* then archive is transfred to remote host, nextly it is un-archived. * then archive is transfred to remote host, nextly it is un-archived.
* This method of deployment should normally be much faster * This method of deployment should normally be much faster
* then making file by file copy. * then making file by file copy. For file protocol, the files are copied
* directly to the destination directory.
* *
* @author <a href="mailto:michal@codehaus.org">Michal Maczka</a> * @author <a href="mailto:michal@codehaus.org">Michal Maczka</a>
* @version $Id$ * @version $Id$
@ -120,12 +121,51 @@ public class ScpSiteDeployMojo
Repository repository = new Repository( id, url ); Repository repository = new Repository( id, url );
if ( !"scp".equals( repository.getProtocol() ) ) String siteProtocol = repository.getProtocol();
if ( "scp".equals( siteProtocol ) )
{
scpDeploy( zipFile, id, repository );
}
else if ( "file".equals( siteProtocol ) )
{
File toDir = new File( repository.getBasedir() );
fileDeploy( toDir );
}
else
{ {
throw new MojoExecutionException( throw new MojoExecutionException(
"The deploy mojo currently only supports site deployment using the 'scp' protocol." ); "The deploy mojo currently only supports site deployment using the 'scp' and 'file' protocols." );
} }
}
/**
* @throws MojoExecutionException
*/
private void fileDeploy( File toDir )
throws MojoExecutionException
{
try
{
FileUtils.copyDirectoryStructure( inputDirectory, toDir );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Error transfering site!", e );
}
}
/**
* @param zipFile
* @param id
* @param repository
* @throws MojoExecutionException
*/
private void scpDeploy( File zipFile, String id, Repository repository )
throws MojoExecutionException
{
SshCommandExecutor commandExecutor = null; SshCommandExecutor commandExecutor = null;
try try