You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2011/12/04 22:52:04 UTC

svn commit: r1210240 - /maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java

Author: bentmann
Date: Sun Dec  4 21:52:04 2011
New Revision: 1210240

URL: http://svn.apache.org/viewvc?rev=1210240&view=rev
Log:
o Revised fix from r1151426 which broke the appassembler-maven-plugin

Modified:
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java?rev=1210240&r1=1210239&r2=1210240&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java Sun Dec  4 21:52:04 2011
@@ -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 LegacyLocalRepositoryManage
 
     private final LocalRepository repo;
 
+    private final boolean realLocalRepo;
+
     public static RepositorySystemSession overlay( ArtifactRepository repository, RepositorySystemSession session,
                                                    RepositorySystem system )
     {
@@ -103,6 +106,20 @@ public class LegacyLocalRepositoryManage
         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 LegacyLocalRepositoryManage
 
     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 )



Re: svn commit: r1210240 - /maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java

Posted by Olivier Lamy <ol...@apache.org>.
Thanks Benjamin.

I'm now adding an it test for that.

2011/12/4  <be...@apache.org>:
> Author: bentmann
> Date: Sun Dec  4 21:52:04 2011
> New Revision: 1210240
>
> URL: http://svn.apache.org/viewvc?rev=1210240&view=rev
> Log:
> o Revised fix from r1151426 which broke the appassembler-maven-plugin
>
> Modified:
>    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java
>
> Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java
> URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java?rev=1210240&r1=1210239&r2=1210240&view=diff
> ==============================================================================
> --- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java (original)
> +++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java Sun Dec  4 21:52:04 2011
> @@ -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 LegacyLocalRepositoryManage
>
>     private final LocalRepository repo;
>
> +    private final boolean realLocalRepo;
> +
>     public static RepositorySystemSession overlay( ArtifactRepository repository, RepositorySystemSession session,
>                                                    RepositorySystem system )
>     {
> @@ -103,6 +106,20 @@ public class LegacyLocalRepositoryManage
>         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 LegacyLocalRepositoryManage
>
>     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 )
>
>



-- 
Olivier Lamy
Talend: http://coders.talend.com
http://twitter.com/olamy | http://linkedin.com/in/olamy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org