maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mic...@apache.org
Subject cvs commit: maven/src/plugins-build/artifact project.xml
Date Tue, 17 Jun 2003 22:06:01 GMT
michal      2003/06/17 15:06:01

  Modified:    src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer
                        DefaultArtifactDeployer.java
               src/plugins-build/artifact project.xml
  Added:       src/plugins-build/artifact/src/main/org/apache/maven/deploy/deployers
                        Deployer.java HttpDeployer.java
                        AbstractDeployer.java FtpDeployer.java
                        SshDeployer.java FileDeployer.java
               src/plugins-build/artifact/src/main/org/apache/maven/deploy/exceptions
                        UnsupportedProtocolDeployException.java
                        DeployException.java
                        NotAuthorizedDeployException.java
                        ProxyNotAuthorizedDeployException.java
               src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer
                        MavenDeployRequest.java
               src/plugins-build/artifact/src/main/org/apache/maven/deploy
                        DeployRequest.java DeployTool.java
  Removed:     src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer
                        MavenAuthenticationInfo.java
               src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/deploy
                        SshDeployer.java HttpDeployer.java
                        AbstractDeployer.java Deployer.java
                        GenericAuthenticationInfo.java
                        AuthenticationInfo.java FtpDeployer.java
  Log:
  Refactoring to make it simillar to fetch component in maven-new.
  Code is not yet fully functional.
  
  Revision  Changes    Path
  1.1                  maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/deployers/Deployer.java
  
  Index: Deployer.java
  ===================================================================
  package org.apache.maven.deploy.deployers;
  
  import org.apache.maven.deploy.DeployRequest;
  import org.apache.maven.deploy.exceptions.DeployException;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache MavenSession" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache MavenSession", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  /**
   * Interface for all Maven deployers.
   *
   * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
   * @version $Id: Deployer.java,v 1.1 2003/06/17 22:05:59 michal Exp $
   */
  public interface Deployer
  {
      /**
       * 
       * @param request
       */
      public void deploy(DeployRequest request) throws DeployException;
  }
  
  
  
  1.1                  maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/deployers/HttpDeployer.java
  
  Index: HttpDeployer.java
  ===================================================================
  package org.apache.maven.deploy.deployers;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache MavenSession" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache MavenSession", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.net.MalformedURLException;
  import java.net.URL;
  
  import org.apache.commons.httpclient.Credentials;
  import org.apache.commons.httpclient.Header;
  import org.apache.commons.httpclient.HostConfiguration;
  import org.apache.commons.httpclient.HttpClient;
  import org.apache.commons.httpclient.HttpException;
  import org.apache.commons.httpclient.UsernamePasswordCredentials;
  import org.apache.commons.httpclient.methods.PutMethod;
  import org.apache.maven.deploy.DeployRequest;
  import org.apache.maven.deploy.exceptions.DeployException;
  
  /**
   * 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.1 2003/06/17 22:05:59 michal Exp $
   * 
   * @todo still have to account for differing setups for people deploying to
   *       their own sites and to the central repository.
   *
   * @todo deal with proxies
   * @todo deal with authentication
   */
  public class HttpDeployer extends AbstractDeployer
  {
  
      /**
       * Description of the Method
       */
      public void deploy(DeployRequest request) throws DeployException
      {
          URL url = null;
          try
          {
              url = new URL(request.getUrl());
          }
          catch (MalformedURLException murle)
          {
          }
  
          Credentials creds =
              new UsernamePasswordCredentials(
                  request.getUser(),
                  request.getPass());                
  
          //create a singular HttpClient object
          HttpClient client = new HttpClient();
          
  
          //establish a connection within 5 seconds
          client.setConnectionTimeout(5000);
  
          //set username / password
          if (creds != null)
          {
              client.getState().setCredentials(null, creds);
          }
  
          //
          HostConfiguration hc = new HostConfiguration();
          hc.setHost(request.getHost());              
          //start a session with the webserver
          client.setHostConfiguration(hc);
  
          //create a method object
          PutMethod method = new PutMethod(url.getPath());
          
          try
          {
             method.setRequestBody(new FileInputStream(request.getInputFile()));
          }
          catch(FileNotFoundException io)
          {
            throw new DeployException("input file: '"+ request.getInputFile() + " not found ");
          }  
  
          //turn follow redirects off
          method.setFollowRedirects(false);
  
          //turn strict mode on
          method.setStrictMode(false);
  
          //execute the method
          try
          {
              client.executeMethod(method);
          }
          catch (HttpException he)
          {
              System.err.println("Http error connecting to '" + url + "'");
              System.err.println(he.getMessage());
              System.exit(-4);
          }
          catch (IOException ioe)
          {
              System.err.println("Unable to connect to '" + url + "'");
              System.exit(-3);
          }
  
          //get the request headers
          Header[] requestHeaders = method.getRequestHeaders();
  
          //get the response headers
          Header[] responseHeaders = method.getResponseHeaders();
  
          //get the response body
          byte[] responseBody = method.getResponseBody();
  
          method.releaseConnection();
      }
  }
  
  
  
  1.1                  maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/deployers/AbstractDeployer.java
  
  Index: AbstractDeployer.java
  ===================================================================
  package org.apache.maven.deploy.deployers;
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache MavenSession" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache MavenSession", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  /**
   * Base deployer from which all deployers are derived.
   *
   * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
   * @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
   * @version $Id: AbstractDeployer.java,v 1.1 2003/06/17 22:05:59 michal Exp $
   */
  public abstract class AbstractDeployer implements Deployer
  {
  
  }
  
  
  
  1.1                  maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java
  
  Index: FtpDeployer.java
  ===================================================================
  package org.apache.maven.deploy.deployers;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache MavenSession" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache MavenSession", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.PrintWriter;
  
  import org.apache.commons.net.ProtocolCommandEvent;
  import org.apache.commons.net.ProtocolCommandListener;
  import org.apache.commons.net.ftp.FTP;
  import org.apache.commons.net.ftp.FTPClient;
  import org.apache.commons.net.ftp.FTPConnectionClosedException;
  import org.apache.commons.net.ftp.FTPReply;
  import org.apache.maven.deploy.DeployRequest;
  import org.apache.maven.deploy.exceptions.DeployException;
  
  
  
  
  
  /**
   * An FTP deployer based on the FTPClient in the Commons Net package.
   *
   * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
   *
   * @version $Id: FtpDeployer.java,v 1.1 2003/06/17 22:05:59 michal Exp $
   *
   * @todo account for username and password.
   */
  public class FtpDeployer extends AbstractDeployer
  {
          
      /**
       * Description of the Method
       */
      public void deploy(DeployRequest request) throws DeployException
      {
          String username = request.getUser();
          String password = request.getPass();
          String host = request.getHost();
          
          
          FTPClient ftp = new FTPClient();
                  
          
          ftp.addProtocolCommandListener(
              new PrintCommandListener(new PrintWriter(System.out)));
  
          try
          {                        
              int reply;
              if ( request.getPort()!= DeployRequest.UNKNOWN_PORT)
              {
                 ftp.connect(host, request.getPort());
              }
              else
              {
                  ftp.connect(host);
              }               
              System.out.println("Connected to " + host + ".");
  
              // After connection attempt, you should check the reply code to verify
              // success.
              reply = ftp.getReplyCode();
  
              if (FTPReply.isPositiveCompletion(reply) == false)
              {                
                  ftp.disconnect();
                  System.err.println();
                  throw new DeployException("FTP server refused connection.");
              }
          }
          catch (IOException e)
          {
              if (ftp.isConnected())
              {
                  try
                  {
                      ftp.disconnect();
                  }
                  catch (IOException f)
                  {
                      // do nothing
                  }
              }            
              throw new DeployException("Could not connect to server.");
          }
  
          __main : try
          {
              if (ftp.login(username, password) == false)
              {
                  ftp.logout();
                  break __main;
              }
  
              System.out.println("Remote system is " + ftp.getSystemName());
  
              // Set to binary mode.
              ftp.setFileType(FTP.BINARY_FILE_TYPE);
              // Use passive mode as default because most of us are
              // behind firewalls these days.
              ftp.enterLocalPassiveMode();
              String workingDir = request.getOutputDir();
              String filename = request.getOutputFile();
              System.out.println("Working directory " + workingDir);
              System.out.println("Filename: " + filename);       
              ftp.makeDirectory(workingDir);
              ftp.changeWorkingDirectory( workingDir);            
              ftp.storeFile(filename, new FileInputStream(request.getInputFile()));            
              ftp.logout();
          }
          catch (FTPConnectionClosedException e)
          {            
              throw new DeployException("Server closed connection.");            
          }
          catch (IOException e)
          {
              e.printStackTrace();
          }
          finally
          {
              if (ftp.isConnected())
              {
                  try
                  {
                      ftp.disconnect();
                  }
                  catch (IOException f)
                  {
                      // do nothing
                  }
              }
          }
      }
  
      /**
       * Description of the Class
       */
      public class PrintCommandListener implements ProtocolCommandListener
      {
          private PrintWriter writer;
  
          /**
           * Constructor for the PrintCommandListener object
           *
           * @param writer
           */
          public PrintCommandListener(PrintWriter writer)
          {
              this.writer = writer;
          }
  
          /**
           * Description of the Method
           */
          public void protocolCommandSent(ProtocolCommandEvent event)
          {
              writer.print(event.getMessage());
              writer.flush();
          }
  
          /**
           * Description of the Method
           */
          public void protocolReplyReceived(ProtocolCommandEvent event)
          {
              writer.print(event.getMessage());
              writer.flush();
          }
      }
      
  }
  
  
  
  1.1                  maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/deployers/SshDeployer.java
  
  Index: SshDeployer.java
  ===================================================================
  package org.apache.maven.deploy.deployers;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache MavenSession" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache MavenSession", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  import com.jcraft.jsch.JSch;
  import com.jcraft.jsch.UserInfo;
  import com.jcraft.jsch.ChannelExec;
  import com.jcraft.jsch.Session;
  import com.jcraft.jsch.Channel;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.PipedInputStream;
  import java.io.PipedOutputStream;
  
  import org.apache.maven.deploy.DeployRequest;
  
  /**
   * An ssh2 deployer that uses the JSch library and the JCE. We will first try to
   * use public keys for authentication and if that doesn't work then we fall back
   * to using the login and password of the user in question. NOTE: We are
   * assuming the standard port of 22.
   *
   * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
   * @version $Id: SshDeployer.java,v 1.1 2003/06/17 22:05:59 michal Exp $
   * @todo still have to account for differing setups for people deploying to
   *      their own sites and to the central repository.
   */
  public class SshDeployer extends AbstractDeployer
  {
  
     public final static int DEFAULT_SSH_PORT = 22;
      /**
       * @see Deployer#project
       */
      public void deploy(DeployRequest request)
      {
          try
          {
              JSch jsch = new JSch();
              
              int port = request.getPort();
              if (port == DeployRequest.UNKNOWN_PORT)
              {
                 port = DEFAULT_SSH_PORT;
              }
              Session session =
                  jsch.getSession(request.getHost(), port);
              //22
  
              // Look for the private key and use it if available.
              File privateKey = new File(request.getPrivateKey());
  
              if (privateKey.exists())
              {
                  session.setIdentity(privateKey.getPath());
              }
  
              // username and password will be given via UserInfo interface.
              UserInfo ui = new MavenUserInfo(request);
              session.setUserInfo(ui);
              session.connect();
  
              String inputFile = request.getInputFile();
              // exec 'scp -t remoteArtifactPath' remotely
              String command =
                  "scp -t "
                      + request.getOutputDir()
                      + "/"
                      + request.getOutputFile();
              Channel channel = session.openChannel("exec");
              ((ChannelExec) channel).setCommand(command);
  
              // plug I/O streams for remote scp
              PipedOutputStream out = new PipedOutputStream();
              channel.setInputStream(new PipedInputStream(out));
              PipedInputStream in = new PipedInputStream();
              channel.setOutputStream(new PipedOutputStream(in));
  
              channel.connect();
  
              byte[] tmp = new byte[1];
  
              // wait for '\0'
              do
              {
                  in.read(tmp, 0, 1);
              }
              while (tmp[0] != 0);
  
              // send "C0644 filesize filename", where filename should not include '/'
              int filesize = (int) (new File( inputFile )).length();
              command = "C0644 " + filesize + " " + inputFile;            
              command += "\n";
              out.write(command.getBytes());
              out.flush();
  
              // wait for '\0'
              do
              {
                  in.read(tmp, 0, 1);
              }
              while (tmp[0] != 0);
  
              // send a content of localArtifactPath
              FileInputStream fis = new FileInputStream(inputFile);
              byte[] buf = new byte[1024];
              while (true)
              {
                  int len = fis.read(buf, 0, buf.length);
                  if (len <= 0)
                  {
                      break;
                  }
                  out.write(buf, 0, len);
                  out.flush();
              }
  
              // send '\0'
              buf[0] = 0;
              out.write(buf, 0, 1);
              out.flush();
  
              // wait for '\0'
              do
              {
                  in.read(tmp, 0, 1);
              }
              while (tmp[0] != 0);
          }
          catch (Exception e)
          {
              System.out.println(e);
          }
      }
  
      /**
       * MavenUserInfo class which returns the necessary name and password from
       * the POM to secure an ssh connection.
       */
      public class MavenUserInfo implements UserInfo
      {
          
          DeployRequest request;
          
          MavenUserInfo(DeployRequest request)
          {
            this.request = request;
          }
  
          /**
           * Gets the name attribute of the MavenUserInfo object
           */
          public String getName()
          {
              return request.getUser();
          }
  
          /**
           * Gets the password attribute of the MavenUserInfo object
           */
          public String getPassword()
          {
              return request.getPass();
          }
  
          /**
           * Gets the passphrase attribute of the MavenUserInfo object
           */
          public String getPassphrase(String message)
          {
              return request.getPassphrase();
          }
  
          /**
           * Required to satisfy UserInfo interface. Not used currently.
           */
          public boolean promptNameAndPassphrase(String message)
          {
              return true;
          }
  
          /**
           * Required to satisfy UserInfo interface. Not used currently.
           */
          public boolean promptNameAndPassword(String message)
          {
              return true;
          }
  
          /**
           * Required to satisfy UserInfo interface. Not used currently.
           */
          public boolean retry()
          {
              return true;
          }
  
          /**
           * Required to satisfy UserInfo interface. Not used currently.
           */
          public boolean prompt(String message)
          {
              return true;
          }
      }
  }
  
  
  
  1.1                  maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/deployers/FileDeployer.java
  
  Index: FileDeployer.java
  ===================================================================
  package org.apache.maven.deploy.deployers;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  import java.io.File;
  import java.io.IOException;
  
  import org.apache.commons.io.FileUtils;
  import org.apache.maven.deploy.DeployRequest;
  import org.apache.maven.deploy.exceptions.DeployException;
  
  
  /**
   * 
   * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 
   * @version $Id: FileDeployer.java,v 1.1 2003/06/17 22:05:59 michal Exp $
   */
  public class FileDeployer implements Deployer
  {
  
      /**
       * @see org.apache.maven.fetch.fetchers.Fetcher#fetchUrl(java.lang.String, java.io.OutputStream)
       */
      public void deploy(DeployRequest request) throws DeployException
      {        
          try
          {
              File inputFile = new File( request.getInputFile() );
              File outputFile = new File( request.getOutputDir(), request.getOutputFile());
              FileUtils.copyFile(inputFile, outputFile);
          }
          catch (IOException e)
          {
             throw new DeployException("Cannot copy file: " + e.getMessage());
          }       
      }    
  }
  
  
  
  1.1                  maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/exceptions/UnsupportedProtocolDeployException.java
  
  Index: UnsupportedProtocolDeployException.java
  ===================================================================
  package org.apache.maven.deploy.exceptions;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  
  /**
   * 
   * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 
   * @version $Id: UnsupportedProtocolDeployException.java,v 1.1 2003/06/17 22:06:00 michal Exp $
   */
  public class UnsupportedProtocolDeployException extends DeployException
  {
      /**
       * @param message
       */
      public UnsupportedProtocolDeployException(String message)
      {
          super(message);
      }
  
       /**
       * @param message
       * @param cause
       */
      public UnsupportedProtocolDeployException(String message, Throwable cause)
      {
          super(message, cause);
      }
  
  }
  
  
  
  1.1                  maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/exceptions/DeployException.java
  
  Index: DeployException.java
  ===================================================================
  package org.apache.maven.deploy.exceptions;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  
  /**
   * 
   * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 
   * @version $Id: DeployException.java,v 1.1 2003/06/17 22:06:00 michal Exp $
   */
  public class DeployException extends Exception
  {
      private final String message;
      private final Throwable cause;
      public DeployException(String message, Throwable cause)
      {
          this.message = message;
          this.cause = cause;
      }
  
      public DeployException(String message)
      {
          this.message = message;
          this.cause = null;
      }
  
      /**
       * @return
       */
      public Throwable getCause()
      {
          return cause;
      }
  
      /**
       * @return
       */
      public String getMessage()
      {
          return message;
      }
  
  }
  
  
  
  1.1                  maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/exceptions/NotAuthorizedDeployException.java
  
  Index: NotAuthorizedDeployException.java
  ===================================================================
  package org.apache.maven.deploy.exceptions;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  /**
   * 
   * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 
   * @version $Id: NotAuthorizedDeployException.java,v 1.1 2003/06/17 22:06:00 michal Exp $
   */
  public class NotAuthorizedDeployException extends DeployException
  {
  
      /**
       * @param message
       */
      public NotAuthorizedDeployException(String message)
      {
          super(message);
      }
  
      /**
       * @param message
       * @param cause
       */
      public NotAuthorizedDeployException(String message, Throwable cause)
      {
          super(message, cause);
      }
  
  }
  
  
  
  1.1                  maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/exceptions/ProxyNotAuthorizedDeployException.java
  
  Index: ProxyNotAuthorizedDeployException.java
  ===================================================================
  package org.apache.maven.deploy.exceptions;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  
  /**
   * 
   * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 
   * @version $Id: ProxyNotAuthorizedDeployException.java,v 1.1 2003/06/17 22:06:00 michal Exp $
   */
  public class ProxyNotAuthorizedDeployException extends DeployException
  {
  
      /**
       * @param message
       */
      public ProxyNotAuthorizedDeployException(String message)
      {
          super(message);
      }
  
      /**
       * @param message
       * @param cause
       */
      public ProxyNotAuthorizedDeployException(String message, Throwable cause)
      {
          super(message, cause);
          // TODO Auto-generated constructor stub
      }
  
  }
  
  
  
  1.2       +61 -97    maven/src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
  
  Index: DefaultArtifactDeployer.java
  ===================================================================
  RCS file: /home/cvs/maven/src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultArtifactDeployer.java	16 Jun 2003 14:26:01 -0000	1.1
  +++ DefaultArtifactDeployer.java	17 Jun 2003 22:06:00 -0000	1.2
  @@ -62,12 +62,10 @@
   import java.util.Date;
   
   import org.apache.commons.io.FileUtils;
  +import org.apache.commons.lang.StringUtils;
   import org.apache.maven.MavenConstants;
   import org.apache.maven.MavenException;
  -import org.apache.maven.artifact.deployer.deploy.Deployer;
  -import org.apache.maven.artifact.deployer.deploy.FtpDeployer;
  -import org.apache.maven.artifact.deployer.deploy.HttpDeployer;
  -import org.apache.maven.artifact.deployer.deploy.SshDeployer;
  +import org.apache.maven.deploy.DeployTool;
   import org.apache.maven.project.Project;
   
   /**
  @@ -191,72 +189,64 @@
           String version)
           throws MavenException
       {
  -        String repoPath = getRepositoryPath(type, project, version);
  -        String host = getDistributionHost(project);
  -        String remotePath = getDistributionDirectory(project) + "/" + repoPath;
  -        Deployer deployer = getDeployer(host);
  -        
  -        //Cut of protcol prefix from host name
  -        
  -        host = host.substring( host.indexOf("://") + 3 );
  -        
  -        System.out.println(
  -            "Deploying: '"
  -                + artifact
  -                + "' to host: '"
  -                + host
  -                + "' remote path: '"
  -                + remotePath);
  -        MavenAuthenticationInfo authInfo = new MavenAuthenticationInfo(project);
  -        deployer.deploy(authInfo, host, artifact, remotePath);
  -        System.out.println("Deployment finished");
  -    }
  -
  -    /**
  -     * @param project
  -     * @return
  -     */
  -    private String getDistributionHost(Project project) throws MavenException
  -    {
  -        String host = host = project.getDistributionSite();
  -        if (host == null || host.length() == 0)
  -        {
  -            host =
  -                (String) project.getContext().getVariable(
  -                    "maven.deployer.host");
  -        }
  -        if (host == null)
  -        {
  -            throw new MavenException("Distribution host is not set");
  -        }
   
  -        return host;
  -    }
  +        DeployTool deployTool = new DeployTool();
   
  -    /**
  -     * 
  -     * @param project
  -     * @return
  -     * @throws MavenException
  -     */
  -    private String getDistributionDirectory(Project project)
  -        throws MavenException
  -    {
  +        // trick add special values to context for default repository;
   
  -        String dir = project.getDistributionDirectory();
  +        String repos =
  +            (String) project.getContext().getVariable("maven.deploy.repos");
   
  -        if (dir == null || dir.length() == 0)
  +        String distSite = project.getDistributionSite();
  +        if (distSite != null && distSite.length() > 0)
           {
  -            dir =
  -                (String) project.getContext().getVariable(
  -                    "maven.deployer.remote.directory");
  +            project.getContext().setVariable(
  +                "maven.deploy.default.url",
  +                project.getDistributionSite());
  +            project.getContext().setVariable(
  +                "maven.deploy.default.dir",
  +                project.getDistributionDirectory());
   
  +            repos = "default, " + repos;
           }
  -        if (dir == null)
  +
  +        String repositoryPath = getRepositoryPath(type, project, version);
  +
  +        String[] repoArray = StringUtils.split(repos, ",");
  +
  +        System.out.println(
  +            "Will deploy to " + repoArray.length + " repo(s): " + repos);
  +        for (int i = 0; i < repoArray.length; i++)
           {
  -            throw new MavenException("Distribution directory is not set");
  +
  +            String repo = repoArray[i];
  +            System.out.println("Deploying to repo: " + repo);
  +
  +            MavenDeployRequest request =
  +                new MavenDeployRequest(
  +                    project,
  +                    repo,
  +                    artifact,
  +                    repositoryPath,
  +                    getRepositoryFile(type, project, version));
  +
  +            System.out.println(
  +                "Deploying: '"
  +                    + artifact
  +                    + "' to host: '"
  +                    + request.getHost()
  +                    + "' remote path: '"
  +                    + request.getOutputDir());
  +            try
  +            {
  +                deployTool.performUpload(request);
  +            }
  +            catch (Exception e)
  +            {
  +                throw new MavenException("Cannot deploy", e);
  +            }
  +
           }
  -        return dir;
   
       }
   
  @@ -285,14 +275,21 @@
           path.append(project.getArtifactDirectory());
           path.append("/");
           path.append(type + "s");
  -        path.append("/");
  +        return path.toString();
  +    }
  +
  +    private String getRepositoryFile(
  +        String type,
  +        Project project,
  +        String version)
  +    {
  +        StringBuffer path = new StringBuffer();
           path.append(project.getArtifactId());
           path.append("-");
           path.append(version);
           path.append(".");
           path.append(extensionForType(type));
           return path.toString();
  -
       }
   
       /**
  @@ -318,39 +315,6 @@
               return "jar";
           }
           return type;
  -    }
  -
  -    /**
  -     * 
  -     * @param host
  -     * @param project
  -     * @return
  -     * @throws MavenException
  -     */
  -    private Deployer getDeployer(String host) throws MavenException
  -    {   
  -        Deployer deployer = null;
  -
  -        if (host.startsWith("http://"))
  -        {
  -            deployer = new HttpDeployer();
  -        }
  -        else
  -            if (host.startsWith("ssh://"))
  -            {    
  -                deployer = new SshDeployer();
  -            }
  -            else
  -                if (host.startsWith("ftp://"))
  -                {
  -                    deployer = new FtpDeployer();
  -                }
  -                else
  -                {
  -                    throw new MavenException(
  -                        "unsupported protocol: '" + host + "'");
  -                }
  -        return deployer;
       }
   
   }
  
  
  
  1.1                  maven/src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/MavenDeployRequest.java
  
  Index: MavenDeployRequest.java
  ===================================================================
  package org.apache.maven.artifact.deployer;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache MavenSession" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache MavenSession", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  import org.apache.maven.deploy.DeployRequest;
  import org.apache.maven.project.Project;
  
  /**
   * 
   * The Bean which serves as Proxy for Jelly scripts To Artifact Deployement API
   * 
   * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 
   * @version $Id: MavenDeployRequest.java,v 1.1 2003/06/17 22:06:00 michal Exp $
   */
  public class MavenDeployRequest extends DeployRequest
  {
  
      /**
       * 
       * @param project
       * @param repository This is alias name of the repository 
       *       like </i>repo1</i> taken from <i>maven.deploy.repos= repo1, repo2</i>
       * @param inputDir
       * @param outputDir
       * @param outputFile
       */
      public MavenDeployRequest(
          Project project,
          String repository,
          String inputFile,
          String outputDir,
          String outputFile)
      {
          super();
          String username =
              (String) project.getContext().getVariable(
                  "maven.deploy." + repository + ".username");
  
          System.out.println(repository + " username:" + username);
          String password =
              (String) project.getContext().getVariable(
                  "maven.deploy." + repository + ".password");
  
          System.out.println(repository + " password: '" + password + "'");
  
          String passphrase =
              (String) project.getContext().getVariable(
                  "maven.deploy." + repository + ".passphrase");
  
          String privateKey =
              (String) project.getContext().getVariable(
                  "maven.deploy." + repository + ".privatekey");
  
          String url =
              (String) project.getContext().getVariable(
                  "maven.deploy." + repository + ".url");
  
          String dir =
              (String) project.getContext().getVariable(
                  "maven.deploy." + repository + ".dir");
  
          String port =
              (String) project.getContext().getVariable(
                  "maven.deploy." + repository + ".port");
  
          String proxyHost =
              (String) project.getContext().getVariable(
                  "maven.deploy." + repository + ".proxy.host");
          String proxyUser =
              (String) project.getContext().getVariable(
                  "maven.deploy." + repository + ".proxy.username");
          String proxyPassword =
              (String) project.getContext().getVariable(
                  "maven.deploy." + repository + ".proxy.password");
  
          String proxyPort =
              (String) project.getContext().getVariable(
                  "maven.deploy." + repository + ".proxy.port");
  
          setUser(username);
          setPass(password);
          setPassphrase(passphrase);
          setPrivateKey(url);
          setUrl(url);
  
          try
          {
              setPort(Integer.parseInt(port));
          }
          catch (Exception e)
          {
  
              setProxyHost(proxyHost);
              setProxyUser(proxyUser);
              setProxyPass(proxyPassword);
          }
          try
          {
              setProxyPort(Integer.parseInt(proxyPort));
          }
          catch (Exception e)
          {
  
          }
  
          setInputFile(inputFile);
  
          String ouputDir = dir + "/" + outputDir;
          setOutputFile(outputFile);
          setOutputDir(ouputDir);
  
      }
  
  }
  
  
  
  1.1                  maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/DeployRequest.java
  
  Index: DeployRequest.java
  ===================================================================
  package org.apache.maven.deploy;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  /**
   * 
   * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 
   * @version $Id: DeployRequest.java,v 1.1 2003/06/17 22:06:00 michal Exp $
   */
  public class DeployRequest
  {
      public final static int UNKNOWN_PORT = -1;
  
      private String url;
      private int port = UNKNOWN_PORT;
      private String outputDir;
      private String outputFile;
      private String inputFile;
  
      /*
       * Resource access user / pass /group
       */
      private String user;
      private String pass;
      private String group;
      private String passphrase;
      private String privateKey;
  
      public DeployRequest()
      {
      
      }
  
      public DeployRequest(String url)
      {
          this.url = url;
      }
  
      // private boolean resumeDownload = false;
      private String headerUserAgent = "Maven-Deploy-" + DeployTool.VERSION;
  
      /*
       * Proxy settings.  If proxyHost is not null, settings will be used. 
       */
      private String proxyHost = null;
      private String proxyUser = null;
      private String proxyPass = null;
      private int proxyPort = UNKNOWN_PORT;
  
      /**
       * @return
       */
      public int getPort()
      {
          return port;
      }
  
      /**
       * @param port
       */
      public void setPort(int port)
      {
          this.port = port;
      }
  
      /**
       * @return
       */
      public String getPassphrase()
      {
          return passphrase;
      }
  
      /**
       * @param passphrase
       */
      public void setPassphrase(String passphrase)
      {
          this.passphrase = passphrase;
      }
  
      /**
       * @return
       */
      public String getPrivateKey()
      {
          return privateKey;
      }
  
      /**
       * @param privateKey
       */
      public void setPrivateKey(String privateKey)
      {
          this.privateKey = privateKey;
      }
  
      /**
       * @return
       */
      public String getGroup()
      {
          return group;
      }
  
      /**
       * @param group
       */
      public void setGroup(String group)
      {
          this.group = group;
      }
  
      /**
       * @return
       */
      public String getHeaderUserAgent()
      {
          return headerUserAgent;
      }
  
      /**
       * @param headerUserAgent
       */
      public void setHeaderUserAgent(String headerUserAgent)
      {
          this.headerUserAgent = headerUserAgent;
      }
  
      /**
       * @return
       */
      public String getInputFile()
      {
          return inputFile;
      }
  
      /**
       * @param inputFile
       */
      public void setInputFile(String inputFile)
      {
          this.inputFile = inputFile;
      }
  
      /**
       * @return
       */
      public String getOutputDir()
      {
          return outputDir;
      }
  
      /**
       * @param outputDir
       */
      public void setOutputDir(String outputDir)
      {
          this.outputDir = outputDir;
      }
  
      /**
       * @return
       */
      public String getOutputFile()
      {
          return outputFile;
      }
  
      /**
       * @param outputFile
       */
      public void setOutputFile(String outputFile)
      {
          this.outputFile = outputFile;
      }
  
      /**
       * @return
       */
      public String getPass()
      {
          return pass;
      }
  
      /**
       * @param pass
       */
      public void setPass(String pass)
      {
          this.pass = pass;
      }
  
      /**
       * @return
       */
      public String getProxyHost()
      {
          return proxyHost;
      }
  
      /**
       * @param proxyHost
       */
      public void setProxyHost(String proxyHost)
      {
          this.proxyHost = proxyHost;
      }
  
      /**
       * @return
       */
      public String getProxyPass()
      {
          return proxyPass;
      }
  
      /**
       * @param proxyPass
       */
      public void setProxyPass(String proxyPass)
      {
          this.proxyPass = proxyPass;
      }
  
      /**
       * @return
       */
      public int getProxyPort()
      {
          return proxyPort;
      }
  
      /**
       * @param proxyPort
       */
      public void setProxyPort(int proxyPort)
      {
          this.proxyPort = proxyPort;
      }
  
      /**
       * @return
       */
      public String getProxyUser()
      {
          return proxyUser;
      }
  
      /**
       * @param proxyUser
       */
      public void setProxyUser(String proxyUser)
      {
          this.proxyUser = proxyUser;
      }
  
      /**
       * @return
       */
      public String getUrl()
      {
          return url;
      }
  
      /**
       * @param url
       */
      public void setUrl(String url)
      {
          this.url = url;
      }
  
      /**
       * @return
       */
      public String getUser()
      {
          return user;
      }
  
      /**
       * @param user
       */
      public void setUser(String user)
      {
          this.user = user;
      }
  
      /**
       * Cut of protocol from the URL
       * @return
       */
      public String getHost()
      {
          if (url == null )
          {
             return "localhost";
          }
          return url.substring(url.indexOf("://") + 3);
      }
  
  }
  
  
  
  1.1                  maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/DeployTool.java
  
  Index: DeployTool.java
  ===================================================================
  package org.apache.maven.deploy;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  import org.apache.maven.deploy.deployers.Deployer;
  import org.apache.maven.deploy.deployers.FileDeployer;
  import org.apache.maven.deploy.deployers.FtpDeployer;
  import org.apache.maven.deploy.deployers.HttpDeployer;
  import org.apache.maven.deploy.deployers.SshDeployer;
  import org.apache.maven.deploy.exceptions.DeployException;
  import org.apache.maven.deploy.exceptions.UnsupportedProtocolDeployException;
  
  
  /**
   * 
   * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 
   * @version $Id: DeployTool.java,v 1.1 2003/06/17 22:06:00 michal Exp $
   */
  public class DeployTool
  {
      public static final String VERSION = "1.0-dev";
  
      public void performUpload(DeployRequest request) throws DeployException
      {
  
          String url = request.getUrl();
          Deployer deployer = null;
  
          if (url.startsWith("http://"))
          {
              deployer = new HttpDeployer();
          }
  
          if (url.startsWith("file://"))
          {
              deployer = new FileDeployer();
          }
          if (url.startsWith("ssh://"))
          {
              deployer = new SshDeployer();
          }
          if (url.startsWith("ftp://"))
          {
              deployer = new FtpDeployer();
          }
          if (deployer == null)
          {
              throw new UnsupportedProtocolDeployException(url);
          }
          deployer.deploy(request);
  
      }
  }
  
  
  
  1.2       +8 -0      maven/src/plugins-build/artifact/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/maven/src/plugins-build/artifact/project.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- project.xml	16 Jun 2003 14:26:01 -0000	1.1
  +++ project.xml	17 Jun 2003 22:06:01 -0000	1.2
  @@ -46,6 +46,14 @@
         <version>2.0-beta1</version>
         <type>jar</type>
       </dependency>
  +    
  +    <dependency>
  +      <groupId>commons-lang</groupId>
  +      <artifactId>commons-lang</artifactId>
  +      <version>1.0</version>
  +      <type>jar</type>
  +    </dependency>
  +    
   
   
       <dependency>
  
  
  

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


Mime
View raw message