Added EXTERNAL deployer and made some minor optimzation.
External deployer is a deployer which starts external process for each deployment request. This deployer conceptually close to what what used in maven-deploy plugin Thanks to this deployer external tools like ssh shells/scp etc. can be used for deploying artifacts. Such feature might be useful for users who want to relay on external security infrastructure for making deployments. Still need to test this deployer (I haven't tried it on UNIX) and define list of parameters passed from deployer to the external process and fix their order. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113575 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
05be2a1f64
commit
0ae8ac50b1
@ -67,6 +67,7 @@ import org.apache.maven.MavenConstants;
|
||||
import org.apache.maven.MavenException;
|
||||
import org.apache.maven.deploy.DeployRequest;
|
||||
import org.apache.maven.deploy.DeployTool;
|
||||
import org.apache.maven.deploy.exceptions.WrongParameterException;
|
||||
import org.apache.maven.project.Project;
|
||||
import org.apache.maven.util.MD5Sum;
|
||||
|
||||
@ -76,7 +77,7 @@ import org.apache.maven.util.MD5Sum;
|
||||
*
|
||||
*
|
||||
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: DefaultArtifactDeployer.java,v 1.10 2003/06/29 11:57:39 michal Exp $
|
||||
* @version $Id: DefaultArtifactDeployer.java,v 1.11 2003/07/02 12:42:23 michal Exp $
|
||||
*/
|
||||
public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
{
|
||||
@ -255,7 +256,7 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
|
||||
String repos =
|
||||
(String) project.getContext().getVariable("maven.repo.list");
|
||||
|
||||
|
||||
String distSite = project.getDistributionSite();
|
||||
if (distSite != null && distSite.length() > 0)
|
||||
{
|
||||
@ -271,7 +272,8 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
|
||||
if (repos == null || repos.length() == 0)
|
||||
{
|
||||
System.out.println("No remote repository is defined for deployment");
|
||||
System.out.println(
|
||||
"No remote repository is defined for deployment");
|
||||
return;
|
||||
}
|
||||
String[] repoArray = StringUtils.split(repos, ",");
|
||||
@ -285,20 +287,26 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
String repo = repoArray[i].trim();
|
||||
System.out.println("Deploying to repo: " + repo);
|
||||
|
||||
DeployRequest request = null;
|
||||
|
||||
// Will create only one request per repository
|
||||
try
|
||||
{
|
||||
request = DeployRequestBuilder.getDeployRequest(project, repo);
|
||||
request.setDestDir(destPath);
|
||||
}
|
||||
catch (WrongParameterException e)
|
||||
{
|
||||
System.out.print(e.getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < srcFilenames.length; j++)
|
||||
{
|
||||
|
||||
DeployRequest request = null;
|
||||
try
|
||||
{
|
||||
request =
|
||||
DeployRequestBuilder.getDeployRequest(
|
||||
repo,
|
||||
project,
|
||||
repo,
|
||||
srcFilenames[j],
|
||||
destPath,
|
||||
destFilenames[j]);
|
||||
request.setSrcFile(srcFilenames[j]);
|
||||
request.setDestFile(destFilenames[j]);
|
||||
|
||||
System.out.println(
|
||||
"Deploying: '"
|
||||
@ -306,6 +314,8 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
+ "' to host: '"
|
||||
+ request.getHost()
|
||||
+ "' remote path: '"
|
||||
+ request.getBaseDir()
|
||||
+ "/"
|
||||
+ request.getDestDir()
|
||||
+ "' remote file: '"
|
||||
+ request.getDestFile());
|
||||
@ -356,7 +366,6 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
|
||||
@ -57,7 +57,6 @@ package org.apache.maven.artifact.deployer;
|
||||
*/
|
||||
|
||||
import org.apache.maven.deploy.DeployRequest;
|
||||
import org.apache.maven.deploy.exceptions.DeployException;
|
||||
import org.apache.maven.deploy.exceptions.WrongParameterException;
|
||||
import org.apache.maven.project.Project;
|
||||
|
||||
@ -66,31 +65,28 @@ import org.apache.maven.project.Project;
|
||||
* Perform mapping between project's properties and attributes of DeployRequest class.
|
||||
*
|
||||
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: DeployRequestBuilder.java,v 1.2 2003/06/29 11:57:39 michal Exp $
|
||||
* @version $Id: DeployRequestBuilder.java,v 1.3 2003/07/02 12:42:23 michal Exp $
|
||||
*/
|
||||
public class DeployRequestBuilder
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param project
|
||||
* @param repository Alias(name) of the repository
|
||||
* like </i>repo1</i> taken from propertt: <i>maven.deploy.repos= repo1, repo2</i>
|
||||
* @param srcDir
|
||||
* @param srcDir
|
||||
* @param destFile
|
||||
* @param project. Will lookup the properties in the context of this project
|
||||
* @param repository The name (alias) of the repository
|
||||
* like </i>repo1</i> taken from property: <i>maven.deploy.repos= repo1, repo2</i>
|
||||
* @return Deploy request
|
||||
* @throws WrongParameterException
|
||||
*/
|
||||
public static DeployRequest getDeployRequest(
|
||||
String repositoryAlias,
|
||||
Project project,
|
||||
String repository,
|
||||
String srcFile,
|
||||
String destDir,
|
||||
String destFile) throws DeployException
|
||||
String repository)
|
||||
throws WrongParameterException
|
||||
{
|
||||
|
||||
DeployRequest request = new DeployRequest();
|
||||
request.setRepositoryAlias(repositoryAlias);
|
||||
request.setRepositoryAlias(repository);
|
||||
String url =
|
||||
(String) project.getContext().getVariable(
|
||||
"maven.repo." + repository);
|
||||
@ -122,19 +118,13 @@ public class DeployRequestBuilder
|
||||
(String) project.getContext().getVariable(
|
||||
"maven.repo." + repository + ".group");
|
||||
|
||||
String proxyHost =
|
||||
(String) project.getContext().getProxyHost();
|
||||
String proxyUser =
|
||||
(String) project.getContext().getProxyUserName();
|
||||
|
||||
String proxyHost = (String) project.getContext().getProxyHost();
|
||||
String proxyUser = (String) project.getContext().getProxyUserName();
|
||||
|
||||
String proxyPassword =
|
||||
(String) project.getContext().getProxyPassword();
|
||||
|
||||
String proxyPassword = (String) project.getContext().getProxyPassword();
|
||||
|
||||
String proxyPort = (String) project.getContext().getProxyPort();
|
||||
|
||||
String proxyPort =
|
||||
(String) project.getContext().getProxyPort();
|
||||
|
||||
request.setUserName(username);
|
||||
request.setPassword(password);
|
||||
request.setPassphrase(passphrase);
|
||||
@ -153,7 +143,8 @@ public class DeployRequestBuilder
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new WrongParameterException("maven.repo." + repository + ".port should be an integer");
|
||||
throw new WrongParameterException(
|
||||
"maven.repo." + repository + ".port should be an integer");
|
||||
}
|
||||
}
|
||||
if (proxyPort != null)
|
||||
@ -164,18 +155,14 @@ public class DeployRequestBuilder
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new WrongParameterException("maven.repo." + repository + ".proxy.port should be an integer");
|
||||
throw new WrongParameterException(
|
||||
"maven.repo."
|
||||
+ repository
|
||||
+ ".proxy.port should be an integer");
|
||||
}
|
||||
}
|
||||
|
||||
request.setSrcFile(srcFile);
|
||||
|
||||
if (dir != null)
|
||||
{
|
||||
destDir = dir + "/" + destDir;
|
||||
}
|
||||
request.setDestFile(destFile);
|
||||
request.setDestDir(destDir);
|
||||
request.setBaseDir(dir);
|
||||
return request;
|
||||
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ package org.apache.maven.deploy;
|
||||
* deploy the file to correct location in remote file system
|
||||
*
|
||||
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: DeployRequest.java,v 1.5 2003/06/29 11:57:40 michal Exp $
|
||||
* @version $Id: DeployRequest.java,v 1.6 2003/07/02 12:42:23 michal Exp $
|
||||
*/
|
||||
public class DeployRequest
|
||||
{
|
||||
@ -78,47 +78,52 @@ public class DeployRequest
|
||||
|
||||
/** URL of the remote host*/
|
||||
private String url;
|
||||
|
||||
|
||||
/** Port of remote host */
|
||||
private int port = UNKNOWN_PORT;
|
||||
|
||||
/** The directory where artifact will be placed */
|
||||
|
||||
private String baseDir;
|
||||
|
||||
/**
|
||||
* The directory where artifact will be placed
|
||||
* It is relative to base dir
|
||||
*/
|
||||
private String destDir;
|
||||
|
||||
|
||||
/** The filename of the artifact */
|
||||
private String destFile;
|
||||
|
||||
|
||||
/** The artifact file in local file system */
|
||||
private String srcFile;
|
||||
|
||||
/** The login name of the user in @ remote host*/
|
||||
private String userName;
|
||||
|
||||
|
||||
/** Password */
|
||||
private String password;
|
||||
|
||||
|
||||
/** Remote group name */
|
||||
private String group;
|
||||
|
||||
|
||||
/** The passpharse of the user's private key file */
|
||||
private String passphrase;
|
||||
|
||||
|
||||
/** The absoluth path to private key file */
|
||||
private String privateKey;
|
||||
|
||||
/** Proxy Server host*/
|
||||
/** Proxy Server host*/
|
||||
private String proxyHost = null;
|
||||
|
||||
|
||||
/** the login name of the user @ Proxy Server host*/
|
||||
private String proxyUserName = null;
|
||||
|
||||
|
||||
/** the password user @ Proxy Server host*/
|
||||
private String proxyPassword = null;
|
||||
|
||||
|
||||
/** Proxy server port */
|
||||
private int proxyPort = UNKNOWN_PORT;
|
||||
|
||||
/** Indicates if debug mode should be used*/
|
||||
/** Indicates if debug mode should be used*/
|
||||
private boolean debugOn = false;
|
||||
|
||||
/**
|
||||
@ -218,7 +223,25 @@ public class DeployRequest
|
||||
}
|
||||
|
||||
/**
|
||||
* Get aboluth path to local files = artifact
|
||||
* Get base directory
|
||||
* @return base directory
|
||||
*/
|
||||
public String getBaseDir()
|
||||
{
|
||||
return baseDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set base directory
|
||||
* @param baseDir
|
||||
*/
|
||||
public void setBaseDir(String baseDir)
|
||||
{
|
||||
this.baseDir = baseDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get absolute path to local file = artifact
|
||||
* @return Path to artifact file
|
||||
*/
|
||||
public String getSrcFile()
|
||||
@ -227,7 +250,7 @@ public class DeployRequest
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the aboluthe path to artifact file
|
||||
* Set the absolute path to artifact file
|
||||
* @param srcFile
|
||||
*/
|
||||
public void setSrcFile(String inputFile)
|
||||
|
||||
@ -57,6 +57,7 @@ package org.apache.maven.deploy;
|
||||
*/
|
||||
|
||||
import org.apache.maven.deploy.deployers.Deployer;
|
||||
import org.apache.maven.deploy.deployers.ExternalDeployer;
|
||||
import org.apache.maven.deploy.deployers.FileDeployer;
|
||||
import org.apache.maven.deploy.deployers.FtpDeployer;
|
||||
import org.apache.maven.deploy.deployers.HttpDeployer;
|
||||
@ -71,7 +72,7 @@ import org.apache.maven.deploy.exceptions.WrongParameterException;
|
||||
/**
|
||||
* Delegates
|
||||
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: DeployTool.java,v 1.5 2003/06/29 11:57:40 michal Exp $
|
||||
* @version $Id: DeployTool.java,v 1.6 2003/07/02 12:42:23 michal Exp $
|
||||
*/
|
||||
public class DeployTool
|
||||
{
|
||||
@ -122,10 +123,15 @@ public class DeployTool
|
||||
{
|
||||
deployer = new ScpDeployer();
|
||||
}
|
||||
if (url.startsWith(ExternalDeployer.PROTOCOL))
|
||||
{
|
||||
deployer = new ExternalDeployer();
|
||||
}
|
||||
if (deployer == null)
|
||||
{
|
||||
throw new UnsupportedProtocolException(url);
|
||||
}
|
||||
|
||||
deployer.deploy(request);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,117 @@
|
||||
package org.apache.maven.deploy.deployers;
|
||||
|
||||
import org.apache.maven.deploy.DeployRequest;
|
||||
import org.apache.maven.deploy.exceptions.NotAuthorizedDeployException;
|
||||
import org.apache.maven.deploy.exceptions.ProxyNotAuthorizedDeployException;
|
||||
import org.apache.maven.deploy.exceptions.TransferFailedException;
|
||||
import org.apache.maven.deploy.exceptions.WrongParameterException;
|
||||
|
||||
/* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
* Copyright (c) 2001 The Apache Software Foundation. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution,
|
||||
* if any, must include the following acknowledgment:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||
* "Apache MavenSession" must not be used to endorse or promote products
|
||||
* derived from this software without prior written permission. For
|
||||
* written permission, please contact apache@apache.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Apache",
|
||||
* "Apache MavenSession", nor may "Apache" appear in their name, without
|
||||
* prior written permission of the Apache Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Deployers which runs external script or program as new process.
|
||||
*
|
||||
* @version $Id: ExternalDeployer.java,v 1.1 2003/07/02 12:42:19 michal Exp $
|
||||
* @todo still have to account for differing setups for people deploying to
|
||||
* their own sites and to the central repository.
|
||||
* @todo finich
|
||||
*/
|
||||
public class ExternalDeployer extends AbstractDeployer
|
||||
{
|
||||
|
||||
public final static String PROTOCOL = "external://";
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.maven.deploy.deployers.Deployer#deploy(org.apache.maven.deploy.DeployRequest)
|
||||
*/
|
||||
public void deploy(DeployRequest request)
|
||||
throws
|
||||
TransferFailedException,
|
||||
NotAuthorizedDeployException,
|
||||
ProxyNotAuthorizedDeployException,
|
||||
TransferFailedException,
|
||||
WrongParameterException
|
||||
{
|
||||
|
||||
String cmd = request.getHost();
|
||||
|
||||
|
||||
String[] params =
|
||||
{
|
||||
request.getSrcFile(),
|
||||
request.getDestDir(),
|
||||
request.getDestFile(),
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
System.out.println("Staring external process: '" + cmd + "'");
|
||||
Process process = Runtime.getRuntime().exec(cmd,params);
|
||||
process.waitFor();
|
||||
System.out.println("External process finished");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new TransferFailedException("Failed to deploy with extrnal program",e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -68,7 +68,7 @@ import org.apache.maven.deploy.exceptions.TransferFailedException;
|
||||
* file system.
|
||||
*
|
||||
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: FileDeployer.java,v 1.6 2003/06/29 11:57:40 michal Exp $
|
||||
* @version $Id: FileDeployer.java,v 1.7 2003/07/02 12:42:21 michal Exp $
|
||||
*/
|
||||
public class FileDeployer implements Deployer
|
||||
{
|
||||
@ -86,12 +86,12 @@ public class FileDeployer implements Deployer
|
||||
File srcFile = new File(request.getSrcFile());
|
||||
|
||||
File destFile =
|
||||
new File(request.getHost(), request.getDestDir());
|
||||
|
||||
new File(request.getHost(), request.getBaseDir());
|
||||
destFile = new File(destFile, request.getDestDir());
|
||||
if (! destFile.exists())
|
||||
{
|
||||
destFile.mkdirs();
|
||||
}
|
||||
}
|
||||
destFile = new File( destFile, request.getDestFile());
|
||||
FileUtils.copyFile(srcFile, destFile);
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ import org.apache.maven.deploy.exceptions.TransferFailedException;
|
||||
*
|
||||
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
|
||||
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: FtpDeployer.java,v 1.5 2003/06/29 11:57:39 michal Exp $
|
||||
* @version $Id: FtpDeployer.java,v 1.6 2003/07/02 12:42:13 michal Exp $
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ -158,12 +158,11 @@ public class FtpDeployer extends AbstractDeployer
|
||||
// Use passive mode as default because most of us are
|
||||
// behind firewalls these days.
|
||||
ftp.enterLocalPassiveMode();
|
||||
String workingDir = request.getDestDir();
|
||||
String filename = request.getDestFile();
|
||||
System.out.println("Working directory " + workingDir);
|
||||
System.out.println("Filename: " + filename);
|
||||
ftp.makeDirectory(workingDir);
|
||||
ftp.changeWorkingDirectory(workingDir);
|
||||
ftp.changeWorkingDirectory(request.getBaseDir());
|
||||
String destDir = request.getDestDir();
|
||||
String filename = request.getDestFile();
|
||||
ftp.makeDirectory(destDir);
|
||||
ftp.changeWorkingDirectory(destDir);
|
||||
ftp.storeFile(filename, new FileInputStream(request.getSrcFile()));
|
||||
ftp.logout();
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ import com.jcraft.jsch.SftpException;
|
||||
* An SSH2/SFTP deployer
|
||||
*
|
||||
* @author Michal Maczka
|
||||
* @version $Revision: 1.4 $ $Date: 2003/06/29 11:57:39 $
|
||||
* @version $Revision: 1.5 $ $Date: 2003/07/02 12:42:13 $
|
||||
*/
|
||||
public class SFtpDeployer extends GenericSshDeployer
|
||||
{
|
||||
@ -111,7 +111,8 @@ public class SFtpDeployer extends GenericSshDeployer
|
||||
channel.connect();
|
||||
// iterate over all directories in the path. try to create
|
||||
// directory
|
||||
String[] dirs = StringUtils.split(request.getDestDir(), "/");
|
||||
String destPath = request.getBaseDir() + "/" + request.getDestDir();
|
||||
String[] dirs = StringUtils.split(destPath, "/");
|
||||
for (int i = 0; i < dirs.length; i++)
|
||||
{
|
||||
try
|
||||
|
||||
@ -71,7 +71,7 @@ import com.jcraft.jsch.Session;
|
||||
* An SSH2/SCP deployer
|
||||
*
|
||||
* @author Michal Maczka
|
||||
* @version $Revision: 1.3 $ $Date: 2003/06/29 11:57:40 $
|
||||
* @version $Revision: 1.4 $ $Date: 2003/07/02 12:42:21 $
|
||||
*/
|
||||
public class ScpDeployer extends GenericSshDeployer
|
||||
{
|
||||
@ -92,7 +92,12 @@ public class ScpDeployer extends GenericSshDeployer
|
||||
try
|
||||
{
|
||||
|
||||
String mkdirCmd = "mkdir -p " + request.getDestDir() + "\n";
|
||||
String mkdirCmd =
|
||||
"mkdir -p "
|
||||
+ request.getBaseDir()
|
||||
+ "/"
|
||||
+ request.getDestDir()
|
||||
+ "\n";
|
||||
executeSimpleCommand(session, mkdirCmd);
|
||||
|
||||
doCopy(session, request);
|
||||
@ -103,6 +108,10 @@ public class ScpDeployer extends GenericSshDeployer
|
||||
"chgrp "
|
||||
+ request.getGroup()
|
||||
+ " "
|
||||
+ request.getBaseDir()
|
||||
+ "/"
|
||||
+ request.getDestDir()
|
||||
+ "/"
|
||||
+ request.getDestFile()
|
||||
+ "\n";
|
||||
executeSimpleCommand(session, chgrpCmd);
|
||||
@ -156,11 +165,12 @@ public class ScpDeployer extends GenericSshDeployer
|
||||
|
||||
try
|
||||
{
|
||||
String inputFile = request.getSrcFile();
|
||||
String outputFile = request.getDestFile();
|
||||
String outputDir = request.getDestDir();
|
||||
String srcFile = request.getSrcFile();
|
||||
String destFile = request.getDestFile();
|
||||
String destDir =
|
||||
request.getBaseDir() + "/" + request.getDestDir();
|
||||
// exec 'scp -t rfile' remotely
|
||||
String command = "scp -t " + outputDir + "/" + outputFile;
|
||||
String command = "scp -t " + destDir + "/" + destFile;
|
||||
System.out.println("Executing command: " + command);
|
||||
ChannelExec channel =
|
||||
(ChannelExec) session.openChannel(EXEC_CHANNEL);
|
||||
@ -180,15 +190,15 @@ public class ScpDeployer extends GenericSshDeployer
|
||||
while (tmp[0] != 0);
|
||||
|
||||
// send "C0644 filesize filename", where filename should not include '/'
|
||||
int filesize = (int) (new File(inputFile)).length();
|
||||
int filesize = (int) (new File(srcFile)).length();
|
||||
command = "C0644 " + filesize + " ";
|
||||
if (inputFile.lastIndexOf('/') > 0)
|
||||
if (srcFile.lastIndexOf('/') > 0)
|
||||
{
|
||||
command += inputFile.substring(inputFile.lastIndexOf('/') + 1);
|
||||
command += srcFile.substring(srcFile.lastIndexOf('/') + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
command += inputFile;
|
||||
command += srcFile;
|
||||
}
|
||||
command += "\n";
|
||||
|
||||
@ -203,7 +213,7 @@ public class ScpDeployer extends GenericSshDeployer
|
||||
while (tmp[0] != 0);
|
||||
|
||||
// send a content of inputFile
|
||||
FileInputStream fis = new FileInputStream(inputFile);
|
||||
FileInputStream fis = new FileInputStream(srcFile);
|
||||
byte[] buf = new byte[1024];
|
||||
while (true)
|
||||
{
|
||||
@ -231,7 +241,7 @@ public class ScpDeployer extends GenericSshDeployer
|
||||
String msg =
|
||||
"Error occured while deploying to remote host:"
|
||||
+ request.getHost();
|
||||
throw new TransferFailedException(msg,e);
|
||||
throw new TransferFailedException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user