You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by mi...@apache.org on 2003/06/16 16:26:02 UTC
cvs commit: maven/src/plugins-build/artifact/src/plugin-resources/templates manifest.vm
michal 2003/06/16 07:26:02
Added: src/plugins-build/artifact project.properties
plugin.properties .cvsignore project.xml
plugin.jelly
src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer
MavenAuthenticationInfo.java
DefaultArtifactDeployer.java DeployBean.java
ArtifactDeployer.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
src/plugins-build/artifact/src/plugin-resources/templates
manifest.vm
Log:
Generic code for:
- deployment of artifact to remote repositry
- installaton of artifact to local repository
- manifest generation
Revision Changes Path
1.1 maven/src/plugins-build/artifact/project.properties
Index: project.properties
===================================================================
# -------------------------------------------------------------------
# P R O J E C T P R O P E R T I E S
# -------------------------------------------------------------------
1.1 maven/src/plugins-build/artifact/plugin.properties
Index: plugin.properties
===================================================================
# -------------------------------------------------------------------
# P L U G I N P R O P E R T I E S
# -------------------------------------------------------------------
maven.artifact.manifest.extensions.add=false
maven.artifact.manifest.basedir=${plugin.dir}/plugin-resources/templates
maven.artifact.manifest.template=manifest.vm
1.1 maven/src/plugins-build/artifact/.cvsignore
Index: .cvsignore
===================================================================
target
velocity.log
maven.log
1.1 maven/src/plugins-build/artifact/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>${basedir}/../project.xml</extend>
<pomVersion>3</pomVersion>
<id>maven-artifact-plugin</id>
<name>Maven Artifact Plug-in</name>
<currentVersion>1.0</currentVersion>
<description/>
<shortDescription>Java Project Management Tools</shortDescription>
<url>http://maven.apache.org/reference/plugins/artifact/</url>
<siteDirectory>/www/maven.apache.org/reference/plugins/artifact/</siteDirectory>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven/src/plugins-build/artifact/</connection>
<url>http://cvs.apache.org/viewcvs/maven/src/plugins-build/artifact/</url>
</repository>
<developers/>
<dependencies>
<dependency>
<groupId>maven</groupId>
<artifactId>maven</artifactId>
<version>SNAPSHOT</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>20030203.000550</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>1.0.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>2.0-beta1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>jsch</groupId>
<artifactId>jsch</artifactId>
<version>0.0.9</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-jelly</groupId>
<artifactId>commons-jelly</artifactId>
<version>20030310.073407</version>
<url>http://jakarta.apache.org/commons/jelly/</url>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-jelly</groupId>
<artifactId>commons-jelly-tags-velocity</artifactId>
<version>20030303.205659</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.3</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
1.1 maven/src/plugins-build/artifact/plugin.jelly
Index: plugin.jelly
===================================================================
<?xml version="1.0"?>
<project
xmlns:j="jelly:core"
xmlns:define="jelly:define"
xmlns:ant="jelly:ant"
xmlns:velocity="jelly:velocity"
>
<define:taglib uri="artifact">
<!-- For times the same bean is used. -->
<define:jellybean
name="install"
method="install"
className="org.apache.maven.artifact.deployer.DeployBean"/>
<define:jellybean
name="install-snapshot"
method="installSnapshot"
className="org.apache.maven.artifact.deployer.DeployBean"/>
<define:jellybean
name="deploy"
method="deploy"
className="org.apache.maven.artifact.deployer.DeployBean"/>
<define:jellybean
name="deploy-snapshot"
method="deploySnapshot"
className="org.apache.maven.artifact.deployer.DeployBean"/>
<!--
|
| @filename
| @templateBasedir
| @template
|
|
|
-->
<define:tag name="manifest-file">
<j:if test="${templateBasedir == null}">
<j:set
var="templateBasedir"
value="${pom.getPluginContext('maven-artifact-plugin').getVariable('maven.artifact.manifest.basedir')}"/>
</j:if>
<j:if test="${template == null}">
<j:set
var="template"
value="${pom.getPluginContext('maven-artifact-plugin').getVariable('maven.artifact.manifest.template')}"/>
</j:if>
<j:set
var="mainclass"
value="${pom.getPluginContext('maven-artifact-plugin').getVariable('maven.artifact.manifest.mainclass')}"/>
<j:set
var="addExtensions"
value="${pom.getPluginContext('maven-artifact-plugin').getVariable('maven.artifact.manifest.extensions.add')}"/>
<ant:echo>Creating MANIFEST file:${filename}</ant:echo>
<ant:echo>Mainclass: ${mainclass}</ant:echo>
<ant:echo>addExtensions ${addExtensions}</ant:echo>
<velocity:merge
name="${filename}"
basedir="${templateBasedir}"
template="${template}"/>
</define:tag>
</define:taglib>
<goal name="artifact:load">
</goal>
</project>
1.1 maven/src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/MavenAuthenticationInfo.java
Index: MavenAuthenticationInfo.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.project.Project;
import org.apache.maven.artifact.deployer.deploy.GenericAuthenticationInfo;
/**
*
* Maps information kept in POM to AuthetificationInfo interface
* <br/>
*
*
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: MavenAuthenticationInfo.java,v 1.1 2003/06/16 14:26:01 michal Exp $
*/
public class MavenAuthenticationInfo extends GenericAuthenticationInfo
{
public MavenAuthenticationInfo(Project project)
{
String username =
(String) project.getContext().getVariable(
"maven.deployer.username");
String password =
(String) project.getContext().getVariable(
"maven.deployer.password");
String passphrase =
(String) project.getContext().getVariable(
"maven.deployer.passphrase");
setUsername(username);
setPassword(password);
setPassphrase(passphrase);
}
}
1.1 maven/src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
Index: DefaultArtifactDeployer.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 java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.io.FileUtils;
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.project.Project;
/**
*
* Default implemenataion of Artifact Deployer interface
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: DefaultArtifactDeployer.java,v 1.1 2003/06/16 14:26:01 michal Exp $
*/
public class DefaultArtifactDeployer implements ArtifactDeployer
{
/**
*
*/
public final static DateFormat SNAPSHOT_MARKER =
new SimpleDateFormat("yyyyMMdd.HHmmss");
/**
* @see ArtifactDeployer#deploy(String, String, Project)
*/
public void deploy(String file, String type, Project project)
throws MavenException
{
System.out.println("deploy");
doDeploy(file, type, project, project.getCurrentVersion());
}
/**
* @see DefaultArtifactDeployer#deploySnapshot(String, String, Project)
*/
public void deploySnapshot(String file, String type, Project project)
throws MavenException
{
doDeploy(file, type, project, MavenConstants.SNAPSHOT_SIGNIFIER);
}
/**
* @see ArtifactDeployer#install(String, String, Project)
*/
public void install(String artifact, String type, Project project)
throws MavenException
{
doInstall(artifact, type, project, project.getCurrentVersion());
}
/**
* @see ArtifactDeployer#installSnapshot(String, String, Project)
*/
public void installSnapshot(String artifact, String type, Project project)
throws MavenException
{
System.out.println("Installing snapshot of:'" + artifact + "''");
try
{
doInstall(
artifact,
type,
project,
MavenConstants.SNAPSHOT_SIGNIFIER);
}
catch (MavenException e)
{
System.out.println(e.getMessage());
}
try
{
doInstall(artifact, type, project, getSnapshotVersion());
}
catch (MavenException e)
{
System.out.println(e.getMessage());
}
}
/**
* Istall given file in repsoitory
* @param artifact the artifact file to insatall
* @param type The type of the artiafct
* @param project
* @param version String denominating the version of the artifact
* @throws MavenException
*/
private void doInstall(
String artifact,
String type,
Project project,
String version)
throws MavenException
{
String repositoryPath = getRepositoryPath(type, project, version);
try
{
String dest = getLocalRepository(project) + "/" + repositoryPath;
System.out.println(
"Copying: from '" + artifact + "' to: '" + dest + "'");
FileUtils.copyFile(new File(artifact), new File(dest));
}
catch (IOException e)
{
String msg =
"Cannot install file: '"
+ repositoryPath
+ "'. Reason: "
+ e.getMessage();
throw new MavenException(msg);
}
}
/**
* @param artifact
* @param type
* @param project
* @param snapshot
*/
private void doDeploy(
String artifact,
String type,
Project project,
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;
}
/**
*
* @param project
* @return
* @throws MavenException
*/
private String getDistributionDirectory(Project project)
throws MavenException
{
String dir = project.getDistributionDirectory();
if (dir == null || dir.length() == 0)
{
dir =
(String) project.getContext().getVariable(
"maven.deployer.remote.directory");
}
if (dir == null)
{
throw new MavenException("Distribution directory is not set");
}
return dir;
}
/**
*
* @param project
*/
private String getLocalRepository(Project project)
{
return project.getContext().getMavenRepoLocal();
}
/**
*
* @param type
* @param project
* @param snapshot
* @return
*/
private String getRepositoryPath(
String type,
Project project,
String version)
{
StringBuffer path = new StringBuffer();
path.append(project.getArtifactDirectory());
path.append("/");
path.append(type + "s");
path.append("/");
path.append(project.getArtifactId());
path.append("-");
path.append(version);
path.append(".");
path.append(extensionForType(type));
return path.toString();
}
/**
*
* @return
*/
private String getSnapshotVersion()
{
Date date = new Date();
return SNAPSHOT_MARKER.format(date);
}
/**
*
* @todo Dirty hack util Repository Layout Service is used
* @return
*/
private String extensionForType(String type)
{
if (type.equals("ejb"))
{
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/DeployBean.java
Index: DeployBean.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.MavenException;
import org.apache.maven.artifact.deployer.ArtifactDeployer;
import org.apache.maven.artifact.deployer.DefaultArtifactDeployer;
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: DeployBean.java,v 1.1 2003/06/16 14:26:01 michal Exp $
*/
public class DeployBean
{
ArtifactDeployer artifactDeployer = null;
private Project project = null;
private String artifact = null;
private String type = null;
public DeployBean()
{
artifactDeployer = new DefaultArtifactDeployer();
}
/**
* @return
*/
public String getArtifact()
{
return artifact;
}
/**
* @param artifact
*/
public void setArtifact(String artifact)
{
this.artifact = artifact;
}
/**
* @return
*/
public Project getProject()
{
return project;
}
/**
* @param project
*/
public void setProject(Project project)
{
this.project = project;
}
/**
* @return
*/
public String getType()
{
return type;
}
/**
* @param type
*/
public void setType(String type)
{
this.type = type;
}
/**
*
* @throws MavenException
*/
protected void checkAttributes() throws MavenException
{
if (project == null)
{
throw new MavenException("attribute 'project' is required");
}
if (artifact == null)
{
throw new MavenException("attribute 'artifact' is required");
}
if (type == null)
{
throw new MavenException("attribute 'type' is required");
}
}
/**
*
*/
public void deploy() throws MavenException
{
System.out.println("deploy called");
checkAttributes();
artifactDeployer.deploy(artifact, type, project);
}
/**
*
*/
public void deploySnapshot() throws MavenException
{
checkAttributes();
artifactDeployer.deploySnapshot(artifact, type, project);
}
/**
*
*/
public void install() throws MavenException
{
checkAttributes();
artifactDeployer.install(artifact, type, project);
}
/**
*
*/
public void installSnapshot() throws MavenException
{
checkAttributes();
artifactDeployer.installSnapshot(artifact, type, project);
}
}
1.1 maven/src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/ArtifactDeployer.java
Index: ArtifactDeployer.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.MavenException;
import org.apache.maven.project.Project;
/**
*
* The Bean which serves as Proxy To Hibernate API
* <br/>
*
*
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: ArtifactDeployer.java,v 1.1 2003/06/16 14:26:01 michal Exp $
*/
public interface ArtifactDeployer
{
/**
* Deploy given artifact to remote repository
* @param artifact
* @param type
* @param project
* @throws MavenException
*/
public void deploy(String artifact, String type, Project project)
throws MavenException;
/**
* Deploy given artifact as a snapshot to remote repository
* @param artifact
* @param type
* @param 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
* @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
* @throws MavenException
*/
public void installSnapshot(String artifact, String type, Project project)
throws MavenException;
}
1.1 maven/src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/deploy/SshDeployer.java
Index: SshDeployer.java
===================================================================
package org.apache.maven.artifact.deployer.deploy;
/* ====================================================================
* 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;
/**
* 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/16 14:26:01 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
{
private AuthenticationInfo authInfo = null;
/**
* @see Deployer#project
*/
public void deploy(
AuthenticationInfo authInfo,
String host,
String localArtifactPath,
String remoteArtifactPath)
{
try
{
this.authInfo = authInfo;
JSch jsch = new JSch();
Session session = jsch.getSession(host, 22);
// Look for the private key and use it if available.
File privateKey =
new File(
new File(System.getProperty("user.home"), ".ssh"),
"id_dsa");
if (privateKey.exists())
{
session.setIdentity(privateKey.getPath());
}
// username and password will be given via UserInfo interface.
UserInfo ui = new MavenUserInfo();
session.setUserInfo(ui);
session.connect();
// exec 'scp -t remoteArtifactPath' remotely
String command = "scp -t " + remoteArtifactPath;
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(localArtifactPath)).length();
command = "C0644 " + filesize + " ";
if (localArtifactPath.lastIndexOf('/') > 0)
{
command
+= localArtifactPath.substring(
localArtifactPath.lastIndexOf('/') + 1);
}
else
{
command += localArtifactPath;
}
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(localArtifactPath);
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
{
/**
* Gets the name attribute of the MavenUserInfo object
*/
public String getName()
{
return authInfo.getUsername();
}
/**
* Gets the password attribute of the MavenUserInfo object
*/
public String getPassword()
{
return authInfo.getPassword();
}
/**
* Gets the passphrase attribute of the MavenUserInfo object
*/
public String getPassphrase(String message)
{
return authInfo.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/artifact/deployer/deploy/HttpDeployer.java
Index: HttpDeployer.java
===================================================================
package org.apache.maven.artifact.deployer.deploy;
/* ====================================================================
* 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.File;
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.URI;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.methods.PutMethod;
/**
* 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/16 14:26:01 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(
AuthenticationInfo authInfo,
String host,
String localPath,
String remotePath)
{
URL url = null;
try
{
url = new URL(remotePath);
}
catch (MalformedURLException murle)
{
}
Credentials creds =
new UsernamePasswordCredentials(
authInfo.getUsername(),
authInfo.getPassphrase());
//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();
try
{
hc.setHost(new URI(url));
}
catch (URIException e)
{
throw new RuntimeException(e.toString());
}
//start a session with the webserver
client.setHostConfiguration(hc);
//create a method object
PutMethod method = new PutMethod(url.getPath());
method.setRequestBody(new File(localPath).toString());
//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/artifact/deployer/deploy/AbstractDeployer.java
Index: AbstractDeployer.java
===================================================================
package org.apache.maven.artifact.deployer.deploy;
/* ====================================================================
* 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/16 14:26:01 michal Exp $
*/
public abstract class AbstractDeployer implements Deployer
{
/**
*
*/
public abstract void deploy(
AuthenticationInfo authInfo,
String host,
String localPath,
String remotePath);
}
1.1 maven/src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/deploy/Deployer.java
Index: Deployer.java
===================================================================
package org.apache.maven.artifact.deployer.deploy;
/* ====================================================================
* 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/16 14:26:01 michal Exp $
*/
public interface Deployer
{
/**
*
* @param authInfo
* @param host
* @param localPath
* @param remotePath
*/
public void deploy(
AuthenticationInfo authInfo,
String host,
String localPath,
String remotePath);
}
1.1 maven/src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/deploy/GenericAuthenticationInfo.java
Index: GenericAuthenticationInfo.java
===================================================================
package org.apache.maven.artifact.deployer.deploy;
/* ====================================================================
* 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/>.
*
* ====================================================================
*/
/**
*
* The Bean which serves as Proxy To Hibernate API
* <br/>
*
*
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: GenericAuthenticationInfo.java,v 1.1 2003/06/16 14:26:01 michal Exp $
*/
public class GenericAuthenticationInfo implements AuthenticationInfo
{
private String username;
private String password;
private String passphrase;
private String remoteGroup;
/**
* @return
*/
public String getPassphrase()
{
return passphrase;
}
/**
* @param passphrase
*/
public void setPassphrase(String passphrase)
{
this.passphrase = passphrase;
}
/**
* @return
*/
public String getPassword()
{
return password;
}
/**
* @param password
*/
public void setPassword(String password)
{
this.password = password;
}
/**
* @return
*/
public String getUsername()
{
return username;
}
/**
* @param username
*/
public void setUsername(String username)
{
this.username = username;
}
/**
* @return
*/
public String getRemoteGroup()
{
return remoteGroup;
}
/**
* @param remoteGroup
*/
public void setRemoteGroup(String remoteGroup)
{
this.remoteGroup = remoteGroup;
}
}
1.1 maven/src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/deploy/AuthenticationInfo.java
Index: AuthenticationInfo.java
===================================================================
package org.apache.maven.artifact.deployer.deploy;
/* ====================================================================
* 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/>.
*
* ====================================================================
*/
/**
* Holder of the infomarmation which is used to authentificate user
* during deployment process.
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Revision: 1.1 $ $Date: 2003/06/16 14:26:01 $
*/
public interface AuthenticationInfo
{
/**
* @return
*/
public abstract String getPassphrase();
/**
* @param passphrase
*/
public abstract void setPassphrase(String passphrase);
/**
* @return
*/
public abstract String getPassword();
/**
* @param password
*/
public abstract void setPassword(String password);
/**
* @return
*/
public abstract String getUsername();
/**
* @param username
*/
public abstract void setUsername(String username);
/**
* @return
*/
public abstract String getRemoteGroup();
/**
* @param remoteGroup
*/
public abstract void setRemoteGroup(String remoteGroup);
}
1.1 maven/src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/deploy/FtpDeployer.java
Index: FtpDeployer.java
===================================================================
package org.apache.maven.artifact.deployer.deploy;
/* ====================================================================
* 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;
/**
* 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/16 14:26:01 michal Exp $
*
* @todo account for username and password.
*/
public class FtpDeployer extends AbstractDeployer
{
/**
* Description of the Method
*/
public void deploy(AuthenticationInfo authInfo, String host, String localPath, String remotePath)
{
String username = authInfo.getUsername();
String password = authInfo.getPassword();
FTPClient ftp = new FTPClient();
ftp.addProtocolCommandListener(
new PrintCommandListener(new PrintWriter(System.out)));
try
{
int reply;
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("FTP server refused connection.");
System.exit(1);
}
}
catch (IOException e)
{
if (ftp.isConnected())
{
try
{
ftp.disconnect();
}
catch (IOException f)
{
// do nothing
}
}
System.err.println("Could not connect to server.");
e.printStackTrace();
System.exit(1);
}
__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 = remotePath.substring(0, remotePath.lastIndexOf("/"));
String filename = remotePath.substring(remotePath.lastIndexOf("/")+1);
System.out.println("Working directory " + workingDir);
System.out.println("Filename: " + filename);
System.out.println("LocalPath: " + localPath);
ftp.makeDirectory(workingDir);
ftp.changeWorkingDirectory( workingDir);
ftp.storeFile(filename, new FileInputStream(localPath));
ftp.logout();
}
catch (FTPConnectionClosedException e)
{
System.err.println("Server closed connection.");
e.printStackTrace();
}
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/plugin-resources/templates/manifest.vm
Index: manifest.vm
===================================================================
Built-By: ${jellyContext.getVarable("user.name")}
Created-By: Apache Jakarta Maven
#if (${pom.Package})
Package: ${pom.Package}
#end
Build-Jdk: ${jellyContext.getVarable("java.version")}
#if (${pom.ArtifactId})
Extension-Name: ${pom.ArtifactId}
#end
#if (${pom.SpecificationVersion})
Specification-Version: ${pom.SpecificationVersion}
#end
#if (${pom.Organization.Name})
Specification-Vendor: ${pom.Organization.Name}
#end
#if (${pom.ShortDescription})
Specification-Title: ${pom.ShortDescription}
#end
#if (${pom.CurrentVersion})
Implementation-Version: ${pom.CurrentVersion}
#end
#if (${pom.Organization.Name})
Implementation-Vendor: ${pom.Organization.Name}
Implementation-Vendor-Id: ${pom.Organization.Name}
#end
#if(${mainclass})
Main-Class=${mainclass}
#end
#if( ${addExtensions})
#set($extensionList = "")
#foreach($artifact in $pom.Artifacts)
#set ($dep= $artifact.Dependency )
#if( $dep.Type == "jar" )
#set($extensionList = "$extensionList $artifact.Dependency.ArtifactId")
#end
#end
Extension-List: ${extensionList}
#foreach($artifact in $pom.Artifacts)
#set ($dep= $artifact.Dependency )
#if( $dep.Type == "jar" )
${dep.ArtifactId}-Extension-Name: ${dep.ArtifactId}
${dep.ArtifactId}-Implementation-Version: ${dep.Version}
#if($dep.Url)
${dep.ArtifactId}-Implementation-URL: ${dep.Url}
#else
${dep.ArtifactId}-Implementation-URL: http://www.ibiblio.org/maven/
#end
#end
#end
#end
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org