brett 2004/09/28 02:20:41
Modified: artifact project.xml
artifact/src/main/org/apache/maven/artifact/deployer
RepositoryInfoBuilder.java
artifact/src/main/org/apache/maven/deploy
RepositoryInfo.java
artifact/src/main/org/apache/maven/deploy/deployers
FtpDeployer.java GenericSshDeployer.java
SFtpDeployer.java ScpDeployer.java
ScpExeDeployer.java
artifact/xdocs changes.xml properties.xml
Log:
various bugfixes
Revision Changes Path
1.34 +1 -1 maven-plugins/artifact/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/maven-plugins/artifact/project.xml,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- project.xml 11 Jul 2004 01:57:32 -0000 1.33
+++ project.xml 28 Sep 2004 09:20:40 -0000 1.34
@@ -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>
1.8 +10 -1
maven-plugins/artifact/src/main/org/apache/maven/artifact/deployer/RepositoryInfoBuilder.java
Index: RepositoryInfoBuilder.java
===================================================================
RCS file:
/home/cvs/maven-plugins/artifact/src/main/org/apache/maven/artifact/deployer/RepositoryInfoBuilder.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- RepositoryInfoBuilder.java 6 Jul 2004 13:42:25 -0000 1.7
+++ RepositoryInfoBuilder.java 28 Sep 2004 09:20:40 -0000 1.8
@@ -83,6 +83,10 @@
(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 @@
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);
1.7 +38 -25
maven-plugins/artifact/src/main/org/apache/maven/deploy/RepositoryInfo.java
Index: RepositoryInfo.java
===================================================================
RCS file:
/home/cvs/maven-plugins/artifact/src/main/org/apache/maven/deploy/RepositoryInfo.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- RepositoryInfo.java 6 Jul 2004 13:42:25 -0000 1.6
+++ RepositoryInfo.java 28 Sep 2004 09:20:40 -0000 1.7
@@ -55,6 +55,9 @@
/** 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 @@
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 @@
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;
+ }
}
1.13 +4 -1
maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java
Index: FtpDeployer.java
===================================================================
RCS file:
/home/cvs/maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- FtpDeployer.java 25 Jun 2004 18:50:38 -0000 1.12
+++ FtpDeployer.java 28 Sep 2004 09:20:40 -0000 1.13
@@ -176,6 +176,9 @@
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("..");
1.12 +19 -5
maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/GenericSshDeployer.java
Index: GenericSshDeployer.java
===================================================================
RCS file:
/home/cvs/maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/GenericSshDeployer.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- GenericSshDeployer.java 25 Jun 2004 18:19:35 -0000 1.11
+++ GenericSshDeployer.java 28 Sep 2004 09:20:40 -0000 1.12
@@ -84,7 +84,10 @@
*/
public void release()
{
- session.disconnect();
+ if ( session != null )
+ {
+ session.disconnect();
+ }
}
/* (non-Javadoc)
@@ -93,6 +96,18 @@
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 @@
}
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() );
}
}
1.12 +2 -2
maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/SFtpDeployer.java
Index: SFtpDeployer.java
===================================================================
RCS file:
/home/cvs/maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/SFtpDeployer.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SFtpDeployer.java 25 Jun 2004 13:50:05 -0000 1.11
+++ SFtpDeployer.java 28 Sep 2004 09:20:40 -0000 1.12
@@ -152,7 +152,7 @@
{
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");
1.13 +27 -1
maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/ScpDeployer.java
Index: ScpDeployer.java
===================================================================
RCS file:
/home/cvs/maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/ScpDeployer.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ScpDeployer.java 6 Jul 2004 14:29:30 -0000 1.12
+++ ScpDeployer.java 28 Sep 2004 09:20:40 -0000 1.13
@@ -138,6 +138,18 @@
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)
@@ -152,6 +164,20 @@
+ "\n";
executeSimpleCommand(session, chgrpCmd);
+ }
+
+ if (getRepositoryInfo().getMode() != null)
+ {
+ String chmodCmd =
+ "chmod "
+ + getRepositoryInfo().getMode()
+ + " "
+ + getRepositoryInfo().getBasedir()
+ + "/"
+ + request.getDestFile()
+ + "\n";
+
+ executeSimpleCommand(session, chmodCmd);
}
}
1.2 +126 -93
maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/ScpExeDeployer.java
Index: ScpExeDeployer.java
===================================================================
RCS file:
/home/cvs/maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/ScpExeDeployer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ScpExeDeployer.java 6 Jul 2004 14:42:49 -0000 1.1
+++ ScpExeDeployer.java 28 Sep 2004 09:20:40 -0000 1.2
@@ -19,12 +19,16 @@
*/
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 void init(RepositoryInfo repoInfo) throws AuthenticationException
{
- repositoryInfo = repoInfo;
+ repositoryInfo = repoInfo;
}
private RepositoryInfo getRepositoryInfo() {
- return repositoryInfo;
+ return repositoryInfo;
}
/**
@@ -98,110 +102,139 @@
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<array.length; i++) {
- sb.append(array[i]);
- sb.append(" ");
- }
- return sb.toString();
+ StringBuffer sb = new StringBuffer();
+ for (int i=0; i<array.length; i++) {
+ sb.append(array[i]);
+ sb.append(" ");
+ }
+ return sb.toString();
}
private void executeSimpleCommand(String cmd) throws TransferFailedException {
String args = getRepositoryInfo().getSshArgs();
- if (args == null) {
- args = "";
+ String sshCmd = getRepositoryInfo().getSshExe() + " " +
+ ( args == null ? "" : args + " " ) +
+ getRepositoryInfo().getUserName() + "@" +
getRepositoryInfo().getHost() + " " +
+ cmd;
+ try {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Executing command: " + sshCmd);
+ }
+ Process p = Runtime.getRuntime().exec(sshCmd);
+ // 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);
+ } catch (InterruptedException e) {
+ LOG.error("Error executing command: " + cmd);
+ throw new TransferFailedException("Error executing command: ", e);
}
- String[] sshCmd = { getRepositoryInfo().getSshExe(),
- args,
- getRepositoryInfo().getUserName() + "@" +
getRepositoryInfo().getHost(),
- cmd };
- try {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Executing command: " + arrayToString(sshCmd));
- }
- Process p = Runtime.getRuntime().exec(sshCmd);
- 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);
- }
}
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 = "";
- }
-
- if (destFile.indexOf("SNAPSHOT") > 0) {
- // If an old SNAPSHOT exists, remove it
- executeSimpleCommand("rm -r " + destFile);
- }
-
- 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");
-
- // 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);
- }
-
+ 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 -f " + 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");
+
+ // 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: " +
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();
+ }
+ }
+ }
}
1.30 +12 -0 maven-plugins/artifact/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/maven-plugins/artifact/xdocs/changes.xml,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- changes.xml 11 Jul 2004 01:57:32 -0000 1.29
+++ changes.xml 28 Sep 2004 09:20:40 -0000 1.30
@@ -25,6 +25,18 @@
<author email="[EMAIL PROTECTED]">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>
1.11 +11 -2 maven-plugins/artifact/xdocs/properties.xml
Index: properties.xml
===================================================================
RCS file: /home/cvs/maven-plugins/artifact/xdocs/properties.xml,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- properties.xml 19 Aug 2004 10:53:52 -0000 1.10
+++ properties.xml 28 Sep 2004 09:20:40 -0000 1.11
@@ -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>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]