transform deployment of SNAPSHOT.

Currently, the POM and artifact are deployed separately, causing an inconsistent version to be written out.


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163684 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-03-24 08:45:37 +00:00
parent 886d787bf4
commit 3f0f786e67
17 changed files with 340 additions and 145 deletions

View File

@ -41,7 +41,6 @@ public class ArtifactConstructionSupport
return null;
}
// TODO: localRepository not used (should be used here to resolve path?
String desiredScope = Artifact.SCOPE_RUNTIME;
if ( Artifact.SCOPE_COMPILE.equals( scope ) && inheritedScope == null )
{

View File

@ -25,9 +25,11 @@ public interface ArtifactDeployer
{
String ROLE = ArtifactDeployer.class.getName();
void deploy( String basedir, Artifact artifact, ArtifactRepository deploymentRepository )
void deploy( String basedir, Artifact artifact, ArtifactRepository deploymentRepository,
ArtifactRepository localRepository )
throws ArtifactDeploymentException;
void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository )
void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository,
ArtifactRepository localRepository )
throws ArtifactDeploymentException;
}

View File

@ -20,9 +20,15 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.artifact.transform.ArtifactTransformation;
import org.apache.maven.wagon.TransferFailedException;
import java.io.File;
import java.util.Iterator;
import java.util.List;
public class DefaultArtifactDeployer
@ -34,7 +40,8 @@ public class DefaultArtifactDeployer
private List artifactTransformations;
public void deploy( String basedir, Artifact artifact, ArtifactRepository deploymentRepository )
public void deploy( String basedir, Artifact artifact, ArtifactRepository deploymentRepository,
ArtifactRepository localRepository )
throws ArtifactDeploymentException
{
File source = null;
@ -48,19 +55,43 @@ public class DefaultArtifactDeployer
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
}
deploy( source, artifact, deploymentRepository );
deploy( source, artifact, deploymentRepository, localRepository );
}
public void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository )
public void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository,
ArtifactRepository localRepository )
throws ArtifactDeploymentException
{
// TODO: perform transformations
try
{
// TODO: better to have a transform manager, or reuse the handler manager again so we don't have these requirements duplicated all over?
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
{
ArtifactTransformation transform = (ArtifactTransformation) i.next();
artifact = transform.transformForDeployment( artifact, deploymentRepository );
}
wagonManager.putArtifact( source, artifact, deploymentRepository );
// must be after the artifact is installed
for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); )
{
ArtifactMetadata metadata = (ArtifactMetadata) i.next();
metadata.storeInLocalRepository( localRepository );
// TODO: shouldn't need to calculate this
File f = new File( localRepository.getBasedir(), localRepository.pathOfMetadata( metadata ) );
wagonManager.putArtifactMetadata( f, metadata, deploymentRepository );
}
}
catch ( Exception e )
catch ( TransferFailedException e )
{
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
}
catch ( ArtifactMetadataRetrievalException e )
{
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
}
catch ( ArtifactPathFormatException e )
{
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
}

View File

@ -20,6 +20,7 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.artifact.transform.ArtifactTransformation;
@ -65,7 +66,7 @@ public class DefaultArtifactInstaller
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
{
ArtifactTransformation transform = (ArtifactTransformation) i.next();
artifact = transform.transformLocalArtifact( artifact, localRepository );
artifact = transform.transformForInstall( artifact, localRepository );
}
String localPath = localRepository.pathOf( artifact );
@ -96,5 +97,9 @@ public class DefaultArtifactInstaller
{
throw new ArtifactInstallationException( "Error installing artifact: ", e );
}
catch ( ArtifactMetadataRetrievalException e )
{
throw new ArtifactInstallationException( "Error installing artifact: ", e );
}
}
}

View File

@ -77,25 +77,94 @@ public class DefaultWagonManager
}
// TODO: don't throw exception
public void releaseWagon( Wagon wagon )
private void releaseWagon( Wagon wagon )
throws Exception
{
container.release( wagon );
}
// TODO: don't throw exception
public void putArtifact( File source, Artifact artifact, ArtifactRepository repository )
throws Exception
throws TransferFailedException
{
Wagon wagon = getWagon( repository.getProtocol() );
try
{
putRemoteFile( repository, source, repository.pathOf( artifact ) );
}
catch ( ArtifactPathFormatException e )
{
throw new TransferFailedException( "Path of artifact could not be determined: ", e );
}
}
wagon.connect( repository, getProxy( repository.getProtocol() ) );
public void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository )
throws TransferFailedException
{
try
{
putRemoteFile( repository, source, repository.pathOfMetadata( artifactMetadata ) );
}
catch ( ArtifactPathFormatException e )
{
throw new TransferFailedException( "Path of artifact could not be determined: ", e );
}
}
wagon.put( source, repository.pathOf( artifact ) );
private void putRemoteFile( ArtifactRepository repository, File source, String remotePath )
throws TransferFailedException
{
Wagon wagon = null;
try
{
wagon = getWagon( repository.getProtocol() );
}
catch ( UnsupportedProtocolException e )
{
throw new TransferFailedException( "Unsupported Protocol: ", e );
}
wagon.disconnect();
// TODO: probably don't want this on metadata...
// TODO: not working well on upload, commented out for now
// if ( downloadMonitor != null )
// {
// wagon.addTransferListener( downloadMonitor );
// }
releaseWagon( wagon );
try
{
wagon.connect( repository, getProxy( repository.getProtocol() ) );
wagon.put( source, remotePath );
// TODO [BP]: put all disconnects in finally
wagon.disconnect();
}
catch ( ConnectionException e )
{
throw new TransferFailedException( "Connection failed: ", e );
}
catch ( AuthenticationException e )
{
throw new TransferFailedException( "Authentication failed: ", e );
}
catch ( AuthorizationException e )
{
throw new TransferFailedException( "Authorization failed: ", e );
}
catch ( ResourceDoesNotExistException e )
{
throw new TransferFailedException( "Resource to deploy not found: ", e );
}
finally
{
try
{
releaseWagon( wagon );
}
catch ( Exception e )
{
throw new TransferFailedException( "Unable to release wagon", e );
}
}
}
public void getArtifact( Artifact artifact, List remoteRepositories, File destination )
@ -139,16 +208,13 @@ public class DefaultWagonManager
}
}
public void getMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository,
ArtifactRepository localRepository )
public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination )
throws TransferFailedException, ResourceDoesNotExistException
{
String remotePath;
String localPath;
try
{
remotePath = remoteRepository.pathOfMetadata( metadata );
localPath = localRepository.pathOfMetadata( metadata );
}
catch ( ArtifactPathFormatException e )
{
@ -156,8 +222,7 @@ public class DefaultWagonManager
throw new TransferFailedException( "Failed to determine path for artifact", e );
}
File metadataFile = new File( localRepository.getBasedir(), localPath );
getRemoteFile( remoteRepository, metadataFile, remotePath );
getRemoteFile( remoteRepository, destination, remotePath );
}
private void getRemoteFile( ArtifactRepository repository, File destination, String remotePath )
@ -184,6 +249,7 @@ public class DefaultWagonManager
//wagon.addTransferListener( md5SumObserver );
// TODO: probably don't want this on metadata...
if ( downloadMonitor != null )
{
wagon.addTransferListener( downloadMonitor );
@ -231,6 +297,11 @@ public class DefaultWagonManager
}
}
if ( !temp.exists() )
{
throw new TransferFailedException( "Downloaded file does not exist: " + temp );
}
// The temporary file is named destination + ".tmp" and is done this
// way to ensure
// that the temporary file is in the same file system as the

View File

@ -39,19 +39,16 @@ public interface WagonManager
Wagon getWagon( String protocol )
throws UnsupportedProtocolException;
// TODO: don't throw exception
void releaseWagon( Wagon wagon )
throws Exception;
void getArtifact( Artifact artifact, List remoteRepositories, File destination )
throws TransferFailedException;
// TODO: don't throw exception
void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository )
throws Exception;
throws TransferFailedException;
void getMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository,
ArtifactRepository localRepository )
public void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository )
throws TransferFailedException;
public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination )
throws TransferFailedException, ResourceDoesNotExistException;
void setProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts );

View File

@ -17,19 +17,17 @@ package org.apache.maven.artifact.metadata;
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import java.io.IOException;
/**
* Contains metadata about an artifact, and methods to retrieve/store it from an artifact repository.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
* @todo naming is too close to ArtifactMetadataSource which refers to a POM. A POM is sometimes an artifact itself,
* so that naming may no longer be appropriate.
* @todo merge with artifactmetadatasource
* @todo retrieval exception not appropriate for store
* @todo not happy about the store/retrieve methods - they use "this"
*/
public interface ArtifactMetadata
{
@ -39,16 +37,16 @@ public interface ArtifactMetadata
* @param localRepository the local repository
*/
void storeInLocalRepository( ArtifactRepository localRepository )
throws IOException, ArtifactPathFormatException;
throws ArtifactMetadataRetrievalException;
/**
* Retrieve the metadata from the remote repository into the local repository.
*
* @param remoteRepository the remote repository
* @param localRepository the local repository
* @param wagonManager the wagon manager to use to retrieve the metadata
*/
void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, ArtifactRepository localRepository )
throws IOException, ArtifactResolutionException;
public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, WagonManager wagonManager )
throws ArtifactMetadataRetrievalException;
/**
* Get the associated artifact.

View File

@ -17,11 +17,15 @@ package org.apache.maven.artifact.metadata;
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@ -39,7 +43,7 @@ public class SnapshotArtifactMetadata
{
private String timestamp = null;
private int buildNumber = 1;
private int buildNumber = 0;
private static final String SNAPSHOT_VERSION_LOCAL_FILE = "version-local.txt";
@ -59,40 +63,89 @@ public class SnapshotArtifactMetadata
return new SnapshotArtifactMetadata( artifact, SNAPSHOT_VERSION_LOCAL_FILE );
}
public static ArtifactMetadata createRemoteSnapshotMetadata( Artifact artifact )
public static SnapshotArtifactMetadata createRemoteSnapshotMetadata( Artifact artifact )
{
return new SnapshotArtifactMetadata( artifact, SNAPSHOT_VERSION_FILE );
}
public void storeInLocalRepository( ArtifactRepository localRepository )
throws IOException, ArtifactPathFormatException
throws ArtifactMetadataRetrievalException
{
FileUtils.fileWrite( localRepository.getBasedir() + "/" + localRepository.pathOfMetadata( this ),
getTimestamp() + "-" + buildNumber );
try
{
if ( timestamp == null )
{
timestamp = getUtcDateFormatter().format( new Date() );
}
String path = new File( localRepository.getBasedir(), localRepository.pathOfMetadata( this ) ).getPath();
FileUtils.fileWrite( path, getVersion() );
}
catch ( IOException e )
{
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
}
catch ( ArtifactPathFormatException e )
{
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
}
}
public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, ArtifactRepository localRepository )
throws IOException, ArtifactResolutionException
public String getVersion()
{
/*
// TODO: this is getting the artifact - needs to get the version.txt
resolver.resolve( artifact, Collections.singletonList( remoteRepository ), localRepository );
String version = artifact.getVersion();
if ( version != null )
{
version = StringUtils.replace( version, "SNAPSHOT", timestamp );
}
else
{
version = timestamp;
}
return version + "-" + buildNumber;
}
String version = FileUtils.fileRead( artifact.getPath() );
public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, WagonManager wagonManager )
throws ArtifactMetadataRetrievalException
{
try
{
File destination = File.createTempFile( "maven-artifact", null );
destination.deleteOnExit();
int index = UTC_TIMESTAMP_PATTERN.length();
timestamp = version.substring( 0, index );
try
{
wagonManager.getArtifactMetadata( this, remoteRepository, destination );
}
catch ( ResourceDoesNotExistException e )
{
// this just means that there is no snapshot version file, so we keep timestamp = null, build = 0
return;
}
buildNumber = Integer.valueOf( version.substring( index + 1 ) ).intValue();
*/
String version = FileUtils.fileRead( destination );
int index = version.lastIndexOf( "-" );
timestamp = version.substring( 0, index );
buildNumber = Integer.valueOf( version.substring( index + 1 ) ).intValue();
index = version.indexOf( "-" );
if ( index >= 0 )
{
// ignore starting version part, will be prepended later
timestamp = timestamp.substring( index + 1 );
}
}
catch ( TransferFailedException e )
{
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
}
catch ( IOException e )
{
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
}
}
public String getTimestamp()
{
if ( timestamp == null )
{
timestamp = getUtcDateFormatter().format( new Date() );
}
return timestamp;
}
@ -102,4 +155,10 @@ public class SnapshotArtifactMetadata
utcDateFormatter.setTimeZone( UTC_TIME_ZONE );
return utcDateFormatter;
}
public void update()
{
this.buildNumber++;
timestamp = getUtcDateFormatter().format( new Date() );
}
}

View File

@ -30,7 +30,7 @@ public class LegacyRepositoryLayout
protected String metadataLayoutPattern()
{
return "${groupPath}/${directory}/${artifactId}-${version}-${metadataFilename}";
return "${groupPath}/poms/${artifactId}-${version}-${metadataFilename}";
}
protected String groupIdAsPath( String groupId )

View File

@ -81,7 +81,7 @@ public class DefaultArtifactResolver
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
{
ArtifactTransformation transform = (ArtifactTransformation) i.next();
artifact = transform.transformLocalArtifact( artifact, localRepository );
artifact = transform.transformForResolve( artifact );
}
String localPath;
@ -182,19 +182,12 @@ public class DefaultArtifactResolver
throw new ArtifactResolutionException( "Error transitively resolving artifacts: ", e );
}
// TODO: this is unclean, but necessary as long as resolve may return a different artifact
Map collectedArtifacts = artifactResolutionResult.getArtifacts();
Map resolvedArtifacts = new HashMap( collectedArtifacts.size() );
for ( Iterator i = collectedArtifacts.keySet().iterator(); i.hasNext(); )
for ( Iterator i = artifactResolutionResult.getArtifacts().values().iterator(); i.hasNext(); )
{
Object key = i.next();
resolvedArtifacts.put( key, resolve( (Artifact) collectedArtifacts.get( key ), remoteRepositories,
localRepository ) );
// TODO: resolve may modify artifacts, do we need to get the new list?
resolve( (Artifact) i.next(), remoteRepositories, localRepository );
}
collectedArtifacts.clear();
collectedArtifacts.putAll( resolvedArtifacts );
return artifactResolutionResult;
}

View File

@ -17,6 +17,7 @@ package org.apache.maven.artifact.transform;
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
/**
@ -28,6 +29,15 @@ public interface ArtifactTransformation
{
static String ROLE = ArtifactTransformation.class.getName();
/**
* Take in a artifact and return the transformed artifact for locating in the remote repository. If no
* transformation has occured the original artifact is returned.
*
* @param artifact Artifact to be transformed.
* @return The transformed Artifact
*/
Artifact transformForResolve( Artifact artifact );
/**
* Take in a artifact and return the transformed artifact for locating in the local repository. If no
* transformation has occured the original artifact is returned.
@ -36,15 +46,16 @@ public interface ArtifactTransformation
* @param localRepository the local repository it will be stored in
* @return The transformed Artifact
*/
Artifact transformLocalArtifact( Artifact artifact, ArtifactRepository localRepository );
Artifact transformForInstall( Artifact artifact, ArtifactRepository localRepository );
/**
* Take in a artifact and return the transformed artifact for locating in the remote repository. If no
* Take in a artifact and return the transformed artifact for distributing toa remote repository. If no
* transformation has occured the original artifact is returned.
*
* @param artifact Artifact to be transformed.
* @param artifact Artifact to be transformed.
* @param remoteRepository the repository to deploy to
* @return The transformed Artifact
* @todo finish doco
*/
Artifact transformRemoteArtifact( Artifact artifact, ArtifactRepository remoteRepository );
Artifact transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException;
}

View File

@ -17,7 +17,10 @@ package org.apache.maven.artifact.transform;
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
@ -30,6 +33,8 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
public class SnapshotTransformation
implements ArtifactTransformation
{
private WagonManager wagonManager;
/* TODO: use and remove
public Artifact transform( Artifact artifact, ArtifactRepository localRepository, List repositories,
Map parameters )
@ -185,9 +190,15 @@ public class SnapshotTransformation
return retValue;
}
*/
public Artifact transformLocalArtifact( Artifact artifact, ArtifactRepository localRepository )
public Artifact transformForResolve( Artifact artifact )
{
if ( shouldProcessArtifact( artifact ) )
// TODO: implement
return artifact;
}
public Artifact transformForInstall( Artifact artifact, ArtifactRepository localRepository )
{
if ( isSnapshot( artifact ) )
{
// only store the version-local.txt file for POMs as every file has an associated POM
ArtifactMetadata metadata = SnapshotArtifactMetadata.createLocalSnapshotMetadata( artifact );
@ -196,23 +207,24 @@ public class SnapshotTransformation
return artifact;
}
public Artifact transformRemoteArtifact( Artifact artifact, ArtifactRepository remoteRepository )
public Artifact transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException
{
if ( shouldProcessArtifact( artifact ) )
if ( isSnapshot( artifact ) )
{
ArtifactMetadata metadata = SnapshotArtifactMetadata.createRemoteSnapshotMetadata( artifact );
// wagonManager.getMetadata( metadata, remoteRepository, localRepository );
SnapshotArtifactMetadata metadata = SnapshotArtifactMetadata.createRemoteSnapshotMetadata( artifact );
metadata.retrieveFromRemoteRepository( remoteRepository, wagonManager );
metadata.update();
// TODO: implement
// TODO: note, we could currently transform this in place, as it is only used through the deploy mojo,
// which creates the artifact and then disposes of it
artifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), metadata.getVersion(),
artifact.getScope(), artifact.getType(), artifact.getClassifier() );
artifact.addMetadata( metadata );
}
return artifact;
}
private static boolean shouldProcessArtifact( Artifact artifact )
{
return isSnapshot( artifact ) && "pom".equals( artifact.getType() );
}
private static boolean isSnapshot( Artifact artifact )
{
return artifact.getVersion().endsWith( "SNAPSHOT" );

View File

@ -1,5 +1,20 @@
<component-set>
<components>
<!--
|
| WagonManager
|
-->
<component>
<role>org.apache.maven.artifact.manager.WagonManager</role>
<implementation>org.apache.maven.artifact.manager.DefaultWagonManager</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component>
<!--
|
| Transformations
@ -8,6 +23,11 @@
<component>
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
<implementation>org.apache.maven.artifact.transform.SnapshotTransformation</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement>
</requirements>
</component>
<!--
@ -32,21 +52,6 @@
</requirements>
</component>
<!--
|
| WagonManager
|
-->
<component>
<role>org.apache.maven.artifact.manager.WagonManager</role>
<implementation>org.apache.maven.artifact.manager.DefaultWagonManager</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component>
<!--
|
| ArtifactInstaller

View File

@ -50,7 +50,7 @@ public class ArtifactDeployerTest
Artifact artifact = createArtifact( "artifact", "1.0" );
artifactDeployer.deploy( artifactBasedir, artifact, remoteRepository() );
artifactDeployer.deploy( artifactBasedir, artifact, remoteRepository(), localRepository() );
assertRemoteArtifactPresent( artifact );
}

View File

@ -35,7 +35,11 @@ public class ConsoleDownloadMonitor
public void transferInitiated( TransferEvent transferEvent )
{
System.out.println( "Downloading: " + transferEvent.getResource().getName() );
String message = transferEvent.getRequestType() == TransferEvent.REQUEST_PUT ? "Uploading" : "Downloading";
// TODO: can't use getLogger() because this isn't currently instantiated as a component
System.out.println( message + ": " + transferEvent.getResource().getName() );
complete = 0;
}
@ -60,12 +64,14 @@ public class ConsoleDownloadMonitor
public void transferError( TransferEvent transferEvent )
{
getLogger().error( transferEvent.getException().getMessage() );
// TODO: can't use getLogger() because this isn't currently instantiated as a component
transferEvent.getException().printStackTrace();
}
public void debug( String message )
{
getLogger().debug( message );
// TODO: can't use getLogger() because this isn't currently instantiated as a component
// getLogger().debug( message );
}
}

View File

@ -46,6 +46,13 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>wagon-file</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>wagon-ssh</artifactId>

View File

@ -28,36 +28,34 @@ import org.apache.maven.project.MavenProject;
import java.io.File;
/**
* @goal deploy
*
* @description deploys an artifact to remote repository
*
* @parameter
* name="project"
* type="org.apache.maven.project.MavenProject"
* required="true"
* validator=""
* expression="#project"
* description=""
*
* @parameter
* name="deployer"
* type="org.apache.maven.artifact.deployer.ArtifactDeployer"
* required="true"
* validator=""
* expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer"
* description=""
*
* @parameter
* name="deploymentRepository"
* type="org.apache.maven.artifact.repository.ArtifactRepository"
* required="true"
* validator=""
* expression="#project.distributionManagementArtifactRepository"
* description=""
*
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id$
* @goal deploy
* @description deploys an artifact to remote repository
* @parameter name="project"
* type="org.apache.maven.project.MavenProject"
* required="true"
* validator=""
* expression="#project"
* description=""
* @parameter name="deployer"
* type="org.apache.maven.artifact.deployer.ArtifactDeployer"
* required="true"
* validator=""
* expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer"
* description=""
* @parameter name="deploymentRepository"
* type="org.apache.maven.artifact.repository.ArtifactRepository"
* required="true"
* validator=""
* expression="#project.distributionManagementArtifactRepository"
* description=""
* @parameter name="localRepository"
* type="org.apache.maven.artifact.repository.ArtifactRepository"
* required="true"
* validator=""
* expression="#localRepository"
* description=""
*/
public class DeployMojo
extends AbstractPlugin
@ -68,21 +66,22 @@ public class DeployMojo
private ArtifactRepository deploymentRepository;
private ArtifactRepository localRepository;
public void execute()
throws PluginExecutionException
{
if ( deploymentRepository == null )
{
String msg = "Deployment failed: repository element was not specified in the pom inside"
+ " distributionManagement element";
String msg = "Deployment failed: repository element was not specified in the pom inside" +
" distributionManagement element";
throw new PluginExecutionException( msg );
}
if ( deploymentRepository.getAuthenticationInfo() == null )
{
getLog().warn(
"Deployment repository {id: \'" + deploymentRepository.getId()
+ "\'} has no associated authentication info!" );
getLog().warn( "Deployment repository {id: \'" + deploymentRepository.getId() +
"\'} has no associated authentication info!" );
}
// Deploy the POM
@ -93,7 +92,7 @@ public class DeployMojo
try
{
deployer.deploy( pom, pomArtifact, deploymentRepository );
deployer.deploy( pom, pomArtifact, deploymentRepository, localRepository );
//Deploy artifact
if ( !"pom".equals( project.getPackaging() ) )
@ -101,7 +100,7 @@ public class DeployMojo
Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(),
project.getVersion(), project.getPackaging() );
deployer.deploy( project.getBuild().getDirectory(), artifact, deploymentRepository );
deployer.deploy( project.getBuild().getDirectory(), artifact, deploymentRepository, localRepository );
}
}
catch ( ArtifactDeploymentException e )