mirror of https://github.com/apache/maven.git
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:
parent
886d787bf4
commit
3f0f786e67
|
@ -41,7 +41,6 @@ public class ArtifactConstructionSupport
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: localRepository not used (should be used here to resolve path?
|
|
||||||
String desiredScope = Artifact.SCOPE_RUNTIME;
|
String desiredScope = Artifact.SCOPE_RUNTIME;
|
||||||
if ( Artifact.SCOPE_COMPILE.equals( scope ) && inheritedScope == null )
|
if ( Artifact.SCOPE_COMPILE.equals( scope ) && inheritedScope == null )
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,9 +25,11 @@ public interface ArtifactDeployer
|
||||||
{
|
{
|
||||||
String ROLE = ArtifactDeployer.class.getName();
|
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;
|
throws ArtifactDeploymentException;
|
||||||
|
|
||||||
void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository )
|
void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository,
|
||||||
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactDeploymentException;
|
throws ArtifactDeploymentException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.ArtifactHandlerManager;
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
|
||||||
import org.apache.maven.artifact.manager.WagonManager;
|
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.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.io.File;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DefaultArtifactDeployer
|
public class DefaultArtifactDeployer
|
||||||
|
@ -34,7 +40,8 @@ public class DefaultArtifactDeployer
|
||||||
|
|
||||||
private List artifactTransformations;
|
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
|
throws ArtifactDeploymentException
|
||||||
{
|
{
|
||||||
File source = null;
|
File source = null;
|
||||||
|
@ -48,19 +55,43 @@ public class DefaultArtifactDeployer
|
||||||
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
|
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
|
throws ArtifactDeploymentException
|
||||||
{
|
{
|
||||||
// TODO: perform transformations
|
|
||||||
|
|
||||||
try
|
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 );
|
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 );
|
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.ArtifactHandlerManager;
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
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.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||||
import org.apache.maven.artifact.transform.ArtifactTransformation;
|
import org.apache.maven.artifact.transform.ArtifactTransformation;
|
||||||
|
@ -65,7 +66,7 @@ public class DefaultArtifactInstaller
|
||||||
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
|
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
ArtifactTransformation transform = (ArtifactTransformation) i.next();
|
ArtifactTransformation transform = (ArtifactTransformation) i.next();
|
||||||
artifact = transform.transformLocalArtifact( artifact, localRepository );
|
artifact = transform.transformForInstall( artifact, localRepository );
|
||||||
}
|
}
|
||||||
|
|
||||||
String localPath = localRepository.pathOf( artifact );
|
String localPath = localRepository.pathOf( artifact );
|
||||||
|
@ -96,5 +97,9 @@ public class DefaultArtifactInstaller
|
||||||
{
|
{
|
||||||
throw new ArtifactInstallationException( "Error installing artifact: ", e );
|
throw new ArtifactInstallationException( "Error installing artifact: ", e );
|
||||||
}
|
}
|
||||||
|
catch ( ArtifactMetadataRetrievalException e )
|
||||||
|
{
|
||||||
|
throw new ArtifactInstallationException( "Error installing artifact: ", e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -77,25 +77,94 @@ public class DefaultWagonManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: don't throw exception
|
// TODO: don't throw exception
|
||||||
public void releaseWagon( Wagon wagon )
|
private void releaseWagon( Wagon wagon )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
container.release( wagon );
|
container.release( wagon );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: don't throw exception
|
|
||||||
public void putArtifact( File source, Artifact artifact, ArtifactRepository repository )
|
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 )
|
public void getArtifact( Artifact artifact, List remoteRepositories, File destination )
|
||||||
|
@ -139,16 +208,13 @@ public class DefaultWagonManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository,
|
public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination )
|
||||||
ArtifactRepository localRepository )
|
|
||||||
throws TransferFailedException, ResourceDoesNotExistException
|
throws TransferFailedException, ResourceDoesNotExistException
|
||||||
{
|
{
|
||||||
String remotePath;
|
String remotePath;
|
||||||
String localPath;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
remotePath = remoteRepository.pathOfMetadata( metadata );
|
remotePath = remoteRepository.pathOfMetadata( metadata );
|
||||||
localPath = localRepository.pathOfMetadata( metadata );
|
|
||||||
}
|
}
|
||||||
catch ( ArtifactPathFormatException e )
|
catch ( ArtifactPathFormatException e )
|
||||||
{
|
{
|
||||||
|
@ -156,8 +222,7 @@ public class DefaultWagonManager
|
||||||
throw new TransferFailedException( "Failed to determine path for artifact", e );
|
throw new TransferFailedException( "Failed to determine path for artifact", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
File metadataFile = new File( localRepository.getBasedir(), localPath );
|
getRemoteFile( remoteRepository, destination, remotePath );
|
||||||
getRemoteFile( remoteRepository, metadataFile, remotePath );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getRemoteFile( ArtifactRepository repository, File destination, String remotePath )
|
private void getRemoteFile( ArtifactRepository repository, File destination, String remotePath )
|
||||||
|
@ -184,6 +249,7 @@ public class DefaultWagonManager
|
||||||
|
|
||||||
//wagon.addTransferListener( md5SumObserver );
|
//wagon.addTransferListener( md5SumObserver );
|
||||||
|
|
||||||
|
// TODO: probably don't want this on metadata...
|
||||||
if ( downloadMonitor != null )
|
if ( downloadMonitor != null )
|
||||||
{
|
{
|
||||||
wagon.addTransferListener( downloadMonitor );
|
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
|
// The temporary file is named destination + ".tmp" and is done this
|
||||||
// way to ensure
|
// way to ensure
|
||||||
// that the temporary file is in the same file system as the
|
// that the temporary file is in the same file system as the
|
||||||
|
|
|
@ -39,19 +39,16 @@ public interface WagonManager
|
||||||
Wagon getWagon( String protocol )
|
Wagon getWagon( String protocol )
|
||||||
throws UnsupportedProtocolException;
|
throws UnsupportedProtocolException;
|
||||||
|
|
||||||
// TODO: don't throw exception
|
|
||||||
void releaseWagon( Wagon wagon )
|
|
||||||
throws Exception;
|
|
||||||
|
|
||||||
void getArtifact( Artifact artifact, List remoteRepositories, File destination )
|
void getArtifact( Artifact artifact, List remoteRepositories, File destination )
|
||||||
throws TransferFailedException;
|
throws TransferFailedException;
|
||||||
|
|
||||||
// TODO: don't throw exception
|
|
||||||
void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository )
|
void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository )
|
||||||
throws Exception;
|
throws TransferFailedException;
|
||||||
|
|
||||||
void getMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository,
|
public void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository )
|
||||||
ArtifactRepository localRepository )
|
throws TransferFailedException;
|
||||||
|
|
||||||
|
public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination )
|
||||||
throws TransferFailedException, ResourceDoesNotExistException;
|
throws TransferFailedException, ResourceDoesNotExistException;
|
||||||
|
|
||||||
void setProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts );
|
void setProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts );
|
||||||
|
|
|
@ -17,19 +17,17 @@ package org.apache.maven.artifact.metadata;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
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.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.
|
* 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>
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
* @todo naming is too close to ArtifactMetadataSource which refers to a POM. A POM is sometimes an artifact itself,
|
* @todo merge with artifactmetadatasource
|
||||||
* so that naming may no longer be appropriate.
|
* @todo retrieval exception not appropriate for store
|
||||||
|
* @todo not happy about the store/retrieve methods - they use "this"
|
||||||
*/
|
*/
|
||||||
public interface ArtifactMetadata
|
public interface ArtifactMetadata
|
||||||
{
|
{
|
||||||
|
@ -39,16 +37,16 @@ public interface ArtifactMetadata
|
||||||
* @param localRepository the local repository
|
* @param localRepository the local repository
|
||||||
*/
|
*/
|
||||||
void storeInLocalRepository( ArtifactRepository localRepository )
|
void storeInLocalRepository( ArtifactRepository localRepository )
|
||||||
throws IOException, ArtifactPathFormatException;
|
throws ArtifactMetadataRetrievalException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the metadata from the remote repository into the local repository.
|
* Retrieve the metadata from the remote repository into the local repository.
|
||||||
*
|
*
|
||||||
* @param remoteRepository the remote 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 )
|
public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, WagonManager wagonManager )
|
||||||
throws IOException, ArtifactResolutionException;
|
throws ArtifactMetadataRetrievalException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the associated artifact.
|
* Get the associated artifact.
|
||||||
|
|
|
@ -17,11 +17,15 @@ package org.apache.maven.artifact.metadata;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
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.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
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.FileUtils;
|
||||||
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -39,7 +43,7 @@ public class SnapshotArtifactMetadata
|
||||||
{
|
{
|
||||||
private String timestamp = null;
|
private String timestamp = null;
|
||||||
|
|
||||||
private int buildNumber = 1;
|
private int buildNumber = 0;
|
||||||
|
|
||||||
private static final String SNAPSHOT_VERSION_LOCAL_FILE = "version-local.txt";
|
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 );
|
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 );
|
return new SnapshotArtifactMetadata( artifact, SNAPSHOT_VERSION_FILE );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storeInLocalRepository( ArtifactRepository localRepository )
|
public void storeInLocalRepository( ArtifactRepository localRepository )
|
||||||
throws IOException, ArtifactPathFormatException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
FileUtils.fileWrite( localRepository.getBasedir() + "/" + localRepository.pathOfMetadata( this ),
|
try
|
||||||
getTimestamp() + "-" + buildNumber );
|
{
|
||||||
|
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 )
|
public String getVersion()
|
||||||
throws IOException, ArtifactResolutionException
|
|
||||||
{
|
{
|
||||||
/*
|
String version = artifact.getVersion();
|
||||||
// TODO: this is getting the artifact - needs to get the version.txt
|
if ( version != null )
|
||||||
resolver.resolve( artifact, Collections.singletonList( remoteRepository ), localRepository );
|
{
|
||||||
|
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();
|
try
|
||||||
timestamp = version.substring( 0, index );
|
{
|
||||||
|
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()
|
public String getTimestamp()
|
||||||
{
|
{
|
||||||
if ( timestamp == null )
|
|
||||||
{
|
|
||||||
timestamp = getUtcDateFormatter().format( new Date() );
|
|
||||||
}
|
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,4 +155,10 @@ public class SnapshotArtifactMetadata
|
||||||
utcDateFormatter.setTimeZone( UTC_TIME_ZONE );
|
utcDateFormatter.setTimeZone( UTC_TIME_ZONE );
|
||||||
return utcDateFormatter;
|
return utcDateFormatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
this.buildNumber++;
|
||||||
|
timestamp = getUtcDateFormatter().format( new Date() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class LegacyRepositoryLayout
|
||||||
|
|
||||||
protected String metadataLayoutPattern()
|
protected String metadataLayoutPattern()
|
||||||
{
|
{
|
||||||
return "${groupPath}/${directory}/${artifactId}-${version}-${metadataFilename}";
|
return "${groupPath}/poms/${artifactId}-${version}-${metadataFilename}";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String groupIdAsPath( String groupId )
|
protected String groupIdAsPath( String groupId )
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class DefaultArtifactResolver
|
||||||
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
|
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
ArtifactTransformation transform = (ArtifactTransformation) i.next();
|
ArtifactTransformation transform = (ArtifactTransformation) i.next();
|
||||||
artifact = transform.transformLocalArtifact( artifact, localRepository );
|
artifact = transform.transformForResolve( artifact );
|
||||||
}
|
}
|
||||||
|
|
||||||
String localPath;
|
String localPath;
|
||||||
|
@ -182,19 +182,12 @@ public class DefaultArtifactResolver
|
||||||
throw new ArtifactResolutionException( "Error transitively resolving artifacts: ", e );
|
throw new ArtifactResolutionException( "Error transitively resolving artifacts: ", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this is unclean, but necessary as long as resolve may return a different artifact
|
for ( Iterator i = artifactResolutionResult.getArtifacts().values().iterator(); i.hasNext(); )
|
||||||
Map collectedArtifacts = artifactResolutionResult.getArtifacts();
|
|
||||||
Map resolvedArtifacts = new HashMap( collectedArtifacts.size() );
|
|
||||||
for ( Iterator i = collectedArtifacts.keySet().iterator(); i.hasNext(); )
|
|
||||||
{
|
{
|
||||||
Object key = i.next();
|
// TODO: resolve may modify artifacts, do we need to get the new list?
|
||||||
resolvedArtifacts.put( key, resolve( (Artifact) collectedArtifacts.get( key ), remoteRepositories,
|
resolve( (Artifact) i.next(), remoteRepositories, localRepository );
|
||||||
localRepository ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
collectedArtifacts.clear();
|
|
||||||
collectedArtifacts.putAll( resolvedArtifacts );
|
|
||||||
|
|
||||||
return artifactResolutionResult;
|
return artifactResolutionResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ package org.apache.maven.artifact.transform;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +29,15 @@ public interface ArtifactTransformation
|
||||||
{
|
{
|
||||||
static String ROLE = ArtifactTransformation.class.getName();
|
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
|
* 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.
|
* 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
|
* @param localRepository the local repository it will be stored in
|
||||||
* @return The transformed Artifact
|
* @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.
|
* 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
|
* @return The transformed Artifact
|
||||||
* @todo finish doco
|
|
||||||
*/
|
*/
|
||||||
Artifact transformRemoteArtifact( Artifact artifact, ArtifactRepository remoteRepository );
|
Artifact transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
|
||||||
|
throws ArtifactMetadataRetrievalException;
|
||||||
}
|
}
|
|
@ -17,7 +17,10 @@ package org.apache.maven.artifact.transform;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
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.ArtifactMetadata;
|
||||||
|
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata;
|
import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
|
||||||
|
@ -30,6 +33,8 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
public class SnapshotTransformation
|
public class SnapshotTransformation
|
||||||
implements ArtifactTransformation
|
implements ArtifactTransformation
|
||||||
{
|
{
|
||||||
|
private WagonManager wagonManager;
|
||||||
|
|
||||||
/* TODO: use and remove
|
/* TODO: use and remove
|
||||||
public Artifact transform( Artifact artifact, ArtifactRepository localRepository, List repositories,
|
public Artifact transform( Artifact artifact, ArtifactRepository localRepository, List repositories,
|
||||||
Map parameters )
|
Map parameters )
|
||||||
|
@ -185,9 +190,15 @@ public class SnapshotTransformation
|
||||||
return retValue;
|
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
|
// only store the version-local.txt file for POMs as every file has an associated POM
|
||||||
ArtifactMetadata metadata = SnapshotArtifactMetadata.createLocalSnapshotMetadata( artifact );
|
ArtifactMetadata metadata = SnapshotArtifactMetadata.createLocalSnapshotMetadata( artifact );
|
||||||
|
@ -196,23 +207,24 @@ public class SnapshotTransformation
|
||||||
return artifact;
|
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 );
|
SnapshotArtifactMetadata metadata = SnapshotArtifactMetadata.createRemoteSnapshotMetadata( artifact );
|
||||||
// wagonManager.getMetadata( metadata, remoteRepository, localRepository );
|
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;
|
return artifact;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shouldProcessArtifact( Artifact artifact )
|
|
||||||
{
|
|
||||||
return isSnapshot( artifact ) && "pom".equals( artifact.getType() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isSnapshot( Artifact artifact )
|
private static boolean isSnapshot( Artifact artifact )
|
||||||
{
|
{
|
||||||
return artifact.getVersion().endsWith( "SNAPSHOT" );
|
return artifact.getVersion().endsWith( "SNAPSHOT" );
|
||||||
|
|
|
@ -1,5 +1,20 @@
|
||||||
<component-set>
|
<component-set>
|
||||||
<components>
|
<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
|
| Transformations
|
||||||
|
@ -8,6 +23,11 @@
|
||||||
<component>
|
<component>
|
||||||
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
|
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
|
||||||
<implementation>org.apache.maven.artifact.transform.SnapshotTransformation</implementation>
|
<implementation>org.apache.maven.artifact.transform.SnapshotTransformation</implementation>
|
||||||
|
<requirements>
|
||||||
|
<requirement>
|
||||||
|
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||||
|
</requirement>
|
||||||
|
</requirements>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
@ -32,21 +52,6 @@
|
||||||
</requirements>
|
</requirements>
|
||||||
</component>
|
</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
|
| ArtifactInstaller
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ArtifactDeployerTest
|
||||||
|
|
||||||
Artifact artifact = createArtifact( "artifact", "1.0" );
|
Artifact artifact = createArtifact( "artifact", "1.0" );
|
||||||
|
|
||||||
artifactDeployer.deploy( artifactBasedir, artifact, remoteRepository() );
|
artifactDeployer.deploy( artifactBasedir, artifact, remoteRepository(), localRepository() );
|
||||||
|
|
||||||
assertRemoteArtifactPresent( artifact );
|
assertRemoteArtifactPresent( artifact );
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,11 @@ public class ConsoleDownloadMonitor
|
||||||
|
|
||||||
public void transferInitiated( TransferEvent transferEvent )
|
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;
|
complete = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,12 +64,14 @@ public class ConsoleDownloadMonitor
|
||||||
|
|
||||||
public void transferError( TransferEvent transferEvent )
|
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 )
|
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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,13 @@
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>wagon-file</artifactId>
|
||||||
|
<version>1.0-alpha-2-SNAPSHOT</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>maven</groupId>
|
<groupId>maven</groupId>
|
||||||
<artifactId>wagon-ssh</artifactId>
|
<artifactId>wagon-ssh</artifactId>
|
||||||
|
|
|
@ -28,36 +28,34 @@ import org.apache.maven.project.MavenProject;
|
||||||
import java.io.File;
|
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>
|
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
||||||
* @version $Id$
|
* @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
|
public class DeployMojo
|
||||||
extends AbstractPlugin
|
extends AbstractPlugin
|
||||||
|
@ -68,21 +66,22 @@ public class DeployMojo
|
||||||
|
|
||||||
private ArtifactRepository deploymentRepository;
|
private ArtifactRepository deploymentRepository;
|
||||||
|
|
||||||
|
private ArtifactRepository localRepository;
|
||||||
|
|
||||||
public void execute()
|
public void execute()
|
||||||
throws PluginExecutionException
|
throws PluginExecutionException
|
||||||
{
|
{
|
||||||
if ( deploymentRepository == null )
|
if ( deploymentRepository == null )
|
||||||
{
|
{
|
||||||
String msg = "Deployment failed: repository element was not specified in the pom inside"
|
String msg = "Deployment failed: repository element was not specified in the pom inside" +
|
||||||
+ " distributionManagement element";
|
" distributionManagement element";
|
||||||
throw new PluginExecutionException( msg );
|
throw new PluginExecutionException( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( deploymentRepository.getAuthenticationInfo() == null )
|
if ( deploymentRepository.getAuthenticationInfo() == null )
|
||||||
{
|
{
|
||||||
getLog().warn(
|
getLog().warn( "Deployment repository {id: \'" + deploymentRepository.getId() +
|
||||||
"Deployment repository {id: \'" + deploymentRepository.getId()
|
"\'} has no associated authentication info!" );
|
||||||
+ "\'} has no associated authentication info!" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deploy the POM
|
// Deploy the POM
|
||||||
|
@ -93,7 +92,7 @@ public class DeployMojo
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
deployer.deploy( pom, pomArtifact, deploymentRepository );
|
deployer.deploy( pom, pomArtifact, deploymentRepository, localRepository );
|
||||||
|
|
||||||
//Deploy artifact
|
//Deploy artifact
|
||||||
if ( !"pom".equals( project.getPackaging() ) )
|
if ( !"pom".equals( project.getPackaging() ) )
|
||||||
|
@ -101,7 +100,7 @@ public class DeployMojo
|
||||||
Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(),
|
Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(),
|
||||||
project.getVersion(), project.getPackaging() );
|
project.getVersion(), project.getPackaging() );
|
||||||
|
|
||||||
deployer.deploy( project.getBuild().getDirectory(), artifact, deploymentRepository );
|
deployer.deploy( project.getBuild().getDirectory(), artifact, deploymentRepository, localRepository );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( ArtifactDeploymentException e )
|
catch ( ArtifactDeploymentException e )
|
||||||
|
|
Loading…
Reference in New Issue