o Revised fix from r1151426 which broke the appassembler-maven-plugin

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1210240 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2011-12-04 21:52:04 +00:00
parent b8e759de02
commit c9d2202549
1 changed files with 22 additions and 1 deletions

View File

@ -26,6 +26,7 @@ import java.util.List;
import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreException;
import org.apache.maven.repository.Proxy;
import org.sonatype.aether.RepositorySystem;
@ -58,6 +59,8 @@ public class LegacyLocalRepositoryManager
private final LocalRepository repo;
private final boolean realLocalRepo;
public static RepositorySystemSession overlay( ArtifactRepository repository, RepositorySystemSession session,
RepositorySystem system )
{
@ -103,6 +106,20 @@ public class LegacyLocalRepositoryManager
repo =
new LocalRepository( new File( delegate.getBasedir() ),
( layout != null ) ? layout.getClass().getSimpleName() : "legacy" );
/*
* NOTE: "invoker:install" vs "appassembler:assemble": Both mojos use the artifact installer to put an artifact
* into a repository. In the first case, the result needs to be a proper local repository that one can use for
* local artifact resolution. In the second case, the result needs to precisely obey the path information of the
* repository's layout to allow pointing at artifacts within the repository. Unfortunately,
* DefaultRepositoryLayout does not correctly describe the layout of a local repository which unlike a remote
* repository never uses timestamps in the filename of a snapshot artifact. The discrepancy gets notable when a
* remotely resolved snapshot artifact gets passed into pathOf(). So producing a proper local artifact path
* using DefaultRepositoryLayout requires us to enforce usage of the artifact's base version. This
* transformation however contradicts the other use case of precisely obeying the repository's layout. The below
* flag tries to detect which use case applies to make both plugins happy.
*/
realLocalRepo = ( layout instanceof DefaultRepositoryLayout ) && "local".equals( delegate.getId() );
}
public LocalRepository getRepository()
@ -112,7 +129,11 @@ public class LegacyLocalRepositoryManager
public String getPathForLocalArtifact( Artifact artifact )
{
return delegate.pathOf( RepositoryUtils.toArtifact( artifact.setVersion( artifact.getBaseVersion() ) ) );
if ( realLocalRepo )
{
return delegate.pathOf( RepositoryUtils.toArtifact( artifact.setVersion( artifact.getBaseVersion() ) ) );
}
return delegate.pathOf( RepositoryUtils.toArtifact( artifact ) );
}
public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context )