various bugfixes

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@116100 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
brett 2004-09-28 09:20:40 +00:00
parent adabb3cfd5
commit b4ec0d61d1
10 changed files with 246 additions and 127 deletions

View File

@ -25,7 +25,7 @@
<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.4</currentVersion>
<currentVersion>1.4.1-SNAPSHOT</currentVersion>
<description>Tools to manage artifacts and deployment. Requires Maven 1.0 RC4</description>
<shortDescription>Tools to manage artifacts and deployment</shortDescription>
<url>http://maven.apache.org/reference/plugins/artifact/</url>

View File

@ -27,7 +27,7 @@ import org.apache.maven.project.Project;
* Perform mapping between project's properties and attributes of DeployRequest class.
*
* @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
* @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);

View File

@ -23,7 +23,7 @@ package org.apache.maven.deploy;
* perform a deployment.
*
* @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
* @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

View File

@ -42,7 +42,7 @@ 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.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("..");

View File

@ -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
@ -83,9 +83,12 @@ public abstract class GenericSshDeployer extends AbstractDeployer
* @see org.apache.maven.deploy.deployers.Deployer#release()
*/
public void release()
{
if ( session != null )
{
session.disconnect();
}
}
/* (non-Javadoc)
* @see org.apache.maven.deploy.deployers.Deployer#init(org.apache.maven.deploy.HostInfo)
@ -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() );
}
}

View File

@ -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");

View File

@ -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);
}
}
/**

View File

@ -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;
@ -98,6 +102,20 @@ 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) {
@ -111,19 +129,30 @@ public class ScpExeDeployer extends AbstractDeployer
private void executeSimpleCommand(String cmd) throws TransferFailedException {
String args = getRepositoryInfo().getSshArgs();
if (args == null) {
args = "";
}
String[] sshCmd = { getRepositoryInfo().getSshExe(),
args,
getRepositoryInfo().getUserName() + "@" + getRepositoryInfo().getHost(),
cmd };
String sshCmd = getRepositoryInfo().getSshExe() + " " +
( args == null ? "" : args + " " ) +
getRepositoryInfo().getUserName() + "@" + getRepositoryInfo().getHost() + " " +
cmd;
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Executing command: " + arrayToString(sshCmd));
LOG.debug("Executing command: " + sshCmd);
}
Process p = Runtime.getRuntime().exec(sshCmd);
p.waitFor();
// any error message?
StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), "ERROR");
// any output?
StreamGobbler outputGobbler = new StreamGobbler(p.getInputStream(), "OUTPUT");
// kick them off
errorGobbler.start();
outputGobbler.start();
int returnCode = p.waitFor();
if (returnCode != 0) {
LOG.debug( "exit code = " + returnCode );
throw new TransferFailedException("Error executing command: " + cmd);
}
} catch (IOException e) {
LOG.error("Error executing command: " + cmd);
throw new TransferFailedException("Error executing command: ", e);
@ -134,26 +163,26 @@ public class ScpExeDeployer extends AbstractDeployer
}
private void doCopy(DeployRequest request) throws TransferFailedException {
String srcFile = request.getSrcFile();
String destFile = getRepositoryInfo().getBasedir() + "/" + request.getDestFile();
String dest = getRepositoryInfo().getUserName() + "@" + getRepositoryInfo().getHost() + ":" + destFile;
String args = getRepositoryInfo().getScpArgs();
if (args == null) {
args = "";
String srcFile;
try {
srcFile = MavenUtils.makeRelativePath( new File( System.getProperty( "user.dir" ) ), request.getSrcFile() );
} catch (IOException e) {
throw new TransferFailedException("Error locating artifact to deploy: ", e);
}
String destFile = getRepositoryInfo().getBasedir() + "/" + request.getDestFile();
if (destFile.indexOf("SNAPSHOT") > 0) {
// If an old SNAPSHOT exists, remove it
executeSimpleCommand("rm -r " + destFile);
executeSimpleCommand("rm -f " + destFile);
}
String[] scpCmd = { getRepositoryInfo().getScpExe(),
args,
srcFile,
dest };
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: " + arrayToString(scpCmd));
LOG.debug("Executing command: " + scpCmd);
}
Process p = Runtime.getRuntime().exec(scpCmd);
// any error message?
@ -166,7 +195,11 @@ public class ScpExeDeployer extends AbstractDeployer
errorGobbler.start();
outputGobbler.start();
p.waitFor();
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);

View File

@ -25,6 +25,18 @@
<author email="vmassol@apache.org">Vincent Massol</author>
</properties>
<body>
<release version="1.4.1" date="in CVS">
<action dev="brett" type="fix" issue="MPARTIFACT-38">Allow scpexe protocol to work better with args</action>
<action dev="brett" type="fix" issue="MPARTIFACT-34">Check return code of spawned external processes</action>
<action dev="brett" type="fix" issue="MPARTIFACT-32">Remove old snapshots that were created with symlinks before deployment.</action>
<action dev="brett" type="fix" issue="MPARTIFACT-29">Fix group setting for scpexe deployer</action>
<action dev="brett" type="fix" issue="MPARTIFACT-28">Run scpexe with a relative path so it works on cygwin.</action>
<action dev="brett" type="fix" issue="MPARTIFACT-26">Improve error reporting on a JCEless install attempting to use built in SSH.</action>
<action dev="brett" type="fix" issue="MPARTIFACT-27">Only log JSCH exceptions in debug mode, report exception</action>
<action dev="brett" type="fix" issue="MPARTIFACT-30">Fix group setting for scp deployer</action>
<action dev="brett" type="fix" issue="MPARTIFACT-12">Add mode setting for remote repository</action>
<action dev="brett" type="fix" issue="MPARTIFACT-11">Fix group setting for SFTP deployer</action>
</release>
<release version="1.4" date="2004-07-10">
<action dev="brett" type="fix" issue="MPARTIFACT-23">Add overwrite option to unzip - necessary to run in batch mode</action>
<action dev="brett" type="add" issue="MPARTIFACT-22" due-to="Leif Nelson">Add an scp executable deployer</action>

View File

@ -98,8 +98,17 @@
<td>maven.repo.x.group</td>
<td>
The remote group (UNIX group) to which
artifact will belong after it
will be deployed
the artifact will belong after it
is deployed
</td>
<td>Yes</td>
</tr>
<tr>
<td>maven.repo.x.mode</td>
<td>
The remote file mode (UNIX permissions) to which
the artifact will be set to after it
is deployed. Default is <code>664</code>.
</td>
<td>Yes</td>
</tr>