diff --git a/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java b/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
index 76878fc7..eabff4f9 100644
--- a/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
+++ b/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
@@ -65,16 +65,18 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
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.project.Project;
import org.apache.maven.util.MD5Sum;
/**
*
- * Default implemenataion of Artifact Deployer interface
+ * Default implemenataion of Artifact Deployer interface.
+ *
*
* @author Michal Maczka
- * @version $Id: DefaultArtifactDeployer.java,v 1.8 2003/06/24 22:22:55 michal Exp $
+ * @version $Id: DefaultArtifactDeployer.java,v 1.9 2003/06/25 15:25:19 michal Exp $
*/
public class DefaultArtifactDeployer implements ArtifactDeployer
{
@@ -87,6 +89,7 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
/**
* @see ArtifactDeployer#deploy(String, String, Project)
+ *
* This is "5 files" version.
* It deploys (example):
* foo-20030620.124616.jar,
@@ -95,7 +98,6 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
* foo-SNAPSHOT.jar.md5
* foo-snapshot-version
*
- *
*/
public void deploy(String artifact, String type, Project project)
throws MavenException
@@ -108,12 +110,12 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
String repositoryFile =
getRepositoryFile(type, project, project.getCurrentVersion());
- String[] inputFilenames =
+ String[] srcFilenames =
{ file.getAbsolutePath(), md5File.getAbsolutePath()};
- String[] outputFilenames = { repositoryFile, repositoryFile + ".md5" };
+ String[] destFilenames = { repositoryFile, repositoryFile + ".md5" };
- doDeploy(inputFilenames, outputFilenames, repositoryPath, project);
+ doDeploy(srcFilenames, destFilenames, repositoryPath, project);
}
/**
@@ -131,24 +133,24 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
String repositoryPath =
getRepositoryPath(type, project, MavenConstants.SNAPSHOT_SIGNIFIER);
- String[] inputFilenames = new String[5];
- inputFilenames[0] = file.getAbsolutePath();
- inputFilenames[1] = file.getAbsolutePath();
- inputFilenames[2] = md5File.getAbsolutePath();
- inputFilenames[3] = md5File.getAbsolutePath();
- inputFilenames[4] = snapshotVersionFile.getAbsolutePath();
+ String[] srcFilenames = new String[5];
+ srcFilenames[0] = file.getAbsolutePath();
+ srcFilenames[1] = file.getAbsolutePath();
+ srcFilenames[2] = md5File.getAbsolutePath();
+ srcFilenames[3] = md5File.getAbsolutePath();
+ srcFilenames[4] = snapshotVersionFile.getAbsolutePath();
String out1 =
getRepositoryFile(type, project, MavenConstants.SNAPSHOT_SIGNIFIER);
String out2 = getRepositoryFile(type, project, snapshotVersion);
- String[] outputFilenames = new String[5];
- outputFilenames[0] = out1;
- outputFilenames[1] = out2;
- outputFilenames[2] = out1 + ".md5";
- outputFilenames[3] = out2 + ".md5";
- outputFilenames[4] = project.getArtifactId() + "-snapshot-version";
- doDeploy(inputFilenames, outputFilenames, repositoryPath, project);
+ String[] destFilenames = new String[5];
+ destFilenames[0] = out1;
+ destFilenames[1] = out2;
+ destFilenames[2] = out1 + ".md5";
+ destFilenames[3] = out2 + ".md5";
+ destFilenames[4] = project.getArtifactId() + "-snapshot-version";
+ doDeploy(srcFilenames, destFilenames, repositoryPath, project);
};
@@ -214,7 +216,8 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
{
destFile.mkdirs();
}
- destFile = new File(destFile, getRepositoryFile(type, project, version));
+ destFile =
+ new File(destFile, getRepositoryFile(type, project, version));
System.out.println(
"Copying: from '" + file + "' to: '" + destFile + "'");
FileUtils.copyFile(file, destFile);
@@ -239,9 +242,9 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
* @param snapshot
*/
private void doDeploy(
- String[] inputFilenames,
- String[] outputFilenames,
- String outputPath,
+ String[] srcFilenames,
+ String[] destFilenames,
+ String destPath,
Project project)
throws MavenException
{
@@ -284,37 +287,40 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
String repo = repoArray[i].trim();
System.out.println("Deploying to repo: " + repo);
- for (int j = 0; j < inputFilenames.length; j++)
+ for (int j = 0; j < srcFilenames.length; j++)
{
- MavenDeployRequest deployRequest =
- new MavenDeployRequest(
- repo,
- project,
- repo,
- inputFilenames[j],
- outputPath,
- outputFilenames[j]);
-
+ DeployRequest request = null;
try
{
+ request =
+ DeployRequestBuilder.getDeployRequest(
+ repo,
+ project,
+ repo,
+ srcFilenames[j],
+ destPath,
+ destFilenames[j]);
+
System.out.println(
"Deploying: '"
- + outputFilenames[j]
+ + destFilenames[j]
+ "' to host: '"
- + deployRequest.getHost()
+ + request.getHost()
+ "' remote path: '"
- + deployRequest.getOutputDir()
+ + request.getDestDir()
+ "' remote file: '"
- + deployRequest.getOutputFile());
- deployTool.performUpload(deployRequest);
+ + request.getDestFile());
+ deployTool.performUpload(request);
}
catch (Exception e)
{
- e.printStackTrace();
- throw new MavenException(
- "Cannot deploy. Reason:" + e.getMessage(),
- e);
+ String msg =
+ "Cannot deploy to: "
+ + request.getRepositoryAlias()
+ + ". Reason:"
+ + e.getMessage();
+ throw new MavenException(msg, e);
}
}
}
@@ -374,20 +380,6 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
}
- /**
- *
- * @todo Dirty hack util Repository Layout Service is used
- * @return
- */
- private String extensionForType(String type)
- {
- if (type.equals("ejb"))
- {
- return "jar";
- }
- return type;
- }
-
/**
*
* @param artifact
@@ -480,7 +472,20 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
}
return md5ChecksumFile;
+ }
+ /**
+ *
+ * @todo Dirty hack util Repository Layout Service is used
+ * @return
+ */
+ private String extensionForType(String type)
+ {
+ if (type.equals("ejb"))
+ {
+ return "jar";
+ }
+ return type;
}
}
diff --git a/artifact/src/main/org/apache/maven/artifact/deployer/DeployBean.java b/artifact/src/main/org/apache/maven/artifact/deployer/DeployBean.java
index 2129c5c2..ffa19ee7 100644
--- a/artifact/src/main/org/apache/maven/artifact/deployer/DeployBean.java
+++ b/artifact/src/main/org/apache/maven/artifact/deployer/DeployBean.java
@@ -63,10 +63,11 @@ import org.apache.maven.project.Project;
/**
*
- * The Bean which serves as Proxy for Jelly scripts To Artifact Deployement API
+ * The Bean which provides access to Artifact Deployement API
+ * for jelly scripts.
*
* @author Michal Maczka
- * @version $Id: DeployBean.java,v 1.1 2003/06/16 14:26:01 michal Exp $
+ * @version $Id: DeployBean.java,v 1.2 2003/06/25 15:25:19 michal Exp $
*/
public class DeployBean
{
diff --git a/artifact/src/main/org/apache/maven/artifact/deployer/MavenDeployRequest.java b/artifact/src/main/org/apache/maven/artifact/deployer/DeployRequestBuilder.java
similarity index 76%
rename from artifact/src/main/org/apache/maven/artifact/deployer/MavenDeployRequest.java
rename to artifact/src/main/org/apache/maven/artifact/deployer/DeployRequestBuilder.java
index a9bf2e17..af1e7c74 100644
--- a/artifact/src/main/org/apache/maven/artifact/deployer/MavenDeployRequest.java
+++ b/artifact/src/main/org/apache/maven/artifact/deployer/DeployRequestBuilder.java
@@ -57,38 +57,39 @@ package org.apache.maven.artifact.deployer;
*/
import org.apache.maven.deploy.DeployRequest;
+import org.apache.maven.deploy.exceptions.DeployException;
import org.apache.maven.project.Project;
/**
*
- * The Bean which serves as Proxy for Jelly scripts To Artifact Deployement API
+ * Perform mapping between project's properties and attributes of DeployRequest class.
*
* @author Michal Maczka
- * @version $Id: MavenDeployRequest.java,v 1.6 2003/06/25 12:33:11 michal Exp $
+ * @version $Id: DeployRequestBuilder.java,v 1.1 2003/06/25 15:25:19 michal Exp $
*/
-public class MavenDeployRequest extends DeployRequest
+public class DeployRequestBuilder
{
/**
*
* @param project
- * @param repository This is alias name of the repository
- * like repo1 taken from maven.deploy.repos= repo1, repo2
- * @param inputDir
- * @param outputDir
- * @param outputFile
+ * @param repository Alias(name) of the repository
+ * like repo1 taken from propertt: maven.deploy.repos= repo1, repo2
+ * @param srcDir
+ * @param srcDir
+ * @param destFile
*/
- public MavenDeployRequest(
+ public static DeployRequest getDeployRequest(
String repositoryAlias,
Project project,
String repository,
- String inputFile,
- String outputDir,
- String outputFile)
+ String srcFile,
+ String destDir,
+ String destFile) throws DeployException
{
- super();
- setRepositoryAlias(repositoryAlias);
+ DeployRequest request = new DeployRequest();
+ request.setRepositoryAlias(repositoryAlias);
String url =
(String) project.getContext().getVariable(
"maven.repo." + repository);
@@ -135,47 +136,48 @@ public class MavenDeployRequest extends DeployRequest
(String) project.getContext().getVariable(
"maven." + repository + ".proxy.port");
- setUser(username);
- setPass(password);
- setPassphrase(passphrase);
- setPrivateKey(privateKey);
- setGroup(remoteGroup);
- setUrl(url);
- setProxyHost(proxyHost);
- setProxyUser(proxyUser);
- setProxyPass(proxyPassword);
+ request.setUser(username);
+ request.setPassword(password);
+ request.setPassphrase(passphrase);
+ request.setPrivateKey(privateKey);
+ request.setGroup(remoteGroup);
+ request.setUrl(url);
+ request.setProxyHost(proxyHost);
+ request.setProxyUser(proxyUser);
+ request.setProxyPass(proxyPassword);
if (port != null)
{
try
{
- setPort(Integer.parseInt(port));
+ request.setPort(Integer.parseInt(port));
}
catch (Exception e)
{
- //throw new DeployException("maven.repo." + repository + ".port should be an integer");
+ throw new DeployException("maven.repo." + repository + ".port should be an integer");
}
}
if (proxyPort != null)
{
try
{
- setProxyPort(Integer.parseInt(proxyPort.trim()));
+ request.setProxyPort(Integer.parseInt(proxyPort.trim()));
}
catch (Exception e)
{
- //throw new DeployException("maven.repo." + repository + ".proxy.port should be an integer");
+ throw new DeployException("maven.repo." + repository + ".proxy.port should be an integer");
}
}
- setInputFile(inputFile);
+ request.setSrcFile(srcFile);
if (dir != null)
{
- outputDir = dir + "/" + outputDir;
+ destDir = dir + "/" + destDir;
}
- setOutputFile(outputFile);
- setOutputDir(outputDir);
+ request.setDestFile(destFile);
+ request.setDestDir(destDir);
+ return request;
}
diff --git a/artifact/src/main/org/apache/maven/deploy/DeployRequest.java b/artifact/src/main/org/apache/maven/deploy/DeployRequest.java
index 97230b01..90618739 100644
--- a/artifact/src/main/org/apache/maven/deploy/DeployRequest.java
+++ b/artifact/src/main/org/apache/maven/deploy/DeployRequest.java
@@ -59,31 +59,39 @@ package org.apache.maven.deploy;
/**
*
* @author Michal Maczka
- * @version $Id: DeployRequest.java,v 1.3 2003/06/24 22:22:55 michal Exp $
+ * @version $Id: DeployRequest.java,v 1.4 2003/06/25 15:25:19 michal Exp $
*/
public class DeployRequest
{
-
public final static int UNKNOWN_PORT = -1;
+ public final static String HEADER_USER_AGENT =
+ "Maven-Deploy-" + DeployTool.VERSION;
-
private String repositoryAlias;
private String url;
private int port = UNKNOWN_PORT;
- private String outputDir;
- private String outputFile;
- private String inputFile;
+ private String destDir;
+ private String destFile;
+ private String srcFile;
/*
- * Resource access user / pass /group
+ * Resource access user / password /group
*/
private String user;
- private String pass;
+ private String password;
private String group;
private String passphrase;
private String privateKey;
+ /*
+ * Proxy server settings. If proxy host is not null, settings will be used.
+ */
+ private String proxyHost = null;
+ private String proxyUser = null;
+ private String proxyPass = null;
+ private int proxyPort = UNKNOWN_PORT;
+
/**
* @param repositoryAlias
*/
@@ -92,27 +100,6 @@ public class DeployRequest
this.repositoryAlias = repositoryAlias;
}
- public DeployRequest()
- {
-
- }
-
- public DeployRequest(String url)
- {
- this.url = url;
- }
-
- // private boolean resumeDownload = false;
- private String headerUserAgent = "Maven-Deploy-" + DeployTool.VERSION;
-
- /*
- * Proxy settings. If proxyHost is not null, settings will be used.
- */
- private String proxyHost = null;
- private String proxyUser = null;
- private String proxyPass = null;
- private int proxyPort = UNKNOWN_PORT;
-
/**
* @return
*/
@@ -182,79 +169,71 @@ public class DeployRequest
*/
public String getHeaderUserAgent()
{
- return headerUserAgent;
- }
-
- /**
- * @param headerUserAgent
- */
- public void setHeaderUserAgent(String headerUserAgent)
- {
- this.headerUserAgent = headerUserAgent;
+ return HEADER_USER_AGENT;
}
/**
* @return
*/
- public String getInputFile()
+ public String getSrcFile()
{
- return inputFile;
+ return srcFile;
}
/**
- * @param inputFile
+ * @param srcFile
*/
- public void setInputFile(String inputFile)
+ public void setSrcFile(String inputFile)
{
- this.inputFile = inputFile;
+ this.srcFile = inputFile;
}
/**
* @return
*/
- public String getOutputDir()
+ public String getDestDir()
{
- return outputDir;
+ return destDir;
}
/**
- * @param outputDir
+ * @param destDir
*/
- public void setOutputDir(String outputDir)
+ public void setDestDir(String outputDir)
{
- this.outputDir = outputDir;
+ this.destDir = outputDir;
}
/**
* @return
*/
- public String getOutputFile()
+ public String getDestFile()
{
- return outputFile;
+ return destFile;
}
/**
- * @param outputFile
+ * @param destFile
*/
- public void setOutputFile(String outputFile)
+ public void setDestFile(String outputFile)
{
- this.outputFile = outputFile;
+ this.destFile = outputFile;
}
/**
* @return
*/
- public String getPass()
+ public String getPassword()
{
- return pass;
+ return password;
}
/**
- * @param pass
+ * @param password
*/
- public void setPass(String pass)
+ public void setPassword(String pass)
{
- this.pass = pass;
+ this.password = pass;
}
/**
@@ -359,9 +338,9 @@ public class DeployRequest
*/
public String getHost()
{
- if (url == null )
+ if (url == null)
{
- return "localhost";
+ return "localhost";
}
return url.substring(url.indexOf("://") + 3);
}
@@ -371,7 +350,7 @@ public class DeployRequest
*/
public String getRepositoryAlias()
{
-
+
return repositoryAlias;
}
diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/FileDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/FileDeployer.java
index 24fcf6f6..fac0096b 100644
--- a/artifact/src/main/org/apache/maven/deploy/deployers/FileDeployer.java
+++ b/artifact/src/main/org/apache/maven/deploy/deployers/FileDeployer.java
@@ -66,7 +66,7 @@ import org.apache.maven.deploy.exceptions.DeployException;
/**
*
* @author Michal Maczka
- * @version $Id: FileDeployer.java,v 1.4 2003/06/24 22:22:54 michal Exp $
+ * @version $Id: FileDeployer.java,v 1.5 2003/06/25 15:25:18 michal Exp $
*/
public class FileDeployer implements Deployer
{
@@ -80,16 +80,16 @@ public class FileDeployer implements Deployer
{
try
{
- File inputFile = new File(request.getInputFile());
+ File inputFile = new File(request.getSrcFile());
File outputFile =
- new File(request.getHost(), request.getOutputDir());
+ new File(request.getHost(), request.getDestDir());
if (! outputFile.exists())
{
outputFile.mkdirs();
}
- outputFile = new File( outputFile, request.getOutputFile());
+ outputFile = new File( outputFile, request.getDestFile());
FileUtils.copyFile(inputFile, outputFile);
}
catch (IOException e)
diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java
index 8b8ebf61..9b49501d 100644
--- a/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java
+++ b/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java
@@ -80,7 +80,7 @@ import org.apache.maven.deploy.exceptions.DeployException;
*
* @author Jason van Zyl
* @author Michal Maczka
- * @version $Id: FtpDeployer.java,v 1.3 2003/06/24 22:22:54 michal Exp $
+ * @version $Id: FtpDeployer.java,v 1.4 2003/06/25 15:25:18 michal Exp $
*
*
*/
@@ -95,7 +95,7 @@ public class FtpDeployer extends AbstractDeployer
public void deploy(DeployRequest request) throws DeployException
{
String username = request.getUser();
- String password = request.getPass();
+ String password = request.getPassword();
String host = request.getHost();
FTPClient ftp = new FTPClient();
@@ -159,13 +159,13 @@ public class FtpDeployer extends AbstractDeployer
// Use passive mode as default because most of us are
// behind firewalls these days.
ftp.enterLocalPassiveMode();
- String workingDir = request.getOutputDir();
- String filename = request.getOutputFile();
+ 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.storeFile(filename, new FileInputStream(request.getInputFile()));
+ ftp.storeFile(filename, new FileInputStream(request.getSrcFile()));
ftp.logout();
}
catch (FTPConnectionClosedException e)
diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/GenericSshDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/GenericSshDeployer.java
index 616be894..ee80d865 100644
--- a/artifact/src/main/org/apache/maven/deploy/deployers/GenericSshDeployer.java
+++ b/artifact/src/main/org/apache/maven/deploy/deployers/GenericSshDeployer.java
@@ -79,7 +79,7 @@ import com.jcraft.jsch.UserInfo;
* assuming the standard port of 22.
*
*
- * @version $Id: GenericSshDeployer.java,v 1.1 2003/06/25 12:33:11 michal Exp $
+ * @version $Id: GenericSshDeployer.java,v 1.2 2003/06/25 15:25:18 michal Exp $
* @todo still have to account for differing setups for people deploying to
* their own sites and to the central repository.
*/
@@ -191,7 +191,7 @@ public abstract class GenericSshDeployer extends AbstractDeployer
*/
public String getPassword()
{
- return request.getPass();
+ return request.getPassword();
}
/* (non-Javadoc)
diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/HttpDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/HttpDeployer.java
index 19222274..6dda7a63 100644
--- a/artifact/src/main/org/apache/maven/deploy/deployers/HttpDeployer.java
+++ b/artifact/src/main/org/apache/maven/deploy/deployers/HttpDeployer.java
@@ -76,7 +76,7 @@ import org.apache.maven.deploy.exceptions.DeployException;
* An HTTP deployer based the Commons HttpClient library.
*
* @author Jason van Zyl
- * @version $Id: HttpDeployer.java,v 1.2 2003/06/24 22:22:54 michal Exp $
+ * @version $Id: HttpDeployer.java,v 1.3 2003/06/25 15:25:18 michal Exp $
*
* @todo still have to account for differing setups for people deploying to
* their own sites and to the central repository.
@@ -105,7 +105,7 @@ public class HttpDeployer extends AbstractDeployer
Credentials creds =
new UsernamePasswordCredentials(
request.getUser(),
- request.getPass());
+ request.getPassword());
//create a singular HttpClient object
HttpClient client = new HttpClient();
@@ -131,11 +131,11 @@ public class HttpDeployer extends AbstractDeployer
try
{
- method.setRequestBody(new FileInputStream(request.getInputFile()));
+ method.setRequestBody(new FileInputStream(request.getSrcFile()));
}
catch(FileNotFoundException io)
{
- throw new DeployException("input file: '"+ request.getInputFile() + " not found ");
+ throw new DeployException("input file: '"+ request.getSrcFile() + " not found ");
}
//turn follow redirects off
diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/SFtpDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/SFtpDeployer.java
index 85cb3874..94f23043 100644
--- a/artifact/src/main/org/apache/maven/deploy/deployers/SFtpDeployer.java
+++ b/artifact/src/main/org/apache/maven/deploy/deployers/SFtpDeployer.java
@@ -67,17 +67,17 @@ import com.jcraft.jsch.SftpATTRS;
import com.jcraft.jsch.SftpException;
/**
- * An SSH2 SFTP deployer
+ * An SSH2/SFTP deployer
*
* @author Michal Maczka
- * @version $Revision: 1.2 $ $Date: 2003/06/25 12:33:11 $
+ * @version $Revision: 1.3 $ $Date: 2003/06/25 15:25:18 $
*/
public class SFtpDeployer extends GenericSshDeployer
{
public final static String PROTOCOL = "sftp://";
- public final static String SFTP_CHANNEL = "sftp";
-
+ private final static String SFTP_CHANNEL = "sftp";
+ private static final int S_IFDIR = 0x4000;
/**
* @see Deployer#project
@@ -96,7 +96,7 @@ public class SFtpDeployer extends GenericSshDeployer
}
catch (NumberFormatException e)
{
- throw new DeployException("For sftp protocol remote group should be an integer");
+ throw new DeployException("SFTP deployer: remote group should be an integer");
}
Session session = getSession(request);
@@ -107,10 +107,9 @@ public class SFtpDeployer extends GenericSshDeployer
channel.connect();
// iterate over all directories in the path. try to create
// directory
- String[] dirs = StringUtils.split(request.getOutputDir(), "/");
+ String[] dirs = StringUtils.split(request.getDestDir(), "/");
for (int i = 0; i < dirs.length; i++)
- {
- System.out.println("processing: " + dirs[i]);
+ {
try
{
SftpATTRS attrs = channel.stat(dirs[i]);
@@ -122,9 +121,7 @@ public class SFtpDeployer extends GenericSshDeployer
else
{
throw new DeployException(
- "Remote path:"
- + request.getOutputDir()
- + "is not correct");
+ "Incorrect remote path:" + request.getDestDir());
}
}
catch (Exception e)
@@ -136,45 +133,34 @@ public class SFtpDeployer extends GenericSshDeployer
}
- channel.put(request.getInputFile(), request.getOutputFile());
+ channel.put(request.getSrcFile(), request.getDestFile());
if (groupId != null)
{
- channel.chgrp(groupId.intValue(), request.getOutputFile());
+ channel.chgrp(groupId.intValue(), request.getDestFile());
}
}
catch (SftpException e)
{
- throw new DeployException(
- "Cannot deploy. Reason: " + e.getMessage(),
- e);
+
+ String msg =
+ "Error occured while deploying to remote host:"
+ + request.getHost();
+ throw new DeployException(msg, e);
}
catch (JSchException e)
{
- throw new DeployException(
- "Cannot deploy. Reason: " + e.getMessage(),
- e);
+ String msg =
+ "Error occured while deploying to remote host:"
+ + request.getHost();
+ throw new DeployException(msg, e);
}
finally
{
- try
- {
- channel.disconnect();
- }
- catch (Exception e)
- {
- //just ignore.
- }
- try
- {
- session.disconnect();
- }
- catch (Exception e)
- {
- // just ignore.
- }
+ channel.disconnect();
+ session.disconnect();
}
}
diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/ScpDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/ScpDeployer.java
index ac210234..b5ab5db6 100644
--- a/artifact/src/main/org/apache/maven/deploy/deployers/ScpDeployer.java
+++ b/artifact/src/main/org/apache/maven/deploy/deployers/ScpDeployer.java
@@ -58,8 +58,6 @@ package org.apache.maven.deploy.deployers;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -67,14 +65,13 @@ import org.apache.maven.deploy.DeployRequest;
import org.apache.maven.deploy.exceptions.DeployException;
import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
/**
- * An SSH2 SFTP deployer
+ * An SSH2/SCP deployer
*
* @author Michal Maczka
- * @version $Revision: 1.1 $ $Date: 2003/06/25 12:33:11 $
+ * @version $Revision: 1.2 $ $Date: 2003/06/25 15:25:18 $
*/
public class ScpDeployer extends GenericSshDeployer
{
@@ -95,34 +92,26 @@ public class ScpDeployer extends GenericSshDeployer
try
{
- //String scpCmd = "scp -t " + request.getOutputFile() + "\n";
- executeSimpleCommand(
- session,
- "mkdir -p " + request.getOutputDir() + "\n");
-
+ String mkdirCmd = "mkdir -p " + request.getDestDir() + "\n";
+ executeSimpleCommand(session, mkdirCmd);
+
doCopy(session, request);
if (request.getGroup() != null)
{
- executeSimpleCommand(
- session,
+
+ String chgrpCmd =
"chgrp "
+ request.getGroup()
+ " "
- + request.getOutputFile()
- + "\n");
+ + request.getDestFile()
+ + "\n";
+ executeSimpleCommand(session, chgrpCmd);
}
}
finally
{
- try
- {
- session.disconnect();
- }
- catch (Exception e)
- {
- // just ignore.
- }
+ session.disconnect();
}
}
@@ -150,24 +139,16 @@ public class ScpDeployer extends GenericSshDeployer
}
finally
{
- //when channel cannot be closed it is still ok. this "local"
- //failure is not global failure
if (channel != null)
{
- try
- {
- channel.disconnect();
- }
- catch (Exception e)
- {
- //ignore
- }
+ channel.disconnect();
}
}
}
/**
- * Copy artifact file using streams (pipes)
+ * Copy artifact to remote host.
+ * Code extracted from JSCH exaples
*/
private void doCopy(Session session, DeployRequest request)
throws DeployException
@@ -175,10 +156,10 @@ public class ScpDeployer extends GenericSshDeployer
try
{
- String inputFile = request.getInputFile();
- String outputFile = request.getOutputFile();
- String outputDir = request.getOutputDir();
- // exec 'scp -t rfile' remotely
+ String inputFile = request.getSrcFile();
+ String outputFile = request.getDestFile();
+ String outputDir = request.getDestDir();
+ // exec 'scp -t rfile' remotely
String command = "scp -t " + outputDir + "/" + outputFile;
System.out.println("Executing command: " + command);
ChannelExec channel =
@@ -245,24 +226,12 @@ public class ScpDeployer extends GenericSshDeployer
}
while (tmp[0] != 0);
}
- catch (FileNotFoundException e)
+ catch (Exception e)
{
-
- throw new DeployException(
- "Input file was not found: " + request.getInputFile(),
- e);
- }
- catch (IOException e)
- {
- throw new DeployException(
- "IO error while sending file: " + request.getInputFile(),
- e);
- }
- catch (JSchException e)
- {
- throw new DeployException(
- "Error occured while copying file to remote host",
- e);
+ String msg =
+ "Error occured while deploying to remote host:"
+ + request.getHost();
+ throw new DeployException(msg,e);
}
}