diff --git a/artifact/src/main/org/apache/maven/artifact/deployer/ArtifactDeployer.java b/artifact/src/main/org/apache/maven/artifact/deployer/ArtifactDeployer.java index 7be1483d..f72e4724 100644 --- a/artifact/src/main/org/apache/maven/artifact/deployer/ArtifactDeployer.java +++ b/artifact/src/main/org/apache/maven/artifact/deployer/ArtifactDeployer.java @@ -61,23 +61,39 @@ import org.apache.maven.project.Project; /** * - * The Bean which serves as Proxy To Hibernate API - *
+ * The Bean which is used in Jelly Scripts + * and serves as a proxy to Artifact Deployer API * + * Note that all paths in repository are computed + * and source file name is igonred. + * + * Other remark: To deploy an artifact means much + * more then to copy signle file. In every case + * also MD5 file created and copied to remote repository. + * In case of snapshots the process in even more complex. * - * * @author Michal Maczka - * @version $Id: ArtifactDeployer.java,v 1.1 2003/06/16 14:26:01 michal Exp $ + * @version $Id: ArtifactDeployer.java,v 1.2 2003/06/29 11:57:39 michal Exp $ */ public interface ArtifactDeployer { - + /** - * Deploy given artifact to remote repository - * @param artifact - * @param type - * @param project - * @throws MavenException + * Deploy given artifact to remote repository + * + * @param artifact Artifact filename + * @param type The type of the artifact + * (like war, jar) + * @param project The project which is a producer of the artifact + * POM conatains a bunch of varaiables which are used + * to control the deployment process (e.g + * + * + * @throws MavenException */ public void deploy(String artifact, String type, Project project) throws MavenException; @@ -85,30 +101,37 @@ public interface ArtifactDeployer /** * Deploy given artifact as a snapshot to remote repository * @param artifact - * @param type - * @param project + * @param type The type of the artifact + * (like war, jar) + * @param project The project which is a producer of the artifact + * @see ArtifactDeployer#deploy(String, String, Project) + * * @throws MavenException */ public void deploySnapshot(String artifact, String type, Project project) throws MavenException; - + /** * Install given artifact in local repository - * @param artifact - * @param type - * @param project + * @param artifact file name of the artifact + * @param type The type of the artifact + * (like war, jar) + * @param project The project which is a producer of the artifact * @throws MavenException - */ + */ public void install(String artifact, String type, Project project) throws MavenException; - + /** * Install given artifact as snapshot in local repository * @param artifact - * @param type - * @param project + * @param type The type of the artifact + * (like war, jar) + * @param project The project which is a producer of the artifact * @throws MavenException - */ + */ public void installSnapshot(String artifact, String type, Project project) throws MavenException; + + } diff --git a/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java b/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java index eabff4f9..ed7b04a0 100644 --- a/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java +++ b/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java @@ -76,13 +76,13 @@ import org.apache.maven.util.MD5Sum; * * * @author Michal Maczka - * @version $Id: DefaultArtifactDeployer.java,v 1.9 2003/06/25 15:25:19 michal Exp $ + * @version $Id: DefaultArtifactDeployer.java,v 1.10 2003/06/29 11:57:39 michal Exp $ */ public class DefaultArtifactDeployer implements ArtifactDeployer { /** - * + * Date/time stamp which is appended to snapshot filenames */ public final static DateFormat SNAPSHOT_MARKER = new SimpleDateFormat("yyyyMMdd.HHmmss"); @@ -191,8 +191,8 @@ public class DefaultArtifactDeployer implements ArtifactDeployer } /** - * Install given file in local repsoitory - * @param artifact the artifact file to insatall + * Install given file in local repository + * @param artifact the artifact file to install * @param type The type of the artiafct * @param project * @param version String denominating the version of the artifact @@ -254,10 +254,8 @@ public class DefaultArtifactDeployer implements ArtifactDeployer // trick add special values to context for default repository; String repos = - (String) project.getContext().getVariable("maven.repo.repos"); - - System.out.println("repos: " + repos); - + (String) project.getContext().getVariable("maven.repo.list"); + String distSite = project.getDistributionSite(); if (distSite != null && distSite.length() > 0) { @@ -273,7 +271,7 @@ public class DefaultArtifactDeployer implements ArtifactDeployer if (repos == null || repos.length() == 0) { - System.out.println("No remote repository is defined"); + System.out.println("No remote repository is defined for deployment"); return; } String[] repoArray = StringUtils.split(repos, ","); @@ -328,8 +326,9 @@ public class DefaultArtifactDeployer implements ArtifactDeployer } /** - * + * Return the local repository path form given project * @param project + * @return The path to local repoository in local file system */ private String getLocalRepository(Project project) { @@ -337,11 +336,13 @@ public class DefaultArtifactDeployer implements ArtifactDeployer } /** - * - * @param type - * @param project + * Return relative path from repositorry root + * for given parameters + * @param type Artifact type + * @param project * @param snapshot * @return + * @todo replace this with RepoistoryLayout Service */ private String getRepositoryPath( String type, @@ -355,6 +356,14 @@ public class DefaultArtifactDeployer implements ArtifactDeployer return path.toString(); } + + /** + * + * @param type + * @param project + * @param version + * @return + */ private String getRepositoryFile( String type, Project project, @@ -441,6 +450,11 @@ public class DefaultArtifactDeployer implements ArtifactDeployer } /** + * Create MD5 checksum file for given file. File is created + * in the same folder + * @param File + * @return The File which contatins MD5 checksum + * @throws MavenException when opertaion failed */ private File createMD5Checksum(File file) throws MavenException { @@ -475,9 +489,9 @@ public class DefaultArtifactDeployer implements ArtifactDeployer } /** - * + * Return file extension for given type * @todo Dirty hack util Repository Layout Service is used - * @return + * @return extension for given type */ private String extensionForType(String type) { diff --git a/artifact/src/main/org/apache/maven/artifact/deployer/DeployBean.java b/artifact/src/main/org/apache/maven/artifact/deployer/DeployBean.java index ffa19ee7..42f6524f 100644 --- a/artifact/src/main/org/apache/maven/artifact/deployer/DeployBean.java +++ b/artifact/src/main/org/apache/maven/artifact/deployer/DeployBean.java @@ -64,10 +64,10 @@ import org.apache.maven.project.Project; /** * * The Bean which provides access to Artifact Deployement API - * for jelly scripts. + * from jelly scripts. * * @author Michal Maczka - * @version $Id: DeployBean.java,v 1.2 2003/06/25 15:25:19 michal Exp $ + * @version $Id: DeployBean.java,v 1.3 2003/06/29 11:57:39 michal Exp $ */ public class DeployBean { @@ -156,7 +156,6 @@ public class DeployBean */ public void deploy() throws MavenException { - System.out.println("deploy called"); checkAttributes(); artifactDeployer.deploy(artifact, type, project); } diff --git a/artifact/src/main/org/apache/maven/artifact/deployer/DeployRequestBuilder.java b/artifact/src/main/org/apache/maven/artifact/deployer/DeployRequestBuilder.java index af1e7c74..dd2b570b 100644 --- a/artifact/src/main/org/apache/maven/artifact/deployer/DeployRequestBuilder.java +++ b/artifact/src/main/org/apache/maven/artifact/deployer/DeployRequestBuilder.java @@ -58,6 +58,7 @@ package org.apache.maven.artifact.deployer; import org.apache.maven.deploy.DeployRequest; import org.apache.maven.deploy.exceptions.DeployException; +import org.apache.maven.deploy.exceptions.WrongParameterException; import org.apache.maven.project.Project; /** @@ -65,7 +66,7 @@ import org.apache.maven.project.Project; * Perform mapping between project's properties and attributes of DeployRequest class. * * @author Michal Maczka - * @version $Id: DeployRequestBuilder.java,v 1.1 2003/06/25 15:25:19 michal Exp $ + * @version $Id: DeployRequestBuilder.java,v 1.2 2003/06/29 11:57:39 michal Exp $ */ public class DeployRequestBuilder { @@ -122,29 +123,27 @@ public class DeployRequestBuilder "maven.repo." + repository + ".group"); String proxyHost = - (String) project.getContext().getVariable( - "maven.repo." + repository + ".proxy"); + (String) project.getContext().getProxyHost(); String proxyUser = - (String) project.getContext().getVariable( - "maven.repo." + repository + ".proxy.username"); + (String) project.getContext().getProxyUserName(); + String proxyPassword = - (String) project.getContext().getVariable( - "maven.repo." + repository + ".proxy.password"); + (String) project.getContext().getProxyPassword(); + String proxyPort = - (String) project.getContext().getVariable( - "maven." + repository + ".proxy.port"); - - request.setUser(username); + (String) project.getContext().getProxyPort(); + + request.setUserName(username); request.setPassword(password); request.setPassphrase(passphrase); request.setPrivateKey(privateKey); request.setGroup(remoteGroup); request.setUrl(url); request.setProxyHost(proxyHost); - request.setProxyUser(proxyUser); - request.setProxyPass(proxyPassword); + request.setProxyUserName(proxyUser); + request.setProxyPassword(proxyPassword); if (port != null) { try @@ -154,7 +153,7 @@ public class DeployRequestBuilder } catch (Exception e) { - throw new DeployException("maven.repo." + repository + ".port should be an integer"); + throw new WrongParameterException("maven.repo." + repository + ".port should be an integer"); } } if (proxyPort != null) @@ -165,7 +164,7 @@ public class DeployRequestBuilder } catch (Exception e) { - throw new DeployException("maven.repo." + repository + ".proxy.port should be an integer"); + throw new WrongParameterException("maven.repo." + repository + ".proxy.port should be an integer"); } } diff --git a/artifact/src/main/org/apache/maven/deploy/DeployRequest.java b/artifact/src/main/org/apache/maven/deploy/DeployRequest.java index 90618739..e552445a 100644 --- a/artifact/src/main/org/apache/maven/deploy/DeployRequest.java +++ b/artifact/src/main/org/apache/maven/deploy/DeployRequest.java @@ -18,7 +18,7 @@ package org.apache.maven.deploy; * the documentation and/or other materials provided with the * distribution. * - * 3. The end-user documentation included with the redistribution, + * 3. The end-userName 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/)." @@ -57,42 +57,72 @@ package org.apache.maven.deploy; */ /** + * Holder of the variables which are used by deployers for + * esatblishing connection to remote hosts and to + * deploy the file to correct location in remote file system * * @author Michal Maczka - * @version $Id: DeployRequest.java,v 1.4 2003/06/25 15:25:19 michal Exp $ + * @version $Id: DeployRequest.java,v 1.5 2003/06/29 11:57:40 michal Exp $ */ public class DeployRequest { + /** Used to mark */ public final static int UNKNOWN_PORT = -1; + public final static String HEADER_USER_AGENT = "Maven-Deploy-" + DeployTool.VERSION; + /** The nickname (alias) of the repository*/ private String repositoryAlias; + + /** URL of the remote host*/ private String url; + + /** Port of remote host */ private int port = UNKNOWN_PORT; + + /** The directory where artifact will be placed */ private String destDir; + + /** The filename of the artifact */ private String destFile; + + /** The artifact file in local file system */ private String srcFile; - /* - * Resource access user / password /group - */ - private String user; + /** The login name of the user in @ remote host*/ + private String userName; + + /** Password */ private String password; + + /** Remote group name */ private String group; + + /** The passpharse of the user's private key file */ private String passphrase; + + /** The absoluth path to private key file */ private String privateKey; - /* - * Proxy server settings. If proxy host is not null, settings will be used. - */ + /** Proxy Server host*/ private String proxyHost = null; - private String proxyUser = null; - private String proxyPass = null; + + /** the login name of the user @ Proxy Server host*/ + private String proxyUserName = null; + + /** the password user @ Proxy Server host*/ + private String proxyPassword = null; + + /** Proxy server port */ private int proxyPort = UNKNOWN_PORT; + /** Indicates if debug mode should be used*/ + private boolean debugOn = false; + /** + * Set the alias of the repository * @param repositoryAlias */ public void setRepositoryAlias(String repositoryAlias) @@ -101,7 +131,8 @@ public class DeployRequest } /** - * @return + * Get the port of the host + * @return the port of the remote host where repository resides. */ public int getPort() { @@ -109,6 +140,7 @@ public class DeployRequest } /** + * Set the port of the remote host * @param port */ public void setPort(int port) @@ -117,7 +149,12 @@ public class DeployRequest } /** - * @return + * Get the passphrase of the private key file. + * Passphrase is used only when host/protocol supports + * authetification via exchange of private/public keys + * and private key was provided. + * + * @return the passphrase of the private key file */ public String getPassphrase() { @@ -125,7 +162,8 @@ public class DeployRequest } /** - * @param passphrase + * Set the passphrase of the private key file + * @param passphrase the passphrase of the private key file */ public void setPassphrase(String passphrase) { @@ -133,7 +171,8 @@ public class DeployRequest } /** - * @return + * Get the absoluth path to the private key + * @return the path to private key */ public String getPrivateKey() { @@ -141,7 +180,8 @@ public class DeployRequest } /** - * @param privateKey + * Set the aboluth path to private key + * @param privateKey The path to private key in local file system */ public void setPrivateKey(String privateKey) { @@ -149,7 +189,10 @@ public class DeployRequest } /** - * @return + * Get the remote group to which will belong to + * after deployemnt. Not all protolcols support + * allow to change the group of the artifact + * @return remote group */ public String getGroup() { @@ -157,7 +200,9 @@ public class DeployRequest } /** - * @param group + * Set the remote group for artifact which is deployed + * @param group The remote group to which + * artifact which is deployed will belong */ public void setGroup(String group) { @@ -173,7 +218,8 @@ public class DeployRequest } /** - * @return + * Get aboluth path to local files = artifact + * @return Path to artifact file */ public String getSrcFile() { @@ -181,6 +227,7 @@ public class DeployRequest } /** + * Set the aboluthe path to artifact file * @param srcFile */ public void setSrcFile(String inputFile) @@ -189,7 +236,10 @@ public class DeployRequest } /** - * @return + * Get destination directory in remote file system for + * the artifact + * + * @return destination dir for artifact */ public String getDestDir() { @@ -197,7 +247,9 @@ public class DeployRequest } /** - * @param destDir + * Set destinatin directory in remote file system + * + * @param destDir the remote path for the artifact */ public void setDestDir(String outputDir) { @@ -205,6 +257,7 @@ public class DeployRequest } /** + * Get destination file name * @return */ public String getDestFile() @@ -213,6 +266,7 @@ public class DeployRequest } /** + * Set destination file name * @param destFile */ public void setDestFile(String outputFile) @@ -221,7 +275,9 @@ public class DeployRequest } /** - * @return + * Get the password to be used when user will be authetificated + * while connection to remote host is established + * @return the password of user */ public String getPassword() { @@ -229,6 +285,8 @@ public class DeployRequest } /** + * + * * @param password */ public void setPassword(String pass) @@ -237,7 +295,8 @@ public class DeployRequest } /** - * @return + * Returhn proxy server host name + * @return proxy server host name */ public String getProxyHost() { @@ -245,6 +304,7 @@ public class DeployRequest } /** + * Set proxy host name * @param proxyHost */ public void setProxyHost(String proxyHost) @@ -253,23 +313,26 @@ public class DeployRequest } /** - * @return + * Get user's password used to login to proxy server + * @return the user's password at proxy host */ - public String getProxyPass() + public String getProxyPassword() { - return proxyPass; + return proxyPassword; } /** - * @param proxyPass + * Set the proxy server password + * @param proxyPassword teh epassword to use to login to a proxy server */ - public void setProxyPass(String proxyPass) + public void setProxyPassword(String proxyPass) { - this.proxyPass = proxyPass; + this.proxyPassword = proxyPass; } /** - * @return + * Get the proxy port + * @return Poroxy server port */ public int getProxyPort() { @@ -277,6 +340,7 @@ public class DeployRequest } /** + * Set the proxy port * @param proxyPort */ public void setProxyPort(int proxyPort) @@ -285,23 +349,27 @@ public class DeployRequest } /** + * + * Get the proxy user name * @return */ - public String getProxyUser() + public String getProxyUserName() { - return proxyUser; + return proxyUserName; } /** - * @param proxyUser + * Set the proxy user name + * @param proxyUserName the proxy user name */ - public void setProxyUser(String proxyUser) + public void setProxyUserName(String proxyUser) { - this.proxyUser = proxyUser; + this.proxyUserName = proxyUser; } /** - * @return + * Get url of remote host + * @return URL (with protocol) of remote host */ public String getUrl() { @@ -309,7 +377,8 @@ public class DeployRequest } /** - * @param url + * Set url of remote host + * @param url url of remote host */ public void setUrl(String url) { @@ -317,24 +386,26 @@ public class DeployRequest } /** - * @return + * Get user login name at remote host + * @return user name at remote host */ - public String getUser() + public String getUserName() { - return user; + return userName; } /** - * @param user + * Set user name at remote host + * @param userName */ - public void setUser(String user) + public void setUserName(String user) { - this.user = user; + this.userName = user; } /** - * Cut of protocol from the URL - * @return + * Return the host name (Cuts of protocol from the URL) + * @return The host name */ public String getHost() { @@ -342,11 +413,13 @@ public class DeployRequest { return "localhost"; } - return url.substring(url.indexOf("://") + 3); + return url.substring(url.indexOf("://") + 3).trim(); } /** - * @return + * Get the name of the repository to which deploy attempt will be made + * + * @return the name (nickname, alias) of the repository */ public String getRepositoryAlias() { @@ -354,4 +427,22 @@ public class DeployRequest return repositoryAlias; } + /** + * Get Debug mode + * @return the debug mode + */ + public boolean isDebugOn() + { + return debugOn; + } + + /** + * Set deplyer in debug mode - more messages will be wriiten + * @param debugOn + */ + public void setDebugOn(boolean debugOn) + { + this.debugOn = debugOn; + } + } diff --git a/artifact/src/main/org/apache/maven/deploy/DeployTool.java b/artifact/src/main/org/apache/maven/deploy/DeployTool.java index 04a168c6..fce9d99e 100644 --- a/artifact/src/main/org/apache/maven/deploy/DeployTool.java +++ b/artifact/src/main/org/apache/maven/deploy/DeployTool.java @@ -62,27 +62,44 @@ import org.apache.maven.deploy.deployers.FtpDeployer; import org.apache.maven.deploy.deployers.HttpDeployer; import org.apache.maven.deploy.deployers.SFtpDeployer; import org.apache.maven.deploy.deployers.ScpDeployer; -import org.apache.maven.deploy.exceptions.DeployException; -import org.apache.maven.deploy.exceptions.UnsupportedProtocolDeployException; +import org.apache.maven.deploy.exceptions.NotAuthorizedDeployException; +import org.apache.maven.deploy.exceptions.ProxyNotAuthorizedDeployException; +import org.apache.maven.deploy.exceptions.TransferFailedException; +import org.apache.maven.deploy.exceptions.UnsupportedProtocolException; +import org.apache.maven.deploy.exceptions.WrongParameterException; /** - * + * Delegates * @author Michal Maczka - * @version $Id: DeployTool.java,v 1.4 2003/06/25 12:33:11 michal Exp $ + * @version $Id: DeployTool.java,v 1.5 2003/06/29 11:57:40 michal Exp $ */ public class DeployTool { + /** Current Version **/ public static final String VERSION = "1.0-dev"; - public void performUpload(DeployRequest request) throws DeployException + /** + * Upload (deploy) artifact to remote repository using + * paramerters kepts in DeployReequest + * @param request The settings + * @throws DeployException When operation fails + */ + public void performUpload(DeployRequest request) + throws + TransferFailedException, + NotAuthorizedDeployException, + ProxyNotAuthorizedDeployException, + TransferFailedException, + WrongParameterException, + UnsupportedProtocolException { String url = request.getUrl(); Deployer deployer = null; if (url == null || url.length() == 1) { - throw new DeployException( - "No URL provided for repsoitory: " + throw new WrongParameterException( + "No URL provided for repository: " + request.getRepositoryAlias()); } if (url.startsWith(HttpDeployer.PROTOCOL)) @@ -107,7 +124,7 @@ public class DeployTool } if (deployer == null) { - throw new UnsupportedProtocolDeployException(url); + throw new UnsupportedProtocolException(url); } deployer.deploy(request); diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/Deployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/Deployer.java index ffbdb59e..08308b9f 100644 --- a/artifact/src/main/org/apache/maven/deploy/deployers/Deployer.java +++ b/artifact/src/main/org/apache/maven/deploy/deployers/Deployer.java @@ -1,7 +1,10 @@ package org.apache.maven.deploy.deployers; import org.apache.maven.deploy.DeployRequest; -import org.apache.maven.deploy.exceptions.DeployException; +import org.apache.maven.deploy.exceptions.NotAuthorizedDeployException; +import org.apache.maven.deploy.exceptions.ProxyNotAuthorizedDeployException; +import org.apache.maven.deploy.exceptions.TransferFailedException; +import org.apache.maven.deploy.exceptions.WrongParameterException; /* ==================================================================== * The Apache Software License, Version 1.1 @@ -61,15 +64,27 @@ import org.apache.maven.deploy.exceptions.DeployException; /** * Interface for all Maven deployers. + * + * Deployer which uploads a file to remote host accordingly to paramters + * recieved in deploy request + * * @author Jason van Zyl - * @version $Id: Deployer.java,v 1.1 2003/06/17 22:05:59 michal Exp $ + * @version $Id: Deployer.java,v 1.2 2003/06/29 11:57:40 michal Exp $ */ public interface Deployer { /** - * - * @param request + * Perform an unppload of single file to remote host + * @param request DeployRequest which should contatin all parameters + * which are necessery to upload a file + * to remote host. */ - public void deploy(DeployRequest request) throws DeployException; + public void deploy(DeployRequest request) + throws + TransferFailedException, + NotAuthorizedDeployException, + ProxyNotAuthorizedDeployException, + TransferFailedException, + WrongParameterException; } diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/FileDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/FileDeployer.java index fac0096b..c6172e9a 100644 --- a/artifact/src/main/org/apache/maven/deploy/deployers/FileDeployer.java +++ b/artifact/src/main/org/apache/maven/deploy/deployers/FileDeployer.java @@ -61,40 +61,43 @@ import java.io.IOException; import org.apache.commons.io.FileUtils; import org.apache.maven.deploy.DeployRequest; -import org.apache.maven.deploy.exceptions.DeployException; +import org.apache.maven.deploy.exceptions.TransferFailedException; /** + * Deployer which deploys to directory visible in local + * file system. * * @author Michal Maczka - * @version $Id: FileDeployer.java,v 1.5 2003/06/25 15:25:18 michal Exp $ + * @version $Id: FileDeployer.java,v 1.6 2003/06/29 11:57:40 michal Exp $ */ public class FileDeployer implements Deployer { + /** Protocol understandable by this deployer*/ public final static String PROTOCOL = "file://"; /** * @see org.apache.maven.fetch.fetchers.Fetcher#fetchUrl(java.lang.String, java.io.OutputStream) */ - public void deploy(DeployRequest request) throws DeployException + public void deploy(DeployRequest request) throws TransferFailedException { try { - File inputFile = new File(request.getSrcFile()); + File srcFile = new File(request.getSrcFile()); - File outputFile = + File destFile = new File(request.getHost(), request.getDestDir()); - if (! outputFile.exists()) + if (! destFile.exists()) { - outputFile.mkdirs(); + destFile.mkdirs(); } - outputFile = new File( outputFile, request.getDestFile()); - FileUtils.copyFile(inputFile, outputFile); + destFile = new File( destFile, request.getDestFile()); + FileUtils.copyFile(srcFile, destFile); } catch (IOException e) { - throw new DeployException("Cannot copy file: " + e.getMessage()); + throw new TransferFailedException("Cannot copy file: " + e.getMessage()); } } } diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java index 9b49501d..22216ff7 100644 --- a/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java +++ b/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java @@ -66,11 +66,7 @@ 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; - - - - +import org.apache.maven.deploy.exceptions.TransferFailedException; /** * An FTP deployer based on the FTPClient in the Commons Net package. @@ -80,41 +76,44 @@ import org.apache.maven.deploy.exceptions.DeployException; * * @author Jason van Zyl * @author Michal Maczka - * @version $Id: FtpDeployer.java,v 1.4 2003/06/25 15:25:18 michal Exp $ + * @version $Id: FtpDeployer.java,v 1.5 2003/06/29 11:57:39 michal Exp $ * * */ public class FtpDeployer extends AbstractDeployer { - + /** Protocol understandable by this deployer*/ public final static String PROTOCOL = "ftp://"; - - /** - * Description of the Method - */ - public void deploy(DeployRequest request) throws DeployException - { - String username = request.getUser(); - String password = request.getPassword(); - String host = request.getHost(); - - FTPClient ftp = new FTPClient(); - - - ftp.addProtocolCommandListener( - new PrintCommandListener(new PrintWriter(System.out))); + + + /** + * @see Deployer#deploy(DeployRequest) + */ + public void deploy(DeployRequest request) throws TransferFailedException + { + String username = request.getUserName(); + String password = request.getPassword(); + String host = request.getHost(); + + FTPClient ftp = new FTPClient(); + + if (request.isDebugOn()) + { + ftp.addProtocolCommandListener( + new PrintCommandListener(new PrintWriter(System.out))); + } try - { + { int reply; - if ( request.getPort()!= DeployRequest.UNKNOWN_PORT) + if (request.getPort() != DeployRequest.UNKNOWN_PORT) { - ftp.connect(host, request.getPort()); + 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 @@ -122,10 +121,10 @@ public class FtpDeployer extends AbstractDeployer reply = ftp.getReplyCode(); if (FTPReply.isPositiveCompletion(reply) == false) - { + { ftp.disconnect(); System.err.println(); - throw new DeployException("FTP server refused connection."); + throw new TransferFailedException("FTP server refused connection."); } } catch (IOException e) @@ -140,12 +139,12 @@ public class FtpDeployer extends AbstractDeployer { // do nothing } - } - throw new DeployException("Could not connect to server."); + } + throw new TransferFailedException("Could not connect to server."); } __main : try - { + { if (ftp.login(username.trim(), password.trim()) == false) { ftp.logout(); @@ -162,15 +161,15 @@ public class FtpDeployer extends AbstractDeployer String workingDir = request.getDestDir(); String filename = request.getDestFile(); System.out.println("Working directory " + workingDir); - System.out.println("Filename: " + filename); + System.out.println("Filename: " + filename); ftp.makeDirectory(workingDir); - ftp.changeWorkingDirectory( workingDir); - ftp.storeFile(filename, new FileInputStream(request.getSrcFile())); + ftp.changeWorkingDirectory(workingDir); + ftp.storeFile(filename, new FileInputStream(request.getSrcFile())); ftp.logout(); } catch (FTPConnectionClosedException e) - { - throw new DeployException("Server closed connection."); + { + throw new TransferFailedException("Server closed connection."); } catch (IOException e) { @@ -227,5 +226,5 @@ public class FtpDeployer extends AbstractDeployer writer.flush(); } } - + } diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/GenericSshDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/GenericSshDeployer.java index ee80d865..8e6714aa 100644 --- a/artifact/src/main/org/apache/maven/deploy/deployers/GenericSshDeployer.java +++ b/artifact/src/main/org/apache/maven/deploy/deployers/GenericSshDeployer.java @@ -59,7 +59,8 @@ package org.apache.maven.deploy.deployers; import java.io.File; import org.apache.maven.deploy.DeployRequest; -import org.apache.maven.deploy.exceptions.DeployException; +import org.apache.maven.deploy.exceptions.TransferFailedException; +import org.apache.maven.deploy.exceptions.WrongParameterException; import com.jcraft.jsch.JSch; import com.jcraft.jsch.Proxy; @@ -69,36 +70,39 @@ import com.jcraft.jsch.Session; import com.jcraft.jsch.UserInfo; /** - * An ssh2 deployer that uses the JSch library and the JCE. + * A base class for deployers using protocols from SSH2 family + * and JSch library for underlining implmenetation * - * This class deals with authetification stage of the process. + * This class deals with authentification stage of the process. * * 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. + * to using the login and password * - * - * @version $Id: GenericSshDeployer.java,v 1.2 2003/06/25 15:25:18 michal Exp $ + * @version $Id: GenericSshDeployer.java,v 1.3 2003/06/29 11:57:40 michal Exp $ * @todo still have to account for differing setups for people deploying to * their own sites and to the central repository. + * @todo improve exception handling */ public abstract class GenericSshDeployer extends AbstractDeployer { - + + /** Default port used for SSH protocol */ public final static int DEFAULT_SSH_PORT = 22; + + /** Default port used by SOCKS5 proxy server */ public final static int SOCKS5_PROXY_PORT = 1080; - /** * @see Deployer#project * * @todo better way of guessing what kind of proxy server is used - * by user + * by user. Jsch Supports among others SOCKS and HTTP proxies */ - public Session getSession(DeployRequest request) throws DeployException + public Session getSession(final DeployRequest request) + throws TransferFailedException { - + try { JSch jsch = new JSch(); @@ -108,36 +112,11 @@ public abstract class GenericSshDeployer extends AbstractDeployer { port = DEFAULT_SSH_PORT; } + System.out.println("host: '"+ request.getHost() + "'"); String host = request.getHost(); - Session session = jsch.getSession(request.getUser(), host, port); - - String proxyHost = request.getProxyHost(); - - if (proxyHost != null) - { - Proxy proxy = null; - int proxyPort = request.getProxyPort(); - //if port == 1080 we will use SOCKS5 Proxy - // otherwise will use HTTP Proxy - - if (proxyPort == SOCKS5_PROXY_PORT) - { - proxy = new ProxySOCKS5(proxyHost); - ((ProxySOCKS5) proxy).setUserPasswd( - request.getProxyUser(), - request.getProxyPass()); - } - else - { - proxy = new ProxyHTTP(proxyHost, proxyPort); - ((ProxyHTTP) proxy).setUserPasswd( - request.getProxyUser(), - request.getProxyPass()); - } - proxy.connect(session, host, port); - - } - + Session session = + jsch.getSession(request.getUserName(), host, port); + // Look for the private key and use it if available. if (request.getPrivateKey() != null) { @@ -145,12 +124,54 @@ public abstract class GenericSshDeployer extends AbstractDeployer if (privateKey.exists()) { + if (request.getPassphrase() == null) + { + String msg = + "Private key provided " + + "without passpharse for repo: " + + request.getRepositoryAlias(); + throw new WrongParameterException(msg); + } + System.out.println("Using private key: " + privateKey); jsch.addIdentity( privateKey.getAbsolutePath(), request.getPassphrase()); } + else + { + String msg = "Private key: " + privateKey + " not found "; + throw new WrongParameterException(msg); + } } + + String proxyHost = request.getProxyHost(); + + if (proxyHost != null) + { + Proxy proxy = null; + int proxyPort = request.getProxyPort(); + // HACK: + //if port == 1080 we will use SOCKS5 Proxy + // otherwise will use HTTP Proxy + + if (proxyPort == SOCKS5_PROXY_PORT) + { + proxy = new ProxySOCKS5(proxyHost); + ((ProxySOCKS5) proxy).setUserPasswd( + request.getProxyUserName(), + request.getProxyPassword()); + } + else + { + proxy = new ProxyHTTP(proxyHost, proxyPort); + ((ProxyHTTP) proxy).setUserPasswd( + request.getProxyUserName(), + request.getProxyPassword()); + } + proxy.connect(session, host, port); + + } // username and password will be given via UserInfo interface. UserInfo ui = new MavenUserInfo(request); session.setUserInfo(ui); @@ -161,7 +182,7 @@ public abstract class GenericSshDeployer extends AbstractDeployer catch (Exception e) { e.printStackTrace(); - throw new DeployException( + throw new TransferFailedException( "Cannot connect. Reason: " + e.getMessage(), e); } diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/HttpDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/HttpDeployer.java index 6dda7a63..01b8c23c 100644 --- a/artifact/src/main/org/apache/maven/deploy/deployers/HttpDeployer.java +++ b/artifact/src/main/org/apache/maven/deploy/deployers/HttpDeployer.java @@ -70,13 +70,13 @@ 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; +import org.apache.maven.deploy.exceptions.TransferFailedException; /** * An HTTP deployer based the Commons HttpClient library. * * @author Jason van Zyl - * @version $Id: HttpDeployer.java,v 1.3 2003/06/25 15:25:18 michal Exp $ + * @version $Id: HttpDeployer.java,v 1.4 2003/06/29 11:57:39 michal Exp $ * * @todo still have to account for differing setups for people deploying to * their own sites and to the central repository. @@ -86,12 +86,14 @@ import org.apache.maven.deploy.exceptions.DeployException; */ public class HttpDeployer extends AbstractDeployer { - + /**Protocol understood by by this deployer*/ public final static String PROTOCOL = "http://"; + + /** * Description of the Method */ - public void deploy(DeployRequest request) throws DeployException + public void deploy(DeployRequest request) throws TransferFailedException { URL url = null; try @@ -104,7 +106,7 @@ public class HttpDeployer extends AbstractDeployer Credentials creds = new UsernamePasswordCredentials( - request.getUser(), + request.getUserName(), request.getPassword()); //create a singular HttpClient object @@ -135,7 +137,7 @@ public class HttpDeployer extends AbstractDeployer } catch(FileNotFoundException io) { - throw new DeployException("input file: '"+ request.getSrcFile() + " not found "); + throw new TransferFailedException("input file: '"+ request.getSrcFile() + " not found "); } //turn follow redirects off diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/SFtpDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/SFtpDeployer.java index 94f23043..7ba166b3 100644 --- a/artifact/src/main/org/apache/maven/deploy/deployers/SFtpDeployer.java +++ b/artifact/src/main/org/apache/maven/deploy/deployers/SFtpDeployer.java @@ -58,7 +58,8 @@ package org.apache.maven.deploy.deployers; import org.apache.commons.lang.StringUtils; import org.apache.maven.deploy.DeployRequest; -import org.apache.maven.deploy.exceptions.DeployException; +import org.apache.maven.deploy.exceptions.TransferFailedException; +import org.apache.maven.deploy.exceptions.WrongParameterException; import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.JSchException; @@ -70,21 +71,24 @@ import com.jcraft.jsch.SftpException; * An SSH2/SFTP deployer * * @author Michal Maczka - * @version $Revision: 1.3 $ $Date: 2003/06/25 15:25:18 $ + * @version $Revision: 1.4 $ $Date: 2003/06/29 11:57:39 $ */ public class SFtpDeployer extends GenericSshDeployer { - + /**Protocol understood by by this deployer*/ public final static String PROTOCOL = "sftp://"; + + /** SSH2 Chanel names used to communicate with the server*/ private final static String SFTP_CHANNEL = "sftp"; + + /** artibute of file used in SSH which denotes is given file is a directory*/ private static final int S_IFDIR = 0x4000; /** - * @see Deployer#project - * - * @todo better way of guessing what king of proxy server is used + * @see Deployer#deploy(DeployRequest) */ - public void deploy(DeployRequest request) throws DeployException + public void deploy(DeployRequest request) + throws TransferFailedException, WrongParameterException { Integer groupId = null; try @@ -96,7 +100,7 @@ public class SFtpDeployer extends GenericSshDeployer } catch (NumberFormatException e) { - throw new DeployException("SFTP deployer: remote group should be an integer"); + throw new WrongParameterException("SFTP deployer: remote group should be an integer"); } Session session = getSession(request); @@ -109,7 +113,7 @@ public class SFtpDeployer extends GenericSshDeployer // directory String[] dirs = StringUtils.split(request.getDestDir(), "/"); for (int i = 0; i < dirs.length; i++) - { + { try { SftpATTRS attrs = channel.stat(dirs[i]); @@ -120,7 +124,7 @@ public class SFtpDeployer extends GenericSshDeployer } else { - throw new DeployException( + throw new WrongParameterException( "Incorrect remote path:" + request.getDestDir()); } } @@ -147,7 +151,7 @@ public class SFtpDeployer extends GenericSshDeployer String msg = "Error occured while deploying to remote host:" + request.getHost(); - throw new DeployException(msg, e); + throw new TransferFailedException(msg, e); } catch (JSchException e) @@ -155,7 +159,7 @@ public class SFtpDeployer extends GenericSshDeployer String msg = "Error occured while deploying to remote host:" + request.getHost(); - throw new DeployException(msg, e); + throw new TransferFailedException(msg, e); } finally { diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/ScpDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/ScpDeployer.java index b5ab5db6..1b55a1f5 100644 --- a/artifact/src/main/org/apache/maven/deploy/deployers/ScpDeployer.java +++ b/artifact/src/main/org/apache/maven/deploy/deployers/ScpDeployer.java @@ -62,7 +62,7 @@ import java.io.InputStream; import java.io.OutputStream; import org.apache.maven.deploy.DeployRequest; -import org.apache.maven.deploy.exceptions.DeployException; +import org.apache.maven.deploy.exceptions.TransferFailedException; import com.jcraft.jsch.ChannelExec; import com.jcraft.jsch.Session; @@ -71,21 +71,21 @@ import com.jcraft.jsch.Session; * An SSH2/SCP deployer * * @author Michal Maczka - * @version $Revision: 1.2 $ $Date: 2003/06/25 15:25:18 $ + * @version $Revision: 1.3 $ $Date: 2003/06/29 11:57:40 $ */ public class ScpDeployer extends GenericSshDeployer { - + /**Protocol understood by by this deployer*/ public final static String PROTOCOL = "scp://"; + /** SSH2 Chanel names used to communicate with the server*/ public final static String EXEC_CHANNEL = "exec"; /** - * @see Deployer#project - * - * @todo better way of guessing what king of proxy server is used + * @see Deployer#deploy(DeployRequest) + * */ - public void deploy(DeployRequest request) throws DeployException + public void deploy(DeployRequest request) throws TransferFailedException { Session session = getSession(request); @@ -116,10 +116,10 @@ public class ScpDeployer extends GenericSshDeployer } /** - * Execute simple command + * Execute "simple" remote command using exec channel */ private void executeSimpleCommand(Session session, String command) - throws DeployException + throws TransferFailedException { System.out.println("Executing command: " + command); @@ -134,7 +134,7 @@ public class ScpDeployer extends GenericSshDeployer } catch (Exception e) { - throw new DeployException( + throw new TransferFailedException( "Cannot execute remote command: " + command); } finally @@ -151,7 +151,7 @@ public class ScpDeployer extends GenericSshDeployer * Code extracted from JSCH exaples */ private void doCopy(Session session, DeployRequest request) - throws DeployException + throws TransferFailedException { try @@ -231,7 +231,7 @@ public class ScpDeployer extends GenericSshDeployer String msg = "Error occured while deploying to remote host:" + request.getHost(); - throw new DeployException(msg,e); + throw new TransferFailedException(msg,e); } } diff --git a/artifact/src/main/org/apache/maven/deploy/exceptions/DeployException.java b/artifact/src/main/org/apache/maven/deploy/exceptions/DeployException.java index 0d775a7b..1ff92ef4 100644 --- a/artifact/src/main/org/apache/maven/deploy/exceptions/DeployException.java +++ b/artifact/src/main/org/apache/maven/deploy/exceptions/DeployException.java @@ -58,11 +58,11 @@ package org.apache.maven.deploy.exceptions; /** - * + * Root class for all exception thrown by Deployers * @author Michal Maczka - * @version $Id: DeployException.java,v 1.1 2003/06/17 22:06:00 michal Exp $ + * @version $Id: DeployException.java,v 1.2 2003/06/29 11:57:39 michal Exp $ */ -public class DeployException extends Exception +public abstract class DeployException extends Exception { private final String message; private final Throwable cause; diff --git a/artifact/src/main/org/apache/maven/deploy/exceptions/TransferFailedException.java b/artifact/src/main/org/apache/maven/deploy/exceptions/TransferFailedException.java new file mode 100644 index 00000000..7ce6d834 --- /dev/null +++ b/artifact/src/main/org/apache/maven/deploy/exceptions/TransferFailedException.java @@ -0,0 +1,88 @@ +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 + * . + * + * ==================================================================== + */ + + +/** + * Exception which should be thrown when IO error occures during + * making remote copy of the file + * + * @author Michal Maczka + * @version $Id: TransferFailedException.java,v 1.1 2003/06/29 11:57:39 michal Exp $ + */ +public class TransferFailedException extends DeployException +{ + + /** + * @param message + */ + public TransferFailedException(String message) + { + super(message); + } + + /** + * @param message + * @param cause + */ + public TransferFailedException(String message, Throwable cause) + { + super(message, cause); + // TODO Auto-generated constructor stub + } + +} diff --git a/artifact/src/main/org/apache/maven/deploy/exceptions/UnsupportedProtocolDeployException.java b/artifact/src/main/org/apache/maven/deploy/exceptions/UnsupportedProtocolException.java similarity index 90% rename from artifact/src/main/org/apache/maven/deploy/exceptions/UnsupportedProtocolDeployException.java rename to artifact/src/main/org/apache/maven/deploy/exceptions/UnsupportedProtocolException.java index 046c6d49..297c1272 100644 --- a/artifact/src/main/org/apache/maven/deploy/exceptions/UnsupportedProtocolDeployException.java +++ b/artifact/src/main/org/apache/maven/deploy/exceptions/UnsupportedProtocolException.java @@ -60,14 +60,14 @@ package org.apache.maven.deploy.exceptions; /** * * @author Michal Maczka - * @version $Id: UnsupportedProtocolDeployException.java,v 1.1 2003/06/17 22:06:00 michal Exp $ + * @version $Id: UnsupportedProtocolException.java,v 1.1 2003/06/29 11:57:39 michal Exp $ */ -public class UnsupportedProtocolDeployException extends DeployException +public class UnsupportedProtocolException extends DeployException { /** * @param message */ - public UnsupportedProtocolDeployException(String message) + public UnsupportedProtocolException(String message) { super(message); } @@ -76,7 +76,7 @@ public class UnsupportedProtocolDeployException extends DeployException * @param message * @param cause */ - public UnsupportedProtocolDeployException(String message, Throwable cause) + public UnsupportedProtocolException(String message, Throwable cause) { super(message, cause); } diff --git a/artifact/src/main/org/apache/maven/deploy/exceptions/WrongParameterException.java b/artifact/src/main/org/apache/maven/deploy/exceptions/WrongParameterException.java new file mode 100644 index 00000000..9f83e516 --- /dev/null +++ b/artifact/src/main/org/apache/maven/deploy/exceptions/WrongParameterException.java @@ -0,0 +1,84 @@ +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 + * . + * + * ==================================================================== + */ + +/** + * + * @author Michal Maczka + * @version $Id: WrongParameterException.java,v 1.1 2003/06/29 11:57:39 michal Exp $ + */ +public class WrongParameterException extends DeployException +{ + + /** + * @param message + */ + public WrongParameterException(String message) + { + super(message); + } + + /** + * @param message + * @param cause + */ + public WrongParameterException(String message, Throwable cause) + { + super(message, cause); + } + +} diff --git a/artifact/xdocs/.cvsignore b/artifact/xdocs/.cvsignore new file mode 100644 index 00000000..cb6131bb --- /dev/null +++ b/artifact/xdocs/.cvsignore @@ -0,0 +1 @@ +stylesheets diff --git a/artifact/xdocs/authentification.xml b/artifact/xdocs/authentification.xml new file mode 100644 index 00000000..26eb9ff1 --- /dev/null +++ b/artifact/xdocs/authentification.xml @@ -0,0 +1,16 @@ + + + + + Maven Artifact Plugin Properties + Michal Maczka + + + +
+

+ In preparation +

+
+ +
diff --git a/artifact/xdocs/changes.xml b/artifact/xdocs/changes.xml new file mode 100644 index 00000000..8c68b109 --- /dev/null +++ b/artifact/xdocs/changes.xml @@ -0,0 +1,16 @@ + + + + Changes + Jason van Zyl + + + + + + Original release for Maven 1.0-beta8 + + + + + diff --git a/artifact/xdocs/examples.xml b/artifact/xdocs/examples.xml new file mode 100644 index 00000000..2d0df271 --- /dev/null +++ b/artifact/xdocs/examples.xml @@ -0,0 +1,49 @@ + + + + + Maven Artifact Plug-in Examples + Tim Anderson + + + +
+

+ The following example demonstrates how to depoyment + of artifact to remote repsoitories can be configured. + + +

+
+ +
diff --git a/artifact/xdocs/index.xml b/artifact/xdocs/index.xml new file mode 100644 index 00000000..2d1c936a --- /dev/null +++ b/artifact/xdocs/index.xml @@ -0,0 +1,41 @@ + + + + + Maven Artifact Plugin Properties + Michal Maczka + + + +
+ +

+ This plugin generates java sources from schemas using Castor. +

+ + + + + + + + + + + +
DocumentDescription
Properties + The behavior of the Maven Artifact Plug-in can be altered via + several properties. This document describes each property + available, and the default used. +
Tags + The Artifact plugin defines Jelly tags to generate java + sources. This document describes the tags and their + arguments. +
Examples + This document provides examples on how to configure the Maven Artifact + plugin for deploying artifacts to remote repository +
+
+
+ +
diff --git a/artifact/xdocs/navigation.xml b/artifact/xdocs/navigation.xml new file mode 100644 index 00000000..1872e547 --- /dev/null +++ b/artifact/xdocs/navigation.xml @@ -0,0 +1,20 @@ + + + + Maven Artifact Plugin + + + + + + + + + + + + + + + + diff --git a/artifact/xdocs/properties.xml b/artifact/xdocs/properties.xml new file mode 100644 index 00000000..fa3e15bf --- /dev/null +++ b/artifact/xdocs/properties.xml @@ -0,0 +1,116 @@ + + + + + Maven Artifact Plugin Properties + Michal Maczka + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Property nameDescriptionOptional?
maven.repo.list + The list of comma separated names of + the repositories to which artifacts produced by + the project will be deployed. E.g.: +
+ maven.repo.list=myrepo1,ibiblio +
+ The names of all other properties are constructed using the + entries present in this list. + Below the set of properties which can be used for + configuration of deployment process to each of the repositories + provided in the list. x in the names + of those properties should be replaced by actual repository name + (like ibiblio). + In case of doubts see an example +
No
maven.repo.x + Specifies the URL of remote repository. The URL + should contain the protocol name. +
+ See the the list of supported protocols. +
+ x corresponds to + repository name defined using maven.repo.list property. +
No
maven.repo.x.directory + The path at remote file system where artifacts will be put + No
maven.repo.x.username + The user name which will be used to authetificated + user if access to repository requires authentification. + Yes
maven.repo.x.password + The password which will be used to authetificate + user. +
+ If server/protocol supports authetification via + both private/public keys and password, + first will try to use keys for authentication + and if that doesn't work then + we fall back to using the username and password +
Yes
maven.repo.x.group + The remote group (UNIX group) to which + artifact will belong after it + will be deployed + Yes
maven.repo.x.privatekey + The absoluth path to private key file. +
+ Thie is used only for when protocol + supports authetification via private/public + key pair. +
Yes
maven.repo.x.passphrase + The passphrase used to decrypt private key file + Yes
+
+
+

+ If you are behind firewall and need to use proxy server see + following + section from the Maven User Guide . +

+
+ +
diff --git a/artifact/xdocs/protocols.xml b/artifact/xdocs/protocols.xml new file mode 100644 index 00000000..d6104907 --- /dev/null +++ b/artifact/xdocs/protocols.xml @@ -0,0 +1,76 @@ + + + + + Maven Artifact Plugin Properties + Michal Maczka + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Protocol nameURL PrefixUsernameDirectoryPasswordGroupPrivate KeyPassphrasePort
+ SCP + (Secure Copy) + scp://MandatoryMandatoryMandatory if private key unless private key is providedOptionalOptionalOptionalOptional (deafult is 22)
+ SFTP + (Secure FTP) + sftp://MandatoryMandatoryMandatory if private key unless private key is providedOptionalOptionalOptionalOptional (deafult is 22)
FTPftp://MandatoryMandatoryMandatoryNot supportedNot supportedNot supportedOptional (deafult is 21)
FILEfile://Not supportedMandatoryNot supportedNot supportedNot supportedNot supportedNot supported
+
+ +
diff --git a/artifact/xdocs/security.xml b/artifact/xdocs/security.xml new file mode 100644 index 00000000..8316310f --- /dev/null +++ b/artifact/xdocs/security.xml @@ -0,0 +1,45 @@ + + + + + Maven Artifact Plug-in Examples + Tim Anderson + + + +
+

+ + +> For the moment I have tested my API with username, user password +> kept in properties file. I think that such approach is not acceptable. +> +> You can use command line to pass properties to maven: +> +> maven war:deloy -Dmaven.repo.ibiblio.password = ****** +> +> +> This is already better ... but still not perfect. +> +> I will try to implement/use(if I find one) simple class which will "Prompt" +> to type your password (eventually to enter other required parameters which +> are missing) +> +> regards +> +> +> Michal + +I would avoid the command line passed password. It is much less secure +on unix than the password kept in a file. Command line can be seen by +simple ps commands, or e.g. linux systems store the in the /proc filesystem. +It should be used only from command files. + +incze + +]]> +

+
+ +
diff --git a/artifact/xdocs/tags.xml b/artifact/xdocs/tags.xml new file mode 100644 index 00000000..83594dce --- /dev/null +++ b/artifact/xdocs/tags.xml @@ -0,0 +1,206 @@ + + + + + Maven Castor Plug-in Tags + Tim Anderson + + + +
+

+ This document describes the + tags + that are available when using the Artifact Plug-in with Maven. +

+
+ +
+ + + + + + + + + + + + + + + + + + +
NameDescription
artifact:delpoyDeploy artifact to remote repository(ies)
artifact:delpoy-snapshotDeploy snapshot version of artifact to remote repository
artifact:installInstall artifact in local repository
artifact:install-snapshotInstall snapshot version of artifact in local repository
+ + +

+ Deploy an artifact to the set of remote repositories. +
+ Following files will be deployed to remote repository: +

    +
  1. Artifact file
  2. +
  3. MD5 checksum file of this artifact
  4. +
+

+ + + + + + + + + + + + + + + + + + + +
Attribute NameDescriptionOptional?
artifactThe path to the artifact fileNo
typeThe type of the artifact + (like jar or war). Type is used for + computing a detination path in repository. + No
project + The project (POM) which produced artifact which will be deployed. +
+ POM contatins a bunch of settings (variables and context properties) + which must be conulted in order to deploy artifact to repsoitories(s). + Those settings include: +
    +
  1. List of remote repositories where artifact will be deployed
  2. +
  3. artifactId, groupId, version
  4. +
  5. Individual settings of each repository
  6. +
  7. Proxy server settings
  8. +
  9. ...
  10. +
+
NO
+
+ + +

+ Deploy a snapshot version of the artifact to a set of remote repositories. +
+ During deloyment following files are put to remote repository: +

    +
  • Timestamped Artifact file
  • +
  • MD5 checksum file of timestamped artifact file
  • +
  • Artifact file with version marked as SNAPSHOT
  • +
  • MD5 checksum file of this file
  • +
  • ${artifactId}-snapshot-version
  • +
+ For exaple for artifact with artifactId = foo + the following files will be transfered to the remote repository: +
    +
  • foo-20030620.124616.jar
  • +
  • foo-20030620.124616.jar.md5
  • +
  • foo-SNAPSHOT.jar
  • +
  • foo-SNAPSHOT.jar.md5
  • +
  • foo-snapshot-version
  • +
+ + File foo-snapshot-version + simply contains the version number (20030620.124616) + that the snapshot is linked with, + so that + 'convert-snapshots' + can correctly update dependencies in projects which will use this artifact. +
+ artifact:deploy-snapshot tag uses the same set of attributes + as artifact:deploy tag +

+
+ +

+ Install an artifact in the local repository +
+ Following files will be copied to the local repository: +

    +
  1. Artifact file
  2. +
  3. MD5 checksum file of this artifact
  4. +
+

+

+ Why I should use artifact:install when it is so easy + just to copy a file inside my plugin? + +
+ There are few good reason for that: +

    +
  • + What is simple now, not necesserly must stay simple in the future. + E.g. when Maven will run in client-server mode + information about repository content can be cached + and even some files from repository can cached in memory + (e.g. POMS). Using centralized "proxy" which copies + files to the repository can play importand role in this + process. +
  • +
  • + It is as simple to use as ant:copy task, but does not require + usage of Ant. +
  • +
+

+ + + + + + + + + + + + + + + + + + + +
Attribute NameDescriptionOptional?
artifactThe path to the artifact fileNo
typeThe type of the artifact + (like jar or war). Type is used for + computing a detination path in repository. + No
project + Information kept in the POM included following bits + used for controling: +
    +
  • artifactId, groupId, version
  • +
  • Location of the local repository
  • +
+
NO
+
+ + +

+ Install a snapshot version of the artifact in the local repository +
+ Following files are copied to the local repository: +

    +
  • Timestamped Artifact file
  • +
  • Artifact file with version marked as SNAPSHOT
  • +
+ For exaple for artifact with artifactId foo + following files will be transfered to local repository: +
    +
  • foo-20030620.124616.jar
  • +
  • foo-SNAPSHOT.jar
  • +
+
+ artifact:install-snapshot tag uses the same set of attributes + as artifact:install tag +

+
+
+ +
\ No newline at end of file