You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2004/06/25 15:50:05 UTC

cvs commit: maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers ExternalDeployer.java FtpDeployer.java GenericSshDeployer.java HttpDeployer.java SFtpDeployer.java ScpDeployer.java

brett       2004/06/25 06:50:05

  Modified:    artifact plugin.jelly project.xml
               artifact/src/main/org/apache/maven/artifact/deployer
                        DefaultArtifactDeployer.java
               artifact/src/main/org/apache/maven/deploy DeployTool.java
               artifact/src/main/org/apache/maven/deploy/deployers
                        ExternalDeployer.java FtpDeployer.java
                        GenericSshDeployer.java HttpDeployer.java
                        SFtpDeployer.java ScpDeployer.java
  Log:
  finalise implementation of legacy deployment method
  
  Revision  Changes    Path
  1.8       +81 -15    maven-plugins/artifact/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/maven-plugins/artifact/plugin.jelly,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- plugin.jelly	23 Jun 2004 13:04:28 -0000	1.7
  +++ plugin.jelly	25 Jun 2004 13:50:05 -0000	1.8
  @@ -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>
   
  
  
  
  1.28      +1 -0      maven-plugins/artifact/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/artifact/project.xml,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- project.xml	23 Jun 2004 13:04:28 -0000	1.27
  +++ project.xml	25 Jun 2004 13:50:05 -0000	1.28
  @@ -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>
  
  
  
  1.21      +68 -59    maven-plugins/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
  
  Index: DefaultArtifactDeployer.java
  ===================================================================
  RCS file: /home/cvs/maven-plugins/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DefaultArtifactDeployer.java	23 Jun 2004 13:04:28 -0000	1.20
  +++ DefaultArtifactDeployer.java	25 Jun 2004 13:50:05 -0000	1.21
  @@ -103,25 +103,29 @@
               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 destFiles = new ArrayList();
  +            destFiles.add(repositoryPath);
  +            destFiles.add(repositoryPath + ".md5");
   
  -        List srcFiles = new ArrayList();
  -        srcFiles.add(file.getAbsolutePath());
  -        srcFiles.add(md5File.getAbsolutePath());
  -
  -        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 @@
           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());
  +
  +            String snapshotFilename =
  +                handler.constructRepositoryFullPath(
  +                    type,
  +                    project,
  +                    MavenConstants.SNAPSHOT_SIGNIFIER);
  +            String timestampedFilename =
  +                handler.constructRepositoryFullPath(type, project, snapshotSignature);
  +
  +            List destFiles = new ArrayList();
  +            destFiles.add(snapshotFilename);
  +            destFiles.add(snapshotFilename + ".md5");
  +            destFiles.add(timestampedFilename);
  +            destFiles.add(timestampedFilename + ".md5");
  +
  +            srcFiles.add(snapshotVersionFile.getAbsolutePath());
  +
  +            String snapshotVersionsFilename = 
  +                handler.constructRepositoryDirectoryPath(type, project)
  +                    + project.getArtifactId()
  +                    + "-snapshot-version";
  +            destFiles.add(snapshotVersionsFilename);
   
  -        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 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");
  -        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);
  -        // Delete md5 file
  -        md5File.delete();
  -    };
  +            // 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);
  +        }
  +        finally {
  +            // Delete md5 file
  +            md5File.delete();
  +            snapshotVersionFile.delete();
  +        }
  +    }
   
       /**
        * @see ArtifactDeployer#install(String, String, Project, ArtifactTypeHandler)
  @@ -226,7 +236,7 @@
               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 @@
               {
                   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 @@
   
           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
               {
  
  
  
  1.12      +8 -3      maven-plugins/artifact/src/main/org/apache/maven/deploy/DeployTool.java
  
  Index: DeployTool.java
  ===================================================================
  RCS file: /home/cvs/maven-plugins/artifact/src/main/org/apache/maven/deploy/DeployTool.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DeployTool.java	2 May 2004 15:04:34 -0000	1.11
  +++ DeployTool.java	25 Jun 2004 13:50:05 -0000	1.12
  @@ -20,6 +20,8 @@
   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;
  @@ -42,6 +44,8 @@
       /** 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 @@
                   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 @@
               }
               catch (Exception e)
               {
  +                LOG.error("Error cleaning up from the deployer", e);
               }
           }
       }
  -}
  \ No newline at end of file
  +}
  
  
  
  1.5       +7 -3      maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/ExternalDeployer.java
  
  Index: ExternalDeployer.java
  ===================================================================
  RCS file: /home/cvs/maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/ExternalDeployer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ExternalDeployer.java	2 Mar 2004 14:59:31 -0000	1.4
  +++ ExternalDeployer.java	25 Jun 2004 13:50:05 -0000	1.5
  @@ -17,6 +17,8 @@
    * ====================================================================
    */
   
  +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;
  @@ -39,6 +41,8 @@
   
       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 @@
   
           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)
           {
  
  
  
  1.11      +7 -5      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- FtpDeployer.java	14 Jun 2004 13:36:48 -0000	1.10
  +++ FtpDeployer.java	25 Jun 2004 13:50:05 -0000	1.11
  @@ -22,6 +22,8 @@
   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;
  @@ -43,7 +45,7 @@
    * @version $Id$
    * 
    * @todo review exception handling
  - * 
  + * @todo don't spool to System.out
    * 
    */
   public class FtpDeployer extends AbstractDeployer
  @@ -52,6 +54,7 @@
       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 @@
               {
                   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 @@
               if (FTPReply.isPositiveCompletion(reply) == false)
               {
                   ftp.disconnect();
  -                System.err.println();
                   throw new AuthenticationException("FTP server refused connection.");
               }
           }
  @@ -118,7 +120,7 @@
                   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);
  
  
  
  1.10      +9 -4      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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- GenericSshDeployer.java	14 Jun 2004 13:36:48 -0000	1.9
  +++ GenericSshDeployer.java	25 Jun 2004 13:50:05 -0000	1.10
  @@ -19,6 +19,9 @@
   
   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;
   
  @@ -58,6 +61,8 @@
   
       private Session session = null;
   
  +    private static final Log LOG = LogFactory.getLog(GenericSshDeployer.class);
  +
       /**
        * @return
        */
  @@ -99,7 +104,7 @@
               {
                   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 @@
                           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 void showMessage(String message)
           {
  -            System.out.println(message);
  +            LOG.info(message);
   
           }
   
  
  
  
  1.7       +5 -8      maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/HttpDeployer.java
  
  Index: HttpDeployer.java
  ===================================================================
  RCS file: /home/cvs/maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/HttpDeployer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HttpDeployer.java	2 Mar 2004 14:59:31 -0000	1.6
  +++ HttpDeployer.java	25 Jun 2004 13:50:05 -0000	1.7
  @@ -137,16 +137,13 @@
           {
               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
  
  
  
  1.11      +9 -3      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SFtpDeployer.java	14 Jun 2004 13:36:48 -0000	1.10
  +++ SFtpDeployer.java	25 Jun 2004 13:50:05 -0000	1.11
  @@ -18,6 +18,9 @@
    */
   
   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;
  @@ -36,6 +39,8 @@
    */
   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 @@
               {
                   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 @@
   
       }
   
  +    /** @todo use logger */
       class ProgressMonitor implements SftpProgressMonitor
       {
   
  
  
  
  1.11      +24 -15    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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ScpDeployer.java	14 Jun 2004 13:36:48 -0000	1.10
  +++ ScpDeployer.java	25 Jun 2004 13:50:05 -0000	1.11
  @@ -20,6 +20,9 @@
   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;
  @@ -43,6 +46,8 @@
    */
   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 void deploy(DeployRequest request) throws TransferFailedException
       {
  -        System.out.println("deployNotCompressed=" + deployNotCompressed);
  +        LOG.debug("deployNotCompressed=" + deployNotCompressed);
           if (deployNotCompressed)
           {
               doDeployNotCompressed(request);
  @@ -247,7 +252,7 @@
       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 @@
               // 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 @@
               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'
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org