finalise implementation of legacy deployment method
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115535 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
1 parent
d529e06834
commit
2c2b0e5aac
10 files changed
+214
-110
No files matched your search
+81
-15
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
-->
|
||||
|
||||
|
||||
<project
|
||||
xmlns:j="jelly:core"
|
||||
xmlns:define="jelly:define"
|
||||
@@ -32,15 +31,11 @@
|
||||
|
||||
<define:taglib uri="artifact">
|
||||
|
||||
|
||||
<!-- For times the same bean is used. -->
|
||||
|
||||
|
||||
<define:jellybean
|
||||
name="install"
|
||||
method="install"
|
||||
className="org.apache.maven.artifact.deployer.DeployBean"/>
|
||||
|
||||
|
||||
<define:jellybean
|
||||
name="install-snapshot"
|
||||
@@ -64,11 +59,30 @@
|
||||
<j:when test="${legacy}">
|
||||
<maven:makeRelativePath basedir="${basedir}" var="artifact" path="${artifact}" separator="/" />
|
||||
<util:file var="f" name="${artifact}" />
|
||||
<j:set var="filename" value="${f.name}" />
|
||||
<j:if test="${filename.indexOf(pom.currentVersion) == '-1'}">
|
||||
<j:set var="filename" value="${pom.artifactId}-${pom.currentVersion}.${type}" />
|
||||
<j:if test="${typeHandler != null}">
|
||||
<util:file var="f" name="${typeHandler.constructRepositoryFullPath(type, pom, pom.currentVersion)}" />
|
||||
<j:set var="filename" value="${f.name}" />
|
||||
</j:if>
|
||||
</j:if>
|
||||
<maven:makeRelativePath basedir="${basedir}" var="projectFilename" path="${project.file}" separator="/" />
|
||||
<j:set var="pomFilename" value="${pom.artifactId}-${pom.currentVersion}.pom" />
|
||||
<deploy:artifact
|
||||
assureDirectoryCommand="mkdir -p"
|
||||
type="${type}"
|
||||
type="poms"
|
||||
artifact="${projectFilename}"
|
||||
targetFilename="${pomFilename}"
|
||||
siteCommand="cd @deployDirectory@; chmod g+w ${pomFilename}; chgrp ${maven.remote.group} ${pomFilename}"
|
||||
/>
|
||||
<deploy:artifact
|
||||
assureDirectoryCommand="mkdir -p"
|
||||
type="${type}s"
|
||||
handler="${typeHandler}"
|
||||
artifact="${artifact}"
|
||||
siteCommand="cd @deployDirectory@; chmod g+w ${f.name}; chgrp ${maven.remote.group} ${f.name}"
|
||||
targetFilename="${filename}"
|
||||
siteCommand="cd @deployDirectory@; chmod g+w ${filename}; chgrp ${maven.remote.group} ${filename}"
|
||||
/>
|
||||
</j:when>
|
||||
<j:otherwise>
|
||||
@@ -87,14 +101,50 @@
|
||||
|
||||
<j:choose>
|
||||
<j:when test="${legacy}">
|
||||
<!-- TODO: what about -snapshot-versioa, SNAPSHOT symlink? -->
|
||||
<maven:makeRelativePath basedir="${basedir}" var="artifact" path="${artifact}" separator="/" />
|
||||
<util:file var="f" name="${artifact}" />
|
||||
<maven:snapshot project="${pom}"/>
|
||||
<j:useBean var="strings" class="org.apache.commons.lang.StringUtils"/>
|
||||
<j:set var="replace" value="${pom.artifactId}-" />
|
||||
<j:set var="snapshotVersion" value='${strings.replace(snapshotSignature, replace, "")}' />
|
||||
<j:set var="filename" value="${f.name}" />
|
||||
<j:choose>
|
||||
<j:when test="${filename.indexOf(pom.currentVersion) == '-1'}">
|
||||
<j:choose>
|
||||
<j:when test="${typeHandler != null}">
|
||||
<util:file var="f" name="${typeHandler.constructRepositoryFullPath(type, pom, snapshotVersion)}" />
|
||||
<j:set var="timestampName" value="${f.name}" />
|
||||
<util:file var="f" name="${typeHandler.constructRepositoryFullPath(type, pom, 'SNAPSHOT')}" />
|
||||
<j:set var="snapshotName" value="${f.name}" />
|
||||
</j:when>
|
||||
<j:otherwise>
|
||||
<j:set var="timestampName" value="${pom.artifactId}-${snapshotVersion}.${type}" />
|
||||
<j:set var="snapshotName" value="${pom.artifactId}-SNAPSHOT.${type}" />
|
||||
</j:otherwise>
|
||||
</j:choose>
|
||||
</j:when>
|
||||
<j:otherwise>
|
||||
<j:set var="timestampName" value='${strings.replace(f.name, pom.currentVersion, snapshotVersion)}' />
|
||||
<j:set var="snapshotName" value='${strings.replace(f.name, pom.currentVersion, "SNAPSHOT")}' />
|
||||
</j:otherwise>
|
||||
</j:choose>
|
||||
<maven:makeRelativePath basedir="${basedir}" var="projectFilename" path="${project.file}" separator="/" />
|
||||
<j:set var="pomFilename" value="${pom.artifactId}-${snapshotVersion}.pom" />
|
||||
<j:set var="pomSnapshotName" value="${pom.artifactId}-SNAPSHOT.pom" />
|
||||
<deploy:artifact
|
||||
assureDirectoryCommand="mkdir -p"
|
||||
type="${type}"
|
||||
type="poms"
|
||||
artifact="${projectFilename}"
|
||||
targetFilename="${pomFilename}"
|
||||
siteCommand="cd @deployDirectory@; chmod g+w ${pomFilename}; chgrp ${maven.remote.group} ${pomFilename}; rm -f ${pomSnapshotName}; ln -s ${pomFilename} ${pomSnapshotName}; echo ${snapshotVersion} > ${pom.artifactId}-snapshot-version"
|
||||
/>
|
||||
<deploy:artifact
|
||||
assureDirectoryCommand="mkdir -p"
|
||||
type="${type}s"
|
||||
handler="${typeHandler}"
|
||||
targetFilename="${timestampName}"
|
||||
artifact="${artifact}"
|
||||
siteCommand="cd @deployDirectory@; chmod g+w ${f.name}; chgrp ${maven.remote.group} ${f.name}"
|
||||
siteCommand="cd @deployDirectory@; chmod g+w ${timestampName}; chgrp ${maven.remote.group} ${timestampName}; rm -f ${snapshotName}; ln -s ${timestampName} ${snapshotName}; echo ${snapshotVersion} > ${pom.artifactId}-snapshot-version"
|
||||
/>
|
||||
</j:when>
|
||||
<j:otherwise>
|
||||
@@ -195,6 +245,8 @@
|
||||
<define:taglib uri="deploy">
|
||||
<define:tag name="artifact">
|
||||
|
||||
<ant:echo>DEPRECATED: use of deploy:artifact tag and the legacy deploy method are deprecated</ant:echo>
|
||||
|
||||
<!--
|
||||
||
|
||||
|| If the ${maven.username} value isn't set then the deployment
|
||||
@@ -228,6 +280,16 @@
|
||||
var="resolvedDirectory"
|
||||
value="${siteDirectory}/${pom.artifactDirectory}/${type}"
|
||||
/>
|
||||
<!-- Note: must be called something different to the artifact parameter so they don't clash -->
|
||||
<j:if test="${handler != null}">
|
||||
<j:useBean var="mavenTool" class="org.apache.maven.util.MavenTool"/>
|
||||
<j:set var="len" value="${type.length()-1}" />
|
||||
<j:set var="baseType" value="${type.substring(0,mavenTool.toInteger(len.toString()))}" />
|
||||
<j:set
|
||||
var="resolvedDirectory"
|
||||
value="${siteDirectory}/${handler.constructRepositoryDirectoryPath(baseType, pom)}"
|
||||
/>
|
||||
</j:if>
|
||||
</j:when>
|
||||
<j:otherwise>
|
||||
<j:set
|
||||
@@ -238,7 +300,7 @@
|
||||
</j:choose>
|
||||
|
||||
<ant:echo>
|
||||
Moving ${artifact} to the ${resolvedDirectory} on ${siteAddress}
|
||||
Copying ${artifact} to the ${resolvedDirectory} on ${siteAddress}
|
||||
</ant:echo>
|
||||
|
||||
<!--
|
||||
@@ -249,13 +311,17 @@
|
||||
|
||||
<j:set var="assureDirectoryCommandX" value="${assureDirectoryCommand}X"/>
|
||||
<j:if test="${assureDirectoryCommandX != 'X'}">
|
||||
<ant:exec dir="." executable="${commander}">
|
||||
<ant:exec dir="." executable="${commander}" failonerror="true">
|
||||
<ant:arg line="${maven.ssh.args} -l ${username} ${siteAddress} '${assureDirectoryCommand} ${resolvedDirectory}'"/>
|
||||
</ant:exec>
|
||||
</j:if>
|
||||
|
||||
<ant:exec dir="." executable="${copier}">
|
||||
<ant:arg line="${maven.scp.args} ${artifact} ${username}@${siteAddress}:${resolvedDirectory}"/>
|
||||
<j:set var="args" value="${maven.scp.args} ${artifact} ${username}@${siteAddress}:${resolvedDirectory}" />
|
||||
<j:if test="${targetFilename != null}">
|
||||
<j:set var="args" value="${args}/${targetFilename}" />
|
||||
</j:if>
|
||||
<ant:exec dir="." executable="${copier}" failonerror="true">
|
||||
<ant:arg line="${args}" />
|
||||
</ant:exec>
|
||||
|
||||
<!--
|
||||
@@ -278,7 +344,7 @@
|
||||
Executing ${siteCommand} with the username ${username} on ${siteAddress}
|
||||
</ant:echo>
|
||||
|
||||
<ant:exec dir="." executable="${commander}">
|
||||
<ant:exec dir="." executable="${commander}" failonerror="true">
|
||||
<ant:arg line="${maven.ssh.args} -l ${username} ${siteAddress} '${siteCommand}'"/>
|
||||
</ant:exec>
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<pomVersion>3</pomVersion>
|
||||
<id>maven-artifact-plugin</id>
|
||||
<name>Maven Artifact Plugin</name>
|
||||
<!-- WARNING: some dependency checks will break if we get to 1.10, need to go to 2.0 from there -->
|
||||
<currentVersion>1.3-SNAPSHOT</currentVersion>
|
||||
<description/>
|
||||
<shortDescription>Tools to manage artifacts and deployment</shortDescription>
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.apache.maven.util.MD5Sum;
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: DefaultArtifactDeployer.java,v 1.20 2004/06/23 13:04:28 brett Exp $
|
||||
* @version $Id: DefaultArtifactDeployer.java,v 1.21 2004/06/25 13:50:05 brett Exp $
|
||||
*/
|
||||
public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
{
|
||||
@@ -103,25 +103,29 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
file = getFileForArtifact(artifact);
|
||||
}
|
||||
File md5File = createMD5Checksum(file);
|
||||
String repositoryPath =
|
||||
handler.constructRepositoryFullPath(type, project, project.getCurrentVersion());
|
||||
try {
|
||||
String repositoryPath =
|
||||
handler.constructRepositoryFullPath(type, project, project.getCurrentVersion());
|
||||
|
||||
List srcFiles = new ArrayList();
|
||||
srcFiles.add(file.getAbsolutePath());
|
||||
srcFiles.add(md5File.getAbsolutePath());
|
||||
List srcFiles = new ArrayList();
|
||||
srcFiles.add(file.getAbsolutePath());
|
||||
srcFiles.add(md5File.getAbsolutePath());
|
||||
|
||||
List destFiles = new ArrayList();
|
||||
destFiles.add(repositoryPath);
|
||||
destFiles.add(repositoryPath + ".md5");
|
||||
|
||||
List destFiles = new ArrayList();
|
||||
destFiles.add(repositoryPath);
|
||||
destFiles.add(repositoryPath + ".md5");
|
||||
|
||||
//do not deploy POM twice
|
||||
if (DEPLOY_POM && !POM_TYPE.equals(type))
|
||||
{
|
||||
deploy(artifact, POM_TYPE, project, POM_ARTIFACT_TYPE_HANDLER);
|
||||
//do not deploy POM twice
|
||||
if (DEPLOY_POM && !POM_TYPE.equals(type))
|
||||
{
|
||||
deploy(artifact, POM_TYPE, project, POM_ARTIFACT_TYPE_HANDLER);
|
||||
}
|
||||
doDeploy(srcFiles, destFiles, project);
|
||||
}
|
||||
finally {
|
||||
//Delete md5 file
|
||||
md5File.delete();
|
||||
}
|
||||
doDeploy(srcFiles, destFiles, project);
|
||||
//Delete md5 file
|
||||
md5File.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,43 +148,49 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
File md5File = createMD5Checksum(file);
|
||||
File snapshotVersionFile =
|
||||
createSnapshotVersionFile(file, snapshotSignature, project, type);
|
||||
try {
|
||||
List srcFiles = new ArrayList();
|
||||
srcFiles.add(file.getAbsolutePath());
|
||||
srcFiles.add(md5File.getAbsolutePath());
|
||||
srcFiles.add(file.getAbsolutePath());
|
||||
srcFiles.add(md5File.getAbsolutePath());
|
||||
|
||||
List srcFiles = new ArrayList();
|
||||
srcFiles.add(file.getAbsolutePath());
|
||||
srcFiles.add(md5File.getAbsolutePath());
|
||||
srcFiles.add(file.getAbsolutePath());
|
||||
srcFiles.add(md5File.getAbsolutePath());
|
||||
srcFiles.add(snapshotVersionFile.getAbsolutePath());
|
||||
String snapshotFilename =
|
||||
handler.constructRepositoryFullPath(
|
||||
type,
|
||||
project,
|
||||
MavenConstants.SNAPSHOT_SIGNIFIER);
|
||||
String timestampedFilename =
|
||||
handler.constructRepositoryFullPath(type, project, snapshotSignature);
|
||||
|
||||
String snapshotFilename =
|
||||
handler.constructRepositoryFullPath(
|
||||
type,
|
||||
project,
|
||||
MavenConstants.SNAPSHOT_SIGNIFIER);
|
||||
String timestampedFilename =
|
||||
handler.constructRepositoryFullPath(type, project, snapshotSignature);
|
||||
String snapshotVersionsFilename =
|
||||
handler.constructRepositoryDirectoryPath(type, project)
|
||||
+ project.getArtifactId()
|
||||
+ "-snapshot-version";
|
||||
List destFiles = new ArrayList();
|
||||
destFiles.add(snapshotFilename);
|
||||
destFiles.add(snapshotFilename + ".md5");
|
||||
destFiles.add(timestampedFilename);
|
||||
destFiles.add(timestampedFilename + ".md5");
|
||||
|
||||
List destFiles = new ArrayList();
|
||||
destFiles.add(snapshotFilename);
|
||||
destFiles.add(snapshotFilename + ".md5");
|
||||
destFiles.add(timestampedFilename);
|
||||
destFiles.add(timestampedFilename + ".md5");
|
||||
destFiles.add(snapshotVersionsFilename);
|
||||
srcFiles.add(snapshotVersionFile.getAbsolutePath());
|
||||
|
||||
// do not deploy POM twice
|
||||
if (DEPLOY_POM_SNAPSHOT && !POM_TYPE.equals(type))
|
||||
{
|
||||
deploySnapshot(artifact, POM_TYPE, project, POM_ARTIFACT_TYPE_HANDLER);
|
||||
String snapshotVersionsFilename =
|
||||
handler.constructRepositoryDirectoryPath(type, project)
|
||||
+ project.getArtifactId()
|
||||
+ "-snapshot-version";
|
||||
destFiles.add(snapshotVersionsFilename);
|
||||
|
||||
// do not deploy POM twice
|
||||
if (DEPLOY_POM_SNAPSHOT && !POM_TYPE.equals(type))
|
||||
{
|
||||
deploySnapshot(artifact, POM_TYPE, project, POM_ARTIFACT_TYPE_HANDLER);
|
||||
}
|
||||
|
||||
doDeploy(srcFiles, destFiles, project);
|
||||
}
|
||||
|
||||
doDeploy(srcFiles, destFiles, project);
|
||||
// Delete md5 file
|
||||
md5File.delete();
|
||||
};
|
||||
finally {
|
||||
// Delete md5 file
|
||||
md5File.delete();
|
||||
snapshotVersionFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ArtifactDeployer#install(String, String, Project, ArtifactTypeHandler)
|
||||
@@ -226,7 +236,7 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
file = getFileForArtifact(artifact);
|
||||
}
|
||||
String snapshotSignature = getSnapshotSignature();
|
||||
System.out.println("Installing snapshot of:'" + artifact + "''");
|
||||
LOG.info("Installing snapshot of:'" + artifact + "''");
|
||||
doInstall(file, type, project, MavenConstants.SNAPSHOT_SIGNIFIER, handler);
|
||||
doInstall(file, type, project, snapshotSignature, handler);
|
||||
if (INSTALL_POM_SNAPSHOT && !POM_TYPE.equals(type))
|
||||
@@ -268,8 +278,7 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
{
|
||||
destFile.getParentFile().mkdirs();
|
||||
}
|
||||
System.out.println(
|
||||
"Copying: from '" + file + "' to: '" + destFile + "'");
|
||||
LOG.info("Copying: from '" + file + "' to: '" + destFile + "'");
|
||||
FileUtils.copyFile(file, destFile);
|
||||
}
|
||||
catch (IOException e)
|
||||
@@ -360,13 +369,13 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
|
||||
String[] repos = StringUtils.split(repoStr, ",");
|
||||
|
||||
System.out.println( "Will deploy to " + repos.length + " repository(ies): " + repoStr);
|
||||
LOG.info( "Will deploy to " + repos.length + " repository(ies): " + repoStr);
|
||||
boolean success = false;
|
||||
for (int i = 0; i < repos.length; i++)
|
||||
{
|
||||
|
||||
String repo = repos[i].trim();
|
||||
System.out.println("Deploying to repository: " + repo);
|
||||
LOG.info("Deploying to repository: " + repo);
|
||||
RepositoryInfo repoInfo = null;
|
||||
try
|
||||
{
|
||||
|
||||
@@ -20,6 +20,8 @@ package org.apache.maven.deploy;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.maven.deploy.deployers.Deployer;
|
||||
import org.apache.maven.deploy.deployers.ExternalDeployer;
|
||||
import org.apache.maven.deploy.deployers.FileDeployer;
|
||||
@@ -35,13 +37,15 @@ import org.apache.maven.deploy.exceptions.UnsupportedProtocolException;
|
||||
* Utility class
|
||||
*
|
||||
* @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: DeployTool.java,v 1.11 2004/05/02 15:04:34 vmassol Exp $
|
||||
* @version $Id: DeployTool.java,v 1.12 2004/06/25 13:50:05 brett Exp $
|
||||
*/
|
||||
public class DeployTool
|
||||
{
|
||||
/** Current Version **/
|
||||
public static final String VERSION = "1.0-dev";
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(DeployTool.class);
|
||||
|
||||
/**
|
||||
* Returns deployer which is able to deploy to repository
|
||||
* described by host info.
|
||||
@@ -130,7 +134,7 @@ public class DeployTool
|
||||
String srcFile = (String) srcIterator.next();
|
||||
String destFile = (String) destIterator.next();
|
||||
DeployRequest request = new DeployRequest(srcFile, destFile);
|
||||
System.out.println("Deploying: " + srcFile + "-->" + destFile);
|
||||
LOG.info("Deploying: " + srcFile + "-->" + destFile);
|
||||
deployer.deploy(request);
|
||||
}
|
||||
}
|
||||
@@ -142,7 +146,8 @@ public class DeployTool
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.error("Error cleaning up from the deployer", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@ package org.apache.maven.deploy.deployers;
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.maven.deploy.RepositoryInfo;
|
||||
import org.apache.maven.deploy.DeployRequest;
|
||||
import org.apache.maven.deploy.exceptions.AuthenticationException;
|
||||
@@ -27,7 +29,7 @@ import org.apache.maven.deploy.exceptions.TransferFailedException;
|
||||
* Deployers which for every deployment request
|
||||
* starts a new external process (e.g batch file, shell script)
|
||||
*
|
||||
* @version $Id: ExternalDeployer.java,v 1.4 2004/03/02 14:59:31 evenisse Exp $
|
||||
* @version $Id: ExternalDeployer.java,v 1.5 2004/06/25 13:50:05 brett Exp $
|
||||
* @todo still have to account for differing setups for people deploying to
|
||||
* their own sites and to the central repository.
|
||||
* @todo finich
|
||||
@@ -39,6 +41,8 @@ public class ExternalDeployer extends AbstractDeployer
|
||||
|
||||
private String cmd = null;
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(ExternalDeployer.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.maven.deploy.deployers.Deployer#init(org.apache.maven.deploy.HostInfo)
|
||||
*/
|
||||
@@ -68,14 +72,14 @@ public class ExternalDeployer extends AbstractDeployer
|
||||
|
||||
try
|
||||
{
|
||||
System.out.println(
|
||||
LOG.debug(
|
||||
"Staring external process: '"
|
||||
+ cmd
|
||||
+ "' to deploy:'"
|
||||
+ request.getDestFile());
|
||||
Process process = Runtime.getRuntime().exec(cmd, params);
|
||||
process.waitFor();
|
||||
System.out.println("External process finished");
|
||||
LOG.debug("External process finished");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,8 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.commons.net.ProtocolCommandEvent;
|
||||
import org.apache.commons.net.ProtocolCommandListener;
|
||||
import org.apache.commons.net.ftp.FTP;
|
||||
@@ -40,10 +42,10 @@ import org.apache.maven.deploy.exceptions.TransferFailedException;
|
||||
*
|
||||
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
|
||||
* @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: FtpDeployer.java,v 1.10 2004/06/14 13:36:48 brett Exp $
|
||||
* @version $Id: FtpDeployer.java,v 1.11 2004/06/25 13:50:05 brett Exp $
|
||||
*
|
||||
* @todo review exception handling
|
||||
*
|
||||
* @todo don't spool to System.out
|
||||
*
|
||||
*/
|
||||
public class FtpDeployer extends AbstractDeployer
|
||||
@@ -52,6 +54,7 @@ public class FtpDeployer extends AbstractDeployer
|
||||
public final static String PROTOCOL = "ftp://";
|
||||
|
||||
private FTPClient ftp = null;
|
||||
private static final Log LOG = LogFactory.getLog(FtpDeployer.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.maven.deploy.deployers.Deployer#init(org.apache.maven.deploy.HostInfo)
|
||||
@@ -82,7 +85,7 @@ public class FtpDeployer extends AbstractDeployer
|
||||
{
|
||||
ftp.connect(host);
|
||||
}
|
||||
System.out.println("Connected to " + host + ".");
|
||||
LOG.info("Connected to " + host + ".");
|
||||
|
||||
// After connection attempt, you should check the reply code to verify
|
||||
// success.
|
||||
@@ -91,7 +94,6 @@ public class FtpDeployer extends AbstractDeployer
|
||||
if (FTPReply.isPositiveCompletion(reply) == false)
|
||||
{
|
||||
ftp.disconnect();
|
||||
System.err.println();
|
||||
throw new AuthenticationException("FTP server refused connection.");
|
||||
}
|
||||
}
|
||||
@@ -118,7 +120,7 @@ public class FtpDeployer extends AbstractDeployer
|
||||
throw new AuthenticationException("Cannot login to remote system");
|
||||
}
|
||||
|
||||
System.out.println("Remote system is " + ftp.getSystemName());
|
||||
LOG.info("Remote system is " + ftp.getSystemName());
|
||||
|
||||
// Set to binary mode.
|
||||
ftp.setFileType(FTP.BINARY_FILE_TYPE);
|
||||
|
||||
@@ -19,6 +19,9 @@ package org.apache.maven.deploy.deployers;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.apache.maven.deploy.RepositoryInfo;
|
||||
import org.apache.maven.deploy.exceptions.AuthenticationException;
|
||||
|
||||
@@ -40,7 +43,7 @@ import com.jcraft.jsch.UserInfo;
|
||||
* and if that doesn't work then we fall back
|
||||
* to using the login and password
|
||||
*
|
||||
* @version $Id: GenericSshDeployer.java,v 1.9 2004/06/14 13:36:48 brett Exp $
|
||||
* @version $Id: GenericSshDeployer.java,v 1.10 2004/06/25 13:50:05 brett Exp $
|
||||
* @todo still have to account for differing setups for people deploying to
|
||||
* their own sites and to the central repository.
|
||||
* @todo improve exception handling
|
||||
@@ -58,6 +61,8 @@ public abstract class GenericSshDeployer extends AbstractDeployer
|
||||
|
||||
private Session session = null;
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(GenericSshDeployer.class);
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@@ -99,7 +104,7 @@ public abstract class GenericSshDeployer extends AbstractDeployer
|
||||
{
|
||||
port = DEFAULT_SSH_PORT;
|
||||
}
|
||||
System.out.println("host: '" + repoInfo.getHost() + "'");
|
||||
LOG.debug("host: '" + repoInfo.getHost() + "'");
|
||||
String host = repoInfo.getHost();
|
||||
session =
|
||||
jsch.getSession(repoInfo.getUserName(), host, port);
|
||||
@@ -120,7 +125,7 @@ public abstract class GenericSshDeployer extends AbstractDeployer
|
||||
throw new AuthenticationException(msg);
|
||||
}
|
||||
|
||||
System.out.println("Using private key: " + privateKey);
|
||||
LOG.info("Using private key: " + privateKey);
|
||||
jsch.addIdentity(
|
||||
privateKey.getAbsolutePath(),
|
||||
repoInfo.getPassphrase());
|
||||
@@ -229,7 +234,7 @@ public abstract class GenericSshDeployer extends AbstractDeployer
|
||||
*/
|
||||
public void showMessage(String message)
|
||||
{
|
||||
System.out.println(message);
|
||||
LOG.info(message);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.apache.maven.deploy.exceptions.TransferFailedException;
|
||||
* An HTTP deployer based the Commons HttpClient library.
|
||||
*
|
||||
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
|
||||
* @version $Id: HttpDeployer.java,v 1.6 2004/03/02 14:59:31 evenisse Exp $
|
||||
* @version $Id: HttpDeployer.java,v 1.7 2004/06/25 13:50:05 brett Exp $
|
||||
*
|
||||
* @todo still have to account for differing setups for people deploying to
|
||||
* their own sites and to the central repository.
|
||||
@@ -137,16 +137,13 @@ public class HttpDeployer extends AbstractDeployer
|
||||
{
|
||||
client.executeMethod(method);
|
||||
}
|
||||
catch (HttpException he)
|
||||
catch (HttpException e)
|
||||
{
|
||||
System.err.println("Http error connecting to '" + url + "'");
|
||||
System.err.println(he.getMessage());
|
||||
System.exit(-4);
|
||||
throw new TransferFailedException("Http error connecting to '" + url + "'", e);
|
||||
}
|
||||
catch (IOException ioe)
|
||||
catch (IOException e)
|
||||
{
|
||||
System.err.println("Unable to connect to '" + url + "'");
|
||||
System.exit(-3);
|
||||
throw new TransferFailedException("Unable to connect to '" + url + "'", e);
|
||||
}
|
||||
|
||||
//get the request headers
|
||||
|
||||
@@ -18,6 +18,9 @@ package org.apache.maven.deploy.deployers;
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.apache.maven.deploy.RepositoryInfo;
|
||||
import org.apache.maven.deploy.DeployRequest;
|
||||
import org.apache.maven.deploy.exceptions.AuthenticationException;
|
||||
@@ -32,10 +35,12 @@ import com.jcraft.jsch.SftpProgressMonitor;
|
||||
* An SSH2/SFTP deployer
|
||||
*
|
||||
* @author Michal Maczka
|
||||
* @version $Revision: 1.10 $ $Date: 2004/06/14 13:36:48 $
|
||||
* @version $Revision: 1.11 $ $Date: 2004/06/25 13:50:05 $
|
||||
*/
|
||||
public class SFtpDeployer extends GenericSshDeployer
|
||||
{
|
||||
private static final Log LOG = LogFactory.getLog(SFtpDeployer.class);
|
||||
|
||||
/**Protocol understood by by this deployer*/
|
||||
public final static String PROTOCOL = "sftp://";
|
||||
|
||||
@@ -145,12 +150,12 @@ public class SFtpDeployer extends GenericSshDeployer
|
||||
{
|
||||
if (getRepositoryInfo().isDebugOn())
|
||||
{
|
||||
System.out.println("Changing group to: " + groupId);
|
||||
LOG.info("Changing group to: " + groupId);
|
||||
}
|
||||
channel.chgrp(groupId.intValue(), request.getDestFile());
|
||||
if (getRepositoryInfo().isDebugOn())
|
||||
{
|
||||
System.out.println("Group successfully changed");
|
||||
LOG.info("Group successfully changed");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -173,6 +178,7 @@ public class SFtpDeployer extends GenericSshDeployer
|
||||
|
||||
}
|
||||
|
||||
/** @todo use logger */
|
||||
class ProgressMonitor implements SftpProgressMonitor
|
||||
{
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ package org.apache.maven.deploy.deployers;
|
||||
import com.jcraft.jsch.ChannelExec;
|
||||
import com.jcraft.jsch.Session;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.apache.maven.deploy.DeployRequest;
|
||||
import org.apache.maven.deploy.RepositoryInfo;
|
||||
import org.apache.maven.deploy.exceptions.AuthenticationException;
|
||||
@@ -39,10 +42,12 @@ import java.util.List;
|
||||
* An SSH2/SCP deployer
|
||||
*
|
||||
* @author Michal Maczka
|
||||
* @version $Revision: 1.10 $ $Date: 2004/06/14 13:36:48 $
|
||||
* @version $Revision: 1.11 $ $Date: 2004/06/25 13:50:05 $
|
||||
*/
|
||||
public class ScpDeployer extends GenericSshDeployer
|
||||
{
|
||||
private static final Log LOG = LogFactory.getLog(ScpDeployer.class);
|
||||
|
||||
/**Protocol understood by this deployer*/
|
||||
public final static String PROTOCOL = "scp://";
|
||||
|
||||
@@ -103,7 +108,7 @@ public class ScpDeployer extends GenericSshDeployer
|
||||
*/
|
||||
public void deploy(DeployRequest request) throws TransferFailedException
|
||||
{
|
||||
System.out.println("deployNotCompressed=" + deployNotCompressed);
|
||||
LOG.debug("deployNotCompressed=" + deployNotCompressed);
|
||||
if (deployNotCompressed)
|
||||
{
|
||||
doDeployNotCompressed(request);
|
||||
@@ -247,7 +252,7 @@ public class ScpDeployer extends GenericSshDeployer
|
||||
private void executeSimpleCommand(Session session, String command)
|
||||
throws TransferFailedException
|
||||
{
|
||||
System.out.println("Executing command: " + command);
|
||||
LOG.info("Executing command: " + command);
|
||||
|
||||
ChannelExec channel = null;
|
||||
|
||||
@@ -293,7 +298,7 @@ public class ScpDeployer extends GenericSshDeployer
|
||||
// exec 'scp -t rfile' remotely
|
||||
String command = "scp -t " + destFile;
|
||||
|
||||
System.out.println("Executing command: " + command);
|
||||
LOG.debug("Executing command: " + command);
|
||||
channel = (ChannelExec) session.openChannel(EXEC_CHANNEL);
|
||||
channel.setCommand(command);
|
||||
|
||||
@@ -339,20 +344,24 @@ public class ScpDeployer extends GenericSshDeployer
|
||||
while (tmp[0] != 0);
|
||||
|
||||
// send a content of inputFile
|
||||
FileInputStream fis = new FileInputStream(srcFile);
|
||||
byte[] buf = new byte[1024];
|
||||
|
||||
while (true)
|
||||
{
|
||||
int len = fis.read(buf, 0, buf.length);
|
||||
|
||||
if (len <= 0)
|
||||
FileInputStream fis = new FileInputStream(srcFile);
|
||||
try {
|
||||
while (true)
|
||||
{
|
||||
break;
|
||||
int len = fis.read(buf, 0, buf.length);
|
||||
|
||||
if (len <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
out.write(buf, 0, len);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
out.write(buf, 0, len);
|
||||
out.flush();
|
||||
}
|
||||
finally {
|
||||
fis.close();
|
||||
}
|
||||
|
||||
// send '\0'
|
||||
|
||||
Reference in new issue
Block a user