mirror of https://github.com/apache/maven.git
correct placement of transformations
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163682 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ee15019eb8
commit
4ba9fbcc33
|
@ -23,10 +23,8 @@ import org.apache.maven.artifact.manager.WagonManager;
|
|||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @todo snapshot notions need to be dealt with in one place.
|
||||
*/
|
||||
public class DefaultArtifactDeployer
|
||||
implements ArtifactDeployer
|
||||
{
|
||||
|
@ -34,6 +32,8 @@ public class DefaultArtifactDeployer
|
|||
|
||||
private ArtifactHandlerManager artifactHandlerManager;
|
||||
|
||||
private List artifactTransformations;
|
||||
|
||||
public void deploy( String basedir, Artifact artifact, ArtifactRepository deploymentRepository )
|
||||
throws ArtifactDeploymentException
|
||||
{
|
||||
|
@ -54,6 +54,8 @@ public class DefaultArtifactDeployer
|
|||
public void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository )
|
||||
throws ArtifactDeploymentException
|
||||
{
|
||||
// TODO: perform transformations
|
||||
|
||||
try
|
||||
{
|
||||
wagonManager.putArtifact( source, artifact, deploymentRepository );
|
||||
|
|
|
@ -16,10 +16,7 @@ package org.apache.maven.artifact.handler.manager;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
|
@ -31,10 +28,4 @@ public interface ArtifactHandlerManager
|
|||
|
||||
ArtifactHandler getArtifactHandler( String type )
|
||||
throws ArtifactHandlerNotFoundException;
|
||||
|
||||
String getLocalRepositoryArtifactPath( Artifact artifact, ArtifactRepository localRepository )
|
||||
throws ArtifactPathFormatException;
|
||||
|
||||
String getRemoteRepositoryArtifactPath( Artifact artifact, ArtifactRepository remoteRepository )
|
||||
throws ArtifactPathFormatException;
|
||||
}
|
|
@ -16,15 +16,9 @@ package org.apache.maven.artifact.handler.manager;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.artifact.transform.ArtifactTransformation;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -36,8 +30,6 @@ import java.util.Set;
|
|||
public class DefaultArtifactHandlerManager
|
||||
implements ArtifactHandlerManager
|
||||
{
|
||||
private List artifactTransformations;
|
||||
|
||||
private Map artifactHandlers;
|
||||
|
||||
private ArtifactRepositoryLayout artifactRepositoryLayout;
|
||||
|
@ -59,31 +51,4 @@ public class DefaultArtifactHandlerManager
|
|||
{
|
||||
return artifactHandlers.keySet();
|
||||
}
|
||||
|
||||
public String getRemoteRepositoryArtifactPath( Artifact artifact, ArtifactRepository remoteRepository )
|
||||
throws ArtifactPathFormatException
|
||||
{
|
||||
// TODO: note that these are currrently assuming only PUT operations, not GET operations
|
||||
// TODO: note also that these add metadata to the artifacts, so it is assumed this is only called once per artifact - needs to be fixed
|
||||
|
||||
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
|
||||
{
|
||||
ArtifactTransformation transform = (ArtifactTransformation) i.next();
|
||||
artifact = transform.transformRemoteArtifact( artifact, remoteRepository );
|
||||
}
|
||||
|
||||
return remoteRepository.pathOf( artifact );
|
||||
}
|
||||
|
||||
public String getLocalRepositoryArtifactPath( Artifact artifact, ArtifactRepository localRepository )
|
||||
throws ArtifactPathFormatException
|
||||
{
|
||||
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
|
||||
{
|
||||
ArtifactTransformation transform = (ArtifactTransformation) i.next();
|
||||
artifact = transform.transformLocalArtifact( artifact, localRepository );
|
||||
}
|
||||
|
||||
return localRepository.getBasedir() + "/" + localRepository.pathOf( artifact );
|
||||
}
|
||||
}
|
|
@ -22,12 +22,14 @@ import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundExceptio
|
|||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||
import org.apache.maven.artifact.transform.ArtifactTransformation;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class DefaultArtifactInstaller
|
||||
extends AbstractLogEnabled
|
||||
|
@ -35,6 +37,8 @@ public class DefaultArtifactInstaller
|
|||
{
|
||||
private ArtifactHandlerManager artifactHandlerManager;
|
||||
|
||||
private List artifactTransformations;
|
||||
|
||||
public void install( String basedir, Artifact artifact, ArtifactRepository localRepository )
|
||||
throws ArtifactInstallationException
|
||||
{
|
||||
|
@ -57,12 +61,19 @@ public class DefaultArtifactInstaller
|
|||
{
|
||||
try
|
||||
{
|
||||
String localPath = artifactHandlerManager.getLocalRepositoryArtifactPath( artifact, localRepository );
|
||||
// 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.transformLocalArtifact( artifact, localRepository );
|
||||
}
|
||||
|
||||
String localPath = localRepository.pathOf( artifact );
|
||||
|
||||
getLogger().info( "Installing " + source.getPath() + " to " + localPath );
|
||||
|
||||
// TODO: use a file: wagon and the wagon manager?
|
||||
File destination = new File( localPath );
|
||||
File destination = new File( localRepository.getBasedir(), localPath );
|
||||
if ( !destination.getParentFile().exists() )
|
||||
{
|
||||
destination.getParentFile().mkdirs();
|
||||
|
|
|
@ -91,7 +91,7 @@ public class DefaultWagonManager
|
|||
|
||||
wagon.connect( repository, getProxy( repository.getProtocol() ) );
|
||||
|
||||
wagon.put( source, artifactHandlerManager.getRemoteRepositoryArtifactPath( artifact, repository ) );
|
||||
wagon.put( source, repository.pathOf( artifact ) );
|
||||
|
||||
wagon.disconnect();
|
||||
|
||||
|
@ -107,11 +107,10 @@ public class DefaultWagonManager
|
|||
{
|
||||
ArtifactRepository repository = (ArtifactRepository) iter.next();
|
||||
|
||||
// TODO: should we avoid doing the transforms on this every time, and instead transform outside the loop?
|
||||
String remotePath = null;
|
||||
try
|
||||
{
|
||||
remotePath = artifactHandlerManager.getRemoteRepositoryArtifactPath( artifact, repository );
|
||||
remotePath = repository.pathOf( artifact );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
|||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
import org.apache.maven.artifact.transform.ArtifactTransformation;
|
||||
import org.apache.maven.wagon.TransferFailedException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
@ -56,6 +57,8 @@ public class DefaultArtifactResolver
|
|||
|
||||
private ArtifactHandlerManager artifactHandlerManager;
|
||||
|
||||
private List artifactTransformations;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Implementation
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -67,27 +70,32 @@ public class DefaultArtifactResolver
|
|||
// ----------------------------------------------------------------------
|
||||
// Check for the existence of the artifact in the specified local
|
||||
// ArtifactRepository. If it is present then simply return as the
|
||||
// request
|
||||
// for resolution has been satisfied.
|
||||
// request for resolution has been satisfied.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Logger logger = getLogger();
|
||||
logger.debug( "Resolving: " + artifact.getId() + " from:\n" + "{localRepository: " + localRepository + "}\n" +
|
||||
"{remoteRepositories: " + remoteRepositories + "}" );
|
||||
|
||||
// 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.transformLocalArtifact( artifact, localRepository );
|
||||
}
|
||||
|
||||
String localPath;
|
||||
|
||||
try
|
||||
{
|
||||
localPath = artifactHandlerManager.getLocalRepositoryArtifactPath( artifact, localRepository );
|
||||
localPath = localRepository.pathOf( artifact );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( "Error resolving artifact: ", e );
|
||||
}
|
||||
|
||||
// TODO: what if it were a snapshot that was transformed?
|
||||
File destination = new File( localPath );
|
||||
File destination = new File( localRepository.getBasedir(), localPath );
|
||||
artifact.setFile( destination );
|
||||
|
||||
if ( destination.exists() )
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
|
||||
<field-name>artifactTransformations</field-name>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
|
@ -55,6 +59,10 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
|
||||
<field-name>artifactTransformations</field-name>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
|
@ -73,6 +81,10 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
|
||||
<field-name>artifactTransformations</field-name>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
|
@ -111,10 +123,6 @@
|
|||
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
|
||||
<field-name>artifactHandlers</field-name>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
|
||||
<field-name>artifactTransformations</field-name>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
|
|
Loading…
Reference in New Issue