From c9d22025493d3121f3473616dfcbdb14ad75defc Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sun, 4 Dec 2011 21:52:04 +0000 Subject: [PATCH] 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 --- .../LegacyLocalRepositoryManager.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java index db0ff0eed2..d77f593547 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java @@ -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 )