diff --git a/artifact/project.xml b/artifact/project.xml index 1d5db3f6..c2b0e3fa 100644 --- a/artifact/project.xml +++ b/artifact/project.xml @@ -25,7 +25,7 @@ Maven Artifact Plugin - 1.4 + 1.4.1-SNAPSHOT Tools to manage artifacts and deployment. Requires Maven 1.0 RC4 Tools to manage artifacts and deployment http://maven.apache.org/reference/plugins/artifact/ diff --git a/artifact/src/main/org/apache/maven/artifact/deployer/RepositoryInfoBuilder.java b/artifact/src/main/org/apache/maven/artifact/deployer/RepositoryInfoBuilder.java index ac441258..e5fc94e5 100644 --- a/artifact/src/main/org/apache/maven/artifact/deployer/RepositoryInfoBuilder.java +++ b/artifact/src/main/org/apache/maven/artifact/deployer/RepositoryInfoBuilder.java @@ -27,7 +27,7 @@ import org.apache.maven.project.Project; * Perform mapping between project's properties and attributes of DeployRequest class. * * @author Michal Maczka - * @version $Id: RepositoryInfoBuilder.java,v 1.7 2004/07/06 13:42:25 brett Exp $ + * @version $Id: RepositoryInfoBuilder.java,v 1.8 2004/09/28 09:20:40 brett Exp $ */ public class RepositoryInfoBuilder { @@ -83,6 +83,10 @@ public class RepositoryInfoBuilder (String) project.getContext().getVariable( "maven.repo." + repository + ".group"); + String remoteMode = + (String) project.getContext().getVariable( + "maven.repo." + repository + ".mode"); + String passiveModeOn = (String) project.getContext().getVariable( "maven.repo." + repository + ".passiveModeOn"); @@ -115,11 +119,16 @@ public class RepositoryInfoBuilder username = (String) project.getContext().getVariable("maven.username"); } + if (remoteMode == null) { + remoteMode = "664"; + } + repoInfo.setUserName(username); repoInfo.setPassword(password); repoInfo.setPassphrase(passphrase); repoInfo.setPrivateKey(privateKey); repoInfo.setGroup(remoteGroup); + repoInfo.setMode(remoteMode); repoInfo.setUrl(url); repoInfo.setProxyHost(proxyHost); repoInfo.setProxyUserName(proxyUser); diff --git a/artifact/src/main/org/apache/maven/deploy/RepositoryInfo.java b/artifact/src/main/org/apache/maven/deploy/RepositoryInfo.java index 7a3c7114..08bdfd18 100644 --- a/artifact/src/main/org/apache/maven/deploy/RepositoryInfo.java +++ b/artifact/src/main/org/apache/maven/deploy/RepositoryInfo.java @@ -23,7 +23,7 @@ package org.apache.maven.deploy; * perform a deployment. * * @author Michal Maczka - * @version $Id: RepositoryInfo.java,v 1.6 2004/07/06 13:42:25 brett Exp $ + * @version $Id: RepositoryInfo.java,v 1.7 2004/09/28 09:20:40 brett Exp $ */ public class RepositoryInfo { @@ -55,6 +55,9 @@ public class RepositoryInfo /** Remote group name */ private String group; + /** File mode. */ + private String mode; + /** The passpharse of the user's private key file */ private String passphrase; @@ -187,6 +190,16 @@ public class RepositoryInfo this.privateKey = privateKey; } + public String getMode() + { + return mode; + } + + public void setMode( String mode ) + { + this.mode = mode; + } + /** * Get the remote group to which will belong to * after deployemnt. Not all protolcols support @@ -389,28 +402,28 @@ public class RepositoryInfo this.passiveModeOn = passiveModeOn; } - public String getScpArgs() { - return scpArgs; - } - public void setScpArgs(String scpArgs) { - this.scpArgs = scpArgs; - } - public String getScpExe() { - return scpExe; - } - public void setScpExe(String scpExe) { - this.scpExe = scpExe; - } - public String getSshArgs() { - return sshArgs; - } - public void setSshArgs(String sshArgs) { - this.sshArgs = sshArgs; - } - public String getSshExe() { - return sshExe; - } - public void setSshExe(String sshExe) { - this.sshExe = sshExe; - } + public String getScpArgs() { + return scpArgs; + } + public void setScpArgs(String scpArgs) { + this.scpArgs = scpArgs; + } + public String getScpExe() { + return scpExe; + } + public void setScpExe(String scpExe) { + this.scpExe = scpExe; + } + public String getSshArgs() { + return sshArgs; + } + public void setSshArgs(String sshArgs) { + this.sshArgs = sshArgs; + } + public String getSshExe() { + return sshExe; + } + public void setSshExe(String sshExe) { + this.sshExe = sshExe; + } } 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 d9c7e4a1..7796768e 100644 --- a/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java +++ b/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java @@ -42,7 +42,7 @@ import org.apache.maven.deploy.exceptions.TransferFailedException; * * @author Jason van Zyl * @author Michal Maczka - * @version $Id: FtpDeployer.java,v 1.12 2004/06/25 18:50:38 brett Exp $ + * @version $Id: FtpDeployer.java,v 1.13 2004/09/28 09:20:40 brett Exp $ * * @todo review exception handling * @todo don't spool to System.out @@ -176,6 +176,9 @@ public class FtpDeployer extends AbstractDeployer ftp.storeFile( request.filename(), new FileInputStream(request.getSrcFile())); + // TODO: test first, then mark MPARTIFACT-24 complete + //ftp.executeSiteCommand( "CHGRP " + request.getGroup() + " " + request.filename() ); + //ftp.executeSiteCommand( "CHMOD " + request.getMode() + " " + request.filename() ); for (int i = 0; i < dirs.length; i++) { ftp.changeWorkingDirectory(".."); 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 665b3665..b80acac4 100644 --- a/artifact/src/main/org/apache/maven/deploy/deployers/GenericSshDeployer.java +++ b/artifact/src/main/org/apache/maven/deploy/deployers/GenericSshDeployer.java @@ -43,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.11 2004/06/25 18:19:35 brett Exp $ + * @version $Id: GenericSshDeployer.java,v 1.12 2004/09/28 09:20:40 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 @@ -84,7 +84,10 @@ public abstract class GenericSshDeployer extends AbstractDeployer */ public void release() { - session.disconnect(); + if ( session != null ) + { + session.disconnect(); + } } /* (non-Javadoc) @@ -93,6 +96,18 @@ public abstract class GenericSshDeployer extends AbstractDeployer public void init(RepositoryInfo repoInfo) throws AuthenticationException { + try { + Class.forName( "javax.crypto.spec.DHParameterSpec" ); + } + catch ( ClassNotFoundException e ) + { + LOG.error( "JCE is required for an SSH based deployer" ); + LOG.error( "Please use JDK 1.4 or above, or install a JCE provider" ); + LOG.error( "A free (GPL) provider is available from Bouncycastle:" ); + LOG.error( "http://www.bouncycastle.org/" ); + + throw new AuthenticationException( "JCE required" ); + } try { @@ -168,9 +183,8 @@ public abstract class GenericSshDeployer extends AbstractDeployer } catch (Exception e) { - throw new AuthenticationException( - "Cannot connect. Reason: " + e.getMessage(), - e); + LOG.debug("Connection failure exception", e); + throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage() ); } } 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 65b01b16..e2215efa 100644 --- a/artifact/src/main/org/apache/maven/deploy/deployers/SFtpDeployer.java +++ b/artifact/src/main/org/apache/maven/deploy/deployers/SFtpDeployer.java @@ -35,7 +35,7 @@ import com.jcraft.jsch.SftpProgressMonitor; * An SSH2/SFTP deployer * * @author Michal Maczka - * @version $Revision: 1.11 $ $Date: 2004/06/25 13:50:05 $ + * @version $Revision: 1.12 $ $Date: 2004/09/28 09:20:40 $ */ public class SFtpDeployer extends GenericSshDeployer { @@ -152,7 +152,7 @@ public class SFtpDeployer extends GenericSshDeployer { LOG.info("Changing group to: " + groupId); } - channel.chgrp(groupId.intValue(), request.getDestFile()); + channel.chgrp(groupId.intValue(), request.filename()); if (getRepositoryInfo().isDebugOn()) { LOG.info("Group successfully changed"); 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 6b1be09d..1038ac43 100644 --- a/artifact/src/main/org/apache/maven/deploy/deployers/ScpDeployer.java +++ b/artifact/src/main/org/apache/maven/deploy/deployers/ScpDeployer.java @@ -42,7 +42,7 @@ import java.util.List; * An SSH2/SCP deployer * * @author Michal Maczka - * @version $Revision: 1.12 $ $Date: 2004/07/06 14:29:30 $ + * @version $Revision: 1.13 $ $Date: 2004/09/28 09:20:40 $ */ public class ScpDeployer extends GenericSshDeployer { @@ -138,6 +138,18 @@ public class ScpDeployer extends GenericSshDeployer executeSimpleCommand(session, mkdirCmd); + // If an old SNAPSHOT exists, remove it + if (request.getDestFile().indexOf("SNAPSHOT") > 0) { + String cmd = + "rm -f " + + getRepositoryInfo().getBasedir() + + "/" + + request.getDestFile() + + "\n"; + + executeSimpleCommand(session, cmd); + } + doCopy(session, request); if (getRepositoryInfo().getGroup() != null) @@ -153,6 +165,20 @@ public class ScpDeployer extends GenericSshDeployer executeSimpleCommand(session, chgrpCmd); } + + if (getRepositoryInfo().getMode() != null) + { + String chmodCmd = + "chmod " + + getRepositoryInfo().getMode() + + " " + + getRepositoryInfo().getBasedir() + + "/" + + request.getDestFile() + + "\n"; + + executeSimpleCommand(session, chmodCmd); + } } /** diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/ScpExeDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/ScpExeDeployer.java index ea73d1e6..5d24ef56 100755 --- a/artifact/src/main/org/apache/maven/deploy/deployers/ScpExeDeployer.java +++ b/artifact/src/main/org/apache/maven/deploy/deployers/ScpExeDeployer.java @@ -19,12 +19,16 @@ package org.apache.maven.deploy.deployers; */ import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.maven.MavenUtils; import org.apache.maven.deploy.DeployRequest; import org.apache.maven.deploy.RepositoryInfo; import org.apache.maven.deploy.exceptions.AuthenticationException; @@ -55,11 +59,11 @@ public class ScpExeDeployer extends AbstractDeployer */ public void init(RepositoryInfo repoInfo) throws AuthenticationException { - repositoryInfo = repoInfo; + repositoryInfo = repoInfo; } private RepositoryInfo getRepositoryInfo() { - return repositoryInfo; + return repositoryInfo; } /** @@ -98,110 +102,139 @@ public class ScpExeDeployer extends AbstractDeployer executeSimpleCommand(chgrpCmd); } + + if (getRepositoryInfo().getMode() != null) + { + String chmodCmd = + "chmod " + + getRepositoryInfo().getMode() + + " " + + getRepositoryInfo().getBasedir() + + "/" + + request.getDestFile() + + "\n"; + + executeSimpleCommand(chmodCmd); + } } private String arrayToString(String[] array) { - StringBuffer sb = new StringBuffer(); - for (int i=0; i 0) { + // If an old SNAPSHOT exists, remove it + executeSimpleCommand("rm -f " + destFile); + } - if (destFile.indexOf("SNAPSHOT") > 0) { - // If an old SNAPSHOT exists, remove it - executeSimpleCommand("rm -r " + destFile); - } + String args = getRepositoryInfo().getScpArgs(); + String scpCmd = getRepositoryInfo().getScpExe() + " " + + ( args == null ? "" : args + " " ) + + srcFile + " " + + getRepositoryInfo().getUserName() + "@" + getRepositoryInfo().getHost() + ":" + destFile; + try { + if (LOG.isDebugEnabled()) { + LOG.debug("Executing command: " + scpCmd); + } + Process p = Runtime.getRuntime().exec(scpCmd); + // any error message? + StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), "ERROR"); - String[] scpCmd = { getRepositoryInfo().getScpExe(), - args, - srcFile, - dest }; - try { - if (LOG.isDebugEnabled()) { - LOG.debug("Executing command: " + arrayToString(scpCmd)); - } - Process p = Runtime.getRuntime().exec(scpCmd); - // any error message? - StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), "ERROR"); + // any output? + StreamGobbler outputGobbler = new StreamGobbler(p.getInputStream(), "OUTPUT"); - // any output? - StreamGobbler outputGobbler = new StreamGobbler(p.getInputStream(), "OUTPUT"); + // kick them off + errorGobbler.start(); + outputGobbler.start(); - // kick them off - errorGobbler.start(); - outputGobbler.start(); - - p.waitFor(); - } catch (IOException e) { - LOG.error("Error executing command: " + cmd); - throw new TransferFailedException("Error executing command: ", e); - } catch (InterruptedException e) { - LOG.error("Error executing command: " + cmd); - throw new TransferFailedException("Error executing command: ", e); - } - + int returnCode = p.waitFor(); + if (returnCode != 0) { + LOG.debug( "exit code = " + returnCode ); + throw new TransferFailedException("Error executing command: " + scpCmd); + } + } catch (IOException e) { + LOG.error("Error executing command: " + cmd); + throw new TransferFailedException("Error executing command: ", e); + } catch (InterruptedException e) { + LOG.error("Error executing command: " + cmd); + throw new TransferFailedException("Error executing command: ", e); + } + } private class StreamGobbler extends Thread - { - private InputStream is; - private String type; - - public StreamGobbler(InputStream is, String type) { - this.is = is; - this.type = type; - } - - public void run() { - try { - InputStreamReader isr = new InputStreamReader(is); - BufferedReader br = new BufferedReader(isr); - String line = null; - while ((line = br.readLine()) != null) { - LOG.debug(type + ">" + line); - } - br.close(); - isr.close(); - - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } - } + { + private InputStream is; + private String type; + + public StreamGobbler(InputStream is, String type) { + this.is = is; + this.type = type; + } + + public void run() { + try { + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + String line = null; + while ((line = br.readLine()) != null) { + LOG.debug(type + ">" + line); + } + br.close(); + isr.close(); + + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } + } } diff --git a/artifact/xdocs/changes.xml b/artifact/xdocs/changes.xml index fa9c6649..f1972d12 100644 --- a/artifact/xdocs/changes.xml +++ b/artifact/xdocs/changes.xml @@ -25,6 +25,18 @@ Vincent Massol + + Allow scpexe protocol to work better with args + Check return code of spawned external processes + Remove old snapshots that were created with symlinks before deployment. + Fix group setting for scpexe deployer + Run scpexe with a relative path so it works on cygwin. + Improve error reporting on a JCEless install attempting to use built in SSH. + Only log JSCH exceptions in debug mode, report exception + Fix group setting for scp deployer + Add mode setting for remote repository + Fix group setting for SFTP deployer + Add overwrite option to unzip - necessary to run in batch mode Add an scp executable deployer diff --git a/artifact/xdocs/properties.xml b/artifact/xdocs/properties.xml index a0251cf8..1fa6c952 100644 --- a/artifact/xdocs/properties.xml +++ b/artifact/xdocs/properties.xml @@ -98,8 +98,17 @@ maven.repo.x.group The remote group (UNIX group) to which - artifact will belong after it - will be deployed + the artifact will belong after it + is deployed + + Yes + + + maven.repo.x.mode + + The remote file mode (UNIX permissions) to which + the artifact will be set to after it + is deployed. Default is 664. Yes