FTP, FILE deployers work. ssh(scp) on the way

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113524 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
michal committed 2003-06-19 22:02:37 +00:00
1 parent db6e173b60
commit c441b0427a
6 files changed
+95 -46

No files matched your search

@@ -73,7 +73,7 @@ import org.apache.maven.project.Project;
* Default implemenataion of Artifact Deployer interface
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: DefaultArtifactDeployer.java,v 1.3 2003/06/19 10:52:25 michal Exp $
* @version $Id: DefaultArtifactDeployer.java,v 1.4 2003/06/19 22:02:37 michal Exp $
*/
public class DefaultArtifactDeployer implements ArtifactDeployer
{
@@ -205,35 +205,45 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
// trick add special values to context for default repository;
String repos =
(String) project.getContext().getVariable("maven.deploy.repos");
(String) project.getContext().getVariable("maven.repo.repos");
System.out.println( "repos: "+ repos );
String distSite = project.getDistributionSite();
if (distSite != null && distSite.length() > 0)
{
project.getContext().setVariable(
"maven.deploy.repo.central",
"maven.repo.central",
project.getDistributionSite());
project.getContext().setVariable(
"maven.deploy.repo.central.directory",
"maven.central.directory",
project.getDistributionDirectory());
repos = "central, " + repos;
}
String repositoryPath = getRepositoryPath(type, project, version);
if (repos == null || repos.length() == 0)
{
System.out.println("No remote repository is defined");
return;
}
String[] repoArray = StringUtils.split(repos, ",");
System.out.println(
"Will deploy to " + repoArray.length + " repo(s): " + repos);
String repositoryPath = getRepositoryPath(type, project, version);
for (int i = 0; i < repoArray.length; i++)
{
String repo = repoArray[i];
String repo = repoArray[i].trim();
System.out.println("Deploying to repo: " + repo);
MavenDeployRequest request =
new MavenDeployRequest(
repo,
project,
repo,
artifact,
@@ -249,11 +259,12 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
+ request.getOutputDir());
try
{
deployTool.performUpload(request);
deployTool.performUpload(request);
}
catch (Exception e)
{
throw new MavenException("Cannot deploy", e);
e.printStackTrace();
throw new MavenException("Cannot deploy. Reason:" + e.getMessage(), e);
}
}
@@ -64,7 +64,7 @@ import org.apache.maven.project.Project;
* The Bean which serves as Proxy for Jelly scripts To Artifact Deployement API
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: MavenDeployRequest.java,v 1.2 2003/06/19 10:52:25 michal Exp $
* @version $Id: MavenDeployRequest.java,v 1.3 2003/06/19 22:02:37 michal Exp $
*/
public class MavenDeployRequest extends DeployRequest
{
@@ -79,6 +79,7 @@ public class MavenDeployRequest extends DeployRequest
* @param outputFile
*/
public MavenDeployRequest(
String repositoryAlias,
Project project,
String repository,
String inputFile,
@@ -86,62 +87,63 @@ public class MavenDeployRequest extends DeployRequest
String outputFile)
{
super();
setRepositoryAlias(repositoryAlias);
String url =
(String) project.getContext().getVariable(
"maven.repo." + repository);
String username =
(String) project.getContext().getVariable(
"maven.deploy.repo." + repository + ".username");
"maven.repo." + repository + ".username");
System.out.println(repository + " username:" + username);
String password =
(String) project.getContext().getVariable(
"maven.deploy.repo." + repository + ".password");
"maven.repo." + repository + ".password");
System.out.println(repository + " password: '" + password + "'");
String passphrase =
(String) project.getContext().getVariable(
"maven.deploy.repo." + repository + ".passphrase");
"maven.repo." + repository + ".passphrase");
String privateKey =
(String) project.getContext().getVariable(
"maven.deploy.repo." + repository + ".privatekey");
String url =
(String) project.getContext().getVariable(
"maven.deploy.repo." + repository );
"maven.repo." + repository + ".privatekey");
String dir =
(String) project.getContext().getVariable(
"maven.deploy.repo." + repository + ".directory");
"maven.repo." + repository + ".directory");
String port =
(String) project.getContext().getVariable(
"maven.deploy.repo." + repository + ".port");
"maven.repo." + repository + ".port");
String remoteGroup =
(String) project.getContext().getVariable(
"maven.deploy.repo." + repository + ".remote.group");
(String) project.getContext().getVariable(
"maven.repo." + repository + ".remote.group");
String proxyHost =
(String) project.getContext().getVariable(
"maven.deploy.repo." + repository + ".proxy");
"maven.repo." + repository + ".proxy");
String proxyUser =
(String) project.getContext().getVariable(
"maven.deploy.repo." + repository + ".proxy.username");
"maven.repo." + repository + ".proxy.username");
String proxyPassword =
(String) project.getContext().getVariable(
"maven.deploy.repo." + repository + ".proxy.password");
"maven.repo." + repository + ".proxy.password");
String proxyPort =
(String) project.getContext().getVariable(
"maven.deploy." + repository + ".proxy.port");
"maven." + repository + ".proxy.port");
setUser(username);
setPass(password);
setPassphrase(passphrase);
setPrivateKey(url);
setPrivateKey(url.trim());
setGroup(remoteGroup);
setUrl(url);
setUrl(url.trim());
try
{
@@ -156,7 +158,7 @@ public class MavenDeployRequest extends DeployRequest
}
try
{
setProxyPort(Integer.parseInt(proxyPort));
setProxyPort(Integer.parseInt(proxyPort.trim()));
}
catch (Exception e)
{
@@ -59,12 +59,16 @@ package org.apache.maven.deploy;
/**
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: DeployRequest.java,v 1.1 2003/06/17 22:06:00 michal Exp $
* @version $Id: DeployRequest.java,v 1.2 2003/06/19 22:02:37 michal Exp $
*/
public class DeployRequest
{
public final static int UNKNOWN_PORT = -1;
private String repositoryAlias;
private String url;
private int port = UNKNOWN_PORT;
private String outputDir;
@@ -80,6 +84,14 @@ public class DeployRequest
private String passphrase;
private String privateKey;
/**
* @param repositoryAlias
*/
public void setRepositoryAlias(String repositoryAlias)
{
this.repositoryAlias = repositoryAlias;
}
public DeployRequest()
{
@@ -354,4 +366,13 @@ public class DeployRequest
return url.substring(url.indexOf("://") + 3);
}
/**
* @return
*/
public String getRepositoryAlias()
{
return repositoryAlias;
}
}
@@ -64,11 +64,10 @@ import org.apache.maven.deploy.deployers.SshDeployer;
import org.apache.maven.deploy.exceptions.DeployException;
import org.apache.maven.deploy.exceptions.UnsupportedProtocolDeployException;
/**
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: DeployTool.java,v 1.1 2003/06/17 22:06:00 michal Exp $
* @version $Id: DeployTool.java,v 1.2 2003/06/19 22:02:37 michal Exp $
*/
public class DeployTool
{
@@ -80,6 +79,12 @@ public class DeployTool
String url = request.getUrl();
Deployer deployer = null;
if (url == null || url.length() == 1)
{
throw new DeployException(
"No URL provided for repsoitory: "
+ request.getRepositoryAlias());
}
if (url.startsWith("http://"))
{
deployer = new HttpDeployer();
@@ -63,11 +63,10 @@ import org.apache.commons.io.FileUtils;
import org.apache.maven.deploy.DeployRequest;
import org.apache.maven.deploy.exceptions.DeployException;
/**
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: FileDeployer.java,v 1.1 2003/06/17 22:05:59 michal Exp $
* @version $Id: FileDeployer.java,v 1.2 2003/06/19 22:02:36 michal Exp $
*/
public class FileDeployer implements Deployer
{
@@ -76,16 +75,27 @@ public class FileDeployer implements Deployer
* @see org.apache.maven.fetch.fetchers.Fetcher#fetchUrl(java.lang.String, java.io.OutputStream)
*/
public void deploy(DeployRequest request) throws DeployException
{
{
try
{
File inputFile = new File( request.getInputFile() );
File outputFile = new File( request.getOutputDir(), request.getOutputFile());
File inputFile = new File(request.getInputFile());
File outputFile =
new File(request.getHost(), request.getOutputDir());
if (! outputFile.exists())
{
outputFile.mkdirs();
}
outputFile = new File( outputFile, request.getOutputFile());
System.out.println("Copining from: " + inputFile + " to: " + outputFile);
FileUtils.copyFile(inputFile, outputFile);
}
catch (IOException e)
{
throw new DeployException("Cannot copy file: " + e.getMessage());
}
}
throw new DeployException("Cannot copy file: " + e.getMessage());
}
}
}
@@ -77,7 +77,7 @@ import org.apache.maven.deploy.exceptions.DeployException;
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
*
* @version $Id: FtpDeployer.java,v 1.1 2003/06/17 22:05:59 michal Exp $
* @version $Id: FtpDeployer.java,v 1.2 2003/06/19 22:02:36 michal Exp $
*
* @todo account for username and password.
*/
@@ -91,8 +91,7 @@ public class FtpDeployer extends AbstractDeployer
{
String username = request.getUser();
String password = request.getPass();
String host = request.getHost();
String host = request.getHost();
FTPClient ftp = new FTPClient();
@@ -142,7 +141,8 @@ public class FtpDeployer extends AbstractDeployer
__main : try
{
if (ftp.login(username, password) == false)
System.out.println("username: '" + username +"' password: '"+ password+"'");
if (ftp.login(username.trim(), password.trim()) == false)
{
ftp.logout();
break __main;