* fold deploy plugin into artifact plugin - make it easier to manage migration
* add legacy property to force use of deploy plugin via artifact tags * use deploy plugin if artifact is not configured * clean up exception handling in artifact * utilise deploy properties in artifact plugin if it is not configured git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115480 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
1 parent
26e6e261a6
commit
fd0192ae48
23 files changed
+378
-523
No files matched your search
@@ -28,6 +28,8 @@ import java.util.TimeZone;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.maven.MavenConstants;
|
||||
import org.apache.maven.MavenException;
|
||||
import org.apache.maven.deploy.DeployTool;
|
||||
@@ -41,7 +43,7 @@ import org.apache.maven.util.MD5Sum;
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: DefaultArtifactDeployer.java,v 1.18 2004/05/10 23:36:34 brett Exp $
|
||||
* @version $Id: DefaultArtifactDeployer.java,v 1.19 2004/06/14 13:36:47 brett Exp $
|
||||
*/
|
||||
public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
{
|
||||
@@ -77,6 +79,8 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
SNAPSHOT_SIGNATURE_FMT.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
}
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(DefaultArtifactDeployer.class);
|
||||
|
||||
/**
|
||||
* @see ArtifactDeployer#deploy(String, String, Project)
|
||||
*
|
||||
@@ -279,6 +283,45 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
}
|
||||
}
|
||||
|
||||
private String findSshIdentity() {
|
||||
String key = findSshIdentity( System.getProperty( "user.home" ) );
|
||||
if ( key != null ) {
|
||||
return key;
|
||||
}
|
||||
if ( System.getProperty( "user.home" ).equals( System.getProperty( "user.home.env" ) ) == false ) {
|
||||
key = findSshIdentity( System.getProperty( "user.home.env" ) );
|
||||
if ( key != null ) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
LOG.warn( "Unable to locate identity id_rsa, id_dsa or identity - set maven.repo.default.privatekey" );
|
||||
return null;
|
||||
}
|
||||
|
||||
private String findSshIdentity( String home ) {
|
||||
if ( home == null ) {
|
||||
return null;
|
||||
}
|
||||
File sshHome = new File( home, ".ssh" );
|
||||
LOG.debug( "Looking for SSH keys in " + sshHome );
|
||||
File key = new File( sshHome, "id_dsa" );
|
||||
if ( key.exists() ) {
|
||||
LOG.debug( "found " + key );
|
||||
return key.getAbsolutePath();
|
||||
}
|
||||
key = new File( sshHome, "id_rsa" );
|
||||
if ( key.exists() ) {
|
||||
LOG.debug( "found " + key );
|
||||
return key.getAbsolutePath();
|
||||
}
|
||||
key = new File( sshHome, "identity" );
|
||||
if ( key.exists() ) {
|
||||
LOG.debug( "found " + key );
|
||||
return key.getAbsolutePath();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param artifact
|
||||
* @param type
|
||||
@@ -296,15 +339,29 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
String repoStr =
|
||||
(String) project.getContext().getVariable("maven.repo.list");
|
||||
|
||||
if (repoStr == null || repoStr.length() == 0)
|
||||
if (repoStr == null || repoStr.trim().length() == 0)
|
||||
{
|
||||
System.out.println("No remote repository was defined.");
|
||||
return;
|
||||
String central = (String) project.getContext().getVariable("maven.repo.central");
|
||||
if (central != null && central.trim().length() > 0) {
|
||||
repoStr = "default";
|
||||
project.getContext().setVariable("maven.repo.default", "scp://" + central);
|
||||
if ( project.getContext().getVariable("maven.repo.default.privatekey") == null ) {
|
||||
project.getContext().setVariable("maven.repo.default.privatekey", findSshIdentity());
|
||||
}
|
||||
if ( project.getContext().getVariable("maven.repo.default.passphrase") == null ) {
|
||||
LOG.warn( "WARNING: assuming empty passphrase. Specify maven.repo.default.passphrase if needed" );
|
||||
project.getContext().setVariable("maven.repo.default.passphrase", "");
|
||||
}
|
||||
project.getContext().setVariable("maven.repo.default.directory", project.getContext().getVariable("maven.repo.central.directory"));
|
||||
project.getContext().setVariable("maven.repo.default.username", project.getContext().getVariable("maven.username"));
|
||||
project.getContext().setVariable("maven.repo.default.group", project.getContext().getVariable("maven.remote.group"));
|
||||
}
|
||||
}
|
||||
|
||||
String[] repos = StringUtils.split(repoStr, ",");
|
||||
|
||||
System.out.println(
|
||||
"Will deploy to " + repos.length + " repository(ies): " + repoStr);
|
||||
System.out.println( "Will deploy to " + repos.length + " repository(ies): " + repoStr);
|
||||
boolean success = false;
|
||||
for (int i = 0; i < repos.length; i++)
|
||||
{
|
||||
|
||||
@@ -317,6 +374,7 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
RepositoryInfoBuilder.getRepositoryInfo(project, repo);
|
||||
|
||||
deployTool.deploy(repoInfo, srcFiles, destFiles);
|
||||
success = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -325,13 +383,16 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
+ repoInfo.getRepositoryAlias()
|
||||
+ " Reason: "
|
||||
+ e.getMessage();
|
||||
System.out.print(msg);
|
||||
LOG.warn(msg);
|
||||
LOG.debug(e);
|
||||
// deploy to next repository
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
if ( !success ) {
|
||||
throw new MavenException("Unable to deploy to any repositories");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.apache.maven.deploy.exceptions.TransferFailedException;
|
||||
* file system.
|
||||
*
|
||||
* @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: FileDeployer.java,v 1.13 2004/05/02 15:04:34 vmassol Exp $
|
||||
* @version $Id: FileDeployer.java,v 1.14 2004/06/14 13:36:48 brett Exp $
|
||||
*/
|
||||
public class FileDeployer extends AbstractDeployer
|
||||
{
|
||||
@@ -79,7 +79,7 @@ public class FileDeployer extends AbstractDeployer
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new TransferFailedException(
|
||||
"Cannot copy file: " + e.getMessage());
|
||||
"Cannot copy file: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ import org.apache.maven.deploy.exceptions.TransferFailedException;
|
||||
*
|
||||
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
|
||||
* @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: FtpDeployer.java,v 1.9 2004/05/02 15:04:34 vmassol Exp $
|
||||
* @version $Id: FtpDeployer.java,v 1.10 2004/06/14 13:36:48 brett Exp $
|
||||
*
|
||||
* @todo review exception handling
|
||||
*
|
||||
@@ -108,7 +108,7 @@ public class FtpDeployer extends AbstractDeployer
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
throw new AuthenticationException("Could not connect to server.");
|
||||
throw new AuthenticationException("Could not connect to server.",e);
|
||||
}
|
||||
|
||||
try
|
||||
@@ -130,7 +130,7 @@ public class FtpDeployer extends AbstractDeployer
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new AuthenticationException("Cannot login to remote system");
|
||||
throw new AuthenticationException("Cannot login to remote system",e);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -179,8 +179,7 @@ public class FtpDeployer extends AbstractDeployer
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw new TransferFailedException(e.getMessage());
|
||||
throw new TransferFailedException(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ import com.jcraft.jsch.UserInfo;
|
||||
* and if that doesn't work then we fall back
|
||||
* to using the login and password
|
||||
*
|
||||
* @version $Id: GenericSshDeployer.java,v 1.8 2004/03/02 14:59:31 evenisse Exp $
|
||||
* @version $Id: GenericSshDeployer.java,v 1.9 2004/06/14 13:36:48 brett 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
|
||||
@@ -167,7 +167,6 @@ public abstract class GenericSshDeployer extends AbstractDeployer
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw new AuthenticationException(
|
||||
"Cannot connect. Reason: " + e.getMessage(),
|
||||
e);
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.jcraft.jsch.SftpProgressMonitor;
|
||||
* An SSH2/SFTP deployer
|
||||
*
|
||||
* @author Michal Maczka
|
||||
* @version $Revision: 1.9 $ $Date: 2004/03/02 14:59:31 $
|
||||
* @version $Revision: 1.10 $ $Date: 2004/06/14 13:36:48 $
|
||||
*/
|
||||
public class SFtpDeployer extends GenericSshDeployer
|
||||
{
|
||||
@@ -78,7 +78,7 @@ public class SFtpDeployer extends GenericSshDeployer
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AuthenticationException(e.getMessage());
|
||||
throw new AuthenticationException(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import java.util.List;
|
||||
* An SSH2/SCP deployer
|
||||
*
|
||||
* @author Michal Maczka
|
||||
* @version $Revision: 1.9 $ $Date: 2004/05/12 12:33:55 $
|
||||
* @version $Revision: 1.10 $ $Date: 2004/06/14 13:36:48 $
|
||||
*/
|
||||
public class ScpDeployer extends GenericSshDeployer
|
||||
{
|
||||
@@ -180,7 +180,7 @@ public class ScpDeployer extends GenericSshDeployer
|
||||
}
|
||||
}
|
||||
|
||||
throw new TransferFailedException("Cannot create ZIP file");
|
||||
throw new TransferFailedException("Cannot create ZIP file",e);
|
||||
}
|
||||
|
||||
try
|
||||
@@ -264,7 +264,7 @@ public class ScpDeployer extends GenericSshDeployer
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new TransferFailedException(
|
||||
"Cannot execute remote command: " + command);
|
||||
"Cannot execute remote command: " + command,e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
*.log
|
||||
@@ -0,0 +1,65 @@
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<project xmlns:j="jelly:core"
|
||||
xmlns:u="jelly:util"
|
||||
xmlns:deploy="deploy">
|
||||
|
||||
<goal name="testPlugin" prereqs="clean,test-deploy">
|
||||
<attainGoal name="clean"/>
|
||||
</goal>
|
||||
|
||||
<goal name="test-deploy">
|
||||
<deploy:copy-deps
|
||||
todir="${maven.build.dir}"
|
||||
excludes="commons-logging" />
|
||||
|
||||
<!-- check that an exclude with just id works -->
|
||||
<j:set var="unExpectedFile"
|
||||
value="${maven.build.dir}/commons-logging-1.0.3.jar"/>
|
||||
<u:file var="file" name="${unExpectedFile}" />
|
||||
<j:if test="${(file.exists())}">
|
||||
<fail>${unExpectedFile} should not have been copied</fail>
|
||||
</j:if>
|
||||
<j:set var="expectedFile"
|
||||
value="${maven.build.dir}/commons-lang-2.0.jar"/>
|
||||
<u:file var="file" name="${expectedFile}" />
|
||||
<j:if test="${!(file.exists())}">
|
||||
<fail>${expectedFile} should have been copied</fail>
|
||||
</j:if>
|
||||
|
||||
<attainGoal name="clean"/>
|
||||
|
||||
<!-- check one with groupId:artifactId works -->
|
||||
<deploy:copy-deps
|
||||
todir="${maven.build.dir}"
|
||||
excludes="commons-lang:commons-lang" />
|
||||
<j:set var="unExpectedFile"
|
||||
value="${maven.build.dir}/commons-lang-2.0.jar"/>
|
||||
<u:file var="file" name="${unExpectedFile}" />
|
||||
<j:if test="${(file.exists())}">
|
||||
<fail>${unExpectedFile} should not have been copied</fail>
|
||||
</j:if>
|
||||
<j:set var="expectedFile"
|
||||
value="${maven.build.dir}/commons-logging-1.0.3.jar"/>
|
||||
<u:file var="file" name="${expectedFile}" />
|
||||
<j:if test="${!(file.exists())}">
|
||||
<fail>${expectedFile} should have been copied</fail>
|
||||
</j:if>
|
||||
|
||||
</goal>
|
||||
</project>
|
||||
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
|
||||
<project>
|
||||
<pomVersion>3</pomVersion>
|
||||
<name>Test project for Maven Deploy Plugin</name>
|
||||
<id>test-maven-deploy-plugin</id>
|
||||
<currentVersion>1.0-SNAPSHOT</currentVersion>
|
||||
<organization>
|
||||
<name>Nettec</name>
|
||||
<url>http://www.nettec.net</url>
|
||||
</organization>
|
||||
<inceptionYear>2002</inceptionYear>
|
||||
<package>net.nettec.marsh.begin</package>
|
||||
<shortDescription>Marsh Begin TTS Maven</shortDescription>
|
||||
<description>TTS Begin</description>
|
||||
<url/>
|
||||
<issueTrackingUrl>http://bugzilla</issueTrackingUrl>
|
||||
<siteAddress>www.nettec.net</siteAddress>
|
||||
<siteDirectory/>
|
||||
<distributionDirectory/>
|
||||
<repository>
|
||||
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven</connection>
|
||||
<url>http://cvs.apache.org/viewcvs/maven/</url>
|
||||
</repository>
|
||||
<versions/>
|
||||
<mailingLists/>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Nathan Coast</name>
|
||||
<id>nathanc</id>
|
||||
<email>nathan.coast@blueyonder.co.uk</email>
|
||||
<organization>Shadow Solutions</organization>
|
||||
<role>Java Developer</role>
|
||||
</developer>
|
||||
</developers>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<url>http://jakarta.apache.org/commons/logging.html</url>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.0</version>
|
||||
<url>http://jakarta.apache.org/commons/logging.html</url>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<nagEmailAddress>nathan.coast@nettec.net</nagEmailAddress>
|
||||
</build>
|
||||
</project>
|
||||
Reference in new issue
Block a user