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 2010/09/08 15:48:04 UTC

svn commit: r995057 - in /maven/maven-3/trunk: maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ maven-repository-metadata/src/main/mdo/

Author: bentmann
Date: Wed Sep  8 13:48:04 2010
New Revision: 995057

URL: http://svn.apache.org/viewvc?rev=995057&view=rev
Log:
[MNG-4452] Metadata for snapshots should include classifier

Modified:
    maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
    maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java
    maven/maven-3/trunk/maven-repository-metadata/src/main/mdo/metadata.mdo

Modified: maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java?rev=995057&r1=995056&r2=995057&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java (original)
+++ maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java Wed Sep  8 13:48:04 2010
@@ -235,7 +235,7 @@ public class DefaultVersionResolver
             }
             else
             {
-                if ( !resolve( result, infos, SNAPSHOT + artifact.getClassifier() )
+                if ( !resolve( result, infos, SNAPSHOT + getKey( artifact.getClassifier(), artifact.getExtension() ) )
                     && !resolve( result, infos, SNAPSHOT ) )
                 {
                     result.setVersion( version );
@@ -322,18 +322,17 @@ public class DefaultVersionResolver
             merge( LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository );
         }
 
-        boolean mainSnapshot = false;
         for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
         {
             if ( StringUtils.isNotEmpty( sv.getVersion() ) )
             {
-                mainSnapshot |= sv.getClassifier().length() <= 0;
-                merge( SNAPSHOT + sv.getClassifier(), infos, sv.getUpdated(), sv.getVersion(), repository );
+                String key = getKey( sv.getClassifier(), sv.getExtension() );
+                merge( SNAPSHOT + key, infos, sv.getUpdated(), sv.getVersion(), repository );
             }
         }
 
         Snapshot snapshot = versioning.getSnapshot();
-        if ( !mainSnapshot && snapshot != null )
+        if ( snapshot != null )
         {
             String version = artifact.getVersion();
             if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 )
@@ -361,6 +360,11 @@ public class DefaultVersionResolver
         }
     }
 
+    private String getKey( String classifier, String extension )
+    {
+        return StringUtils.clean( classifier ) + ':' + StringUtils.clean( extension );
+    }
+
     private static class VersionInfo
     {
 
@@ -391,6 +395,10 @@ public class DefaultVersionResolver
 
         private final String artifactId;
 
+        private final String classifier;
+
+        private final String extension;
+
         private final String version;
 
         private final String context;
@@ -405,9 +413,12 @@ public class DefaultVersionResolver
 
         public Key( RepositorySystemSession session, VersionRequest request )
         {
-            groupId = request.getArtifact().getGroupId();
-            artifactId = request.getArtifact().getArtifactId();
-            version = request.getArtifact().getVersion();
+            Artifact artifact = request.getArtifact();
+            groupId = artifact.getGroupId();
+            artifactId = artifact.getArtifactId();
+            classifier = artifact.getClassifier();
+            extension = artifact.getExtension();
+            version = artifact.getVersion();
             context = request.getRequestContext();
             localRepo = session.getLocalRepository().getBasedir();
             workspace = CacheUtils.getWorkspace( session );
@@ -427,6 +438,8 @@ public class DefaultVersionResolver
             int hash = 17;
             hash = hash * 31 + groupId.hashCode();
             hash = hash * 31 + artifactId.hashCode();
+            hash = hash * 31 + classifier.hashCode();
+            hash = hash * 31 + extension.hashCode();
             hash = hash * 31 + version.hashCode();
             hash = hash * 31 + localRepo.hashCode();
             hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories );
@@ -447,6 +460,7 @@ public class DefaultVersionResolver
 
             Key that = (Key) obj;
             return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId )
+                && classifier.equals( that.classifier ) && extension.equals( that.extension )
                 && version.equals( that.version ) && context.equals( that.context )
                 && localRepo.equals( that.localRepo ) && CacheUtils.eq( workspace, that.workspace )
                 && CacheUtils.repositoriesEquals( repositories, that.repositories );

Modified: maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java?rev=995057&r1=995056&r2=995057&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java (original)
+++ maven/maven-3/trunk/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java Wed Sep  8 13:48:04 2010
@@ -91,7 +91,8 @@ final class RemoteSnapshotMetadata
 
     public String getExpandedVersion( Artifact artifact )
     {
-        return versions.get( artifact.getClassifier() ).getVersion();
+        String key = getKey( artifact.getClassifier(), artifact.getExtension() );
+        return versions.get( key ).getVersion();
     }
 
     @Override
@@ -134,9 +135,10 @@ final class RemoteSnapshotMetadata
 
             SnapshotVersion sv = new SnapshotVersion();
             sv.setClassifier( artifact.getClassifier() );
+            sv.setExtension( artifact.getExtension() );
             sv.setVersion( version );
             sv.setUpdated( lastUpdated );
-            versions.put( sv.getClassifier(), sv );
+            versions.put( getKey( sv.getClassifier(), sv.getExtension() ), sv );
         }
 
         artifacts.clear();
@@ -146,9 +148,10 @@ final class RemoteSnapshotMetadata
         {
             for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
             {
-                if ( !versions.containsKey( sv.getClassifier() ) )
+                String key = getKey( sv.getClassifier(), sv.getExtension() );
+                if ( !versions.containsKey( key ) )
                 {
-                    versions.put( sv.getClassifier(), sv );
+                    versions.put( key, sv );
                 }
             }
         }
@@ -156,6 +159,11 @@ final class RemoteSnapshotMetadata
         metadata.getVersioning().setSnapshotVersions( new ArrayList<SnapshotVersion>( versions.values() ) );
     }
 
+    private String getKey( String classifier, String extension )
+    {
+        return classifier + ':' + extension;
+    }
+
     private static int getBuildNumber( Metadata metadata )
     {
         int number = 0;

Modified: maven/maven-3/trunk/maven-repository-metadata/src/main/mdo/metadata.mdo
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-repository-metadata/src/main/mdo/metadata.mdo?rev=995057&r1=995056&r2=995057&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-repository-metadata/src/main/mdo/metadata.mdo (original)
+++ maven/maven-3/trunk/maven-repository-metadata/src/main/mdo/metadata.mdo Wed Sep  8 13:48:04 2010
@@ -312,6 +312,12 @@ under the License.
           <description>The classifier of the snapshot artifact this version information belongs to.</description>
           <defaultValue></defaultValue>
         </field>
+        <field>
+          <name>extension</name>
+          <version>1.1.0+</version>
+          <type>String</type>
+          <description>The file extension of the snapshot artifact this version information belongs to.</description>
+        </field>
         <field xml.tagName="value">
           <name>version</name>
           <version>1.1.0+</version>



Re: svn commit: r995057 - in /maven/maven-3/trunk: maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ maven-repository-metadata/src/main/mdo/

Posted by Brett Porter <br...@apache.org>.
On 09/09/2010, at 9:23 PM, Benjamin Bentmann wrote:

> Brett Porter wrote:
> 
>> - Deployment by Maven 3 clients will also make it only consumable with Maven 3 clients.
> 
> I can't follow, I just rechecked and the new metadata is parsed by Maven 2.0.10+ and allows it to resolve SNAPSHOTs deployed by Maven 3.


Sorry, I edited and moved the context away without re-reading. If you follow a process such as:

1) deploy -bin.tar.gz 1.4-SNAPSHOT
2) deploy -bin.zip 1.4-SNAPSHOT

At this point, the first is version, say, 1.4-20100909.032808-1-bin.tar.gz and the second 1.4-20100909.080603-2-bin.zip. There's potentially a POM for both, or just the first depending on how you did it. The main snapshot information reads 20100909.080603-2. Maven 2 will be unable to resolve the originally deployed classifier because of the mismatched timestamp.

That's actually the same result that Maven 2 users get now if they try this - but the person deploying with Maven 3 may not realise the solution that works for them won't work for Maven 2 users they have, in potentially confusing ways. The same would go for any tool that assumes they need to be the same, or those that expect the timestamps of POMs and current artifacts to line up.

My gut says that the snapshot version should be the same, but it has catches and after thinking through it your solution makes more sense to me. I just wanted to walk through it in case you had additional thoughts to share or if anyone caught another edge case. As we know, once the metadata is there we have to support it for some time :)

- Brett

--
Brett Porter
brett@apache.org
http://brettporter.wordpress.com/





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


Re: svn commit: r995057 - in /maven/maven-3/trunk: maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ maven-repository-metadata/src/main/mdo/

Posted by Benjamin Bentmann <be...@udo.edu>.
Brett Porter wrote:

> - Deployment by Maven 3 clients will also make it only consumable with Maven 3 clients.

I can't follow, I just rechecked and the new metadata is parsed by Maven 
2.0.10+ and allows it to resolve SNAPSHOTs deployed by Maven 3.


Benjamin

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


Re: svn commit: r995057 - in /maven/maven-3/trunk: maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ maven-repository-metadata/src/main/mdo/

Posted by Brett Porter <br...@apache.org>.
On 08/09/2010, at 11:48 PM, bentmann@apache.org wrote:

> Author: bentmann
> Date: Wed Sep  8 13:48:04 2010
> New Revision: 995057
> 
> URL: http://svn.apache.org/viewvc?rev=995057&view=rev
> Log:
> [MNG-4452] Metadata for snapshots should include classifier

I've been back and forward on this today... re-reading the associated thread, there were differing opinions about reusing the last snapshot version vs. having distinct ones per derived artifact.

There's some potential problems with diverging versions:
- it isn't clear which "match up" to the same source tree any more
- likewise, it isn't apparent that build 2 of a POM would be used with build 1 of a classifier artifact, when there's a matching build 1 for the pom too.
- Deployment by Maven 3 clients will also make it only consumable with Maven 3 clients. You end up with a top level snapshot version for #2, and #1 not being found when searched for. Same result as attempting this with Maven 2, but maybe some potential for confusion.

They aren't blockers - the first two are cosmetic, and the latter requires a compatibility warning similar to the one for repository managers.

After some thinking, it seems justified to avoid the difficulty of reliably sequencing the alignment of the snapshot version, and for a longer term direction of making them have more distinct metadata. Is that the same conclusion you drew? Any other issues or caveats folks can see here?

I've added some text to the compat page along these lines in the mean time.

FWIW, I'm still of the opinion that extensions to the metadata should come in the form of a new file that supplants both the use of the POM and old metadata for clients that support it, and can be managed for compatibility. But I know that discussion had been deferred until 3.1, so I'll keep holding onto it...

- Brett

--
Brett Porter
brett@apache.org
http://brettporter.wordpress.com/





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