Author: jdcasey
Date: Wed Sep 21 13:01:41 2005
New Revision: 290815

URL: http://svn.apache.org/viewcvs?rev=290815&view=rev
Log:
Resolving: MNG-900

Applied Hiram's patch, with small formatting changes, and a relocation of the 
logic setting the artifact repository to null (it was being done on the 
condition that getLogger().isDebugEnabled() == true, just a minor oversight).

There may be a deeper issue here with missing metadata on all 
repositories...I've annotated what I believe is the root causebut I'm not sure 
how to fix it, or that it should be fixed.


Modified:
    
maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java
    
maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.java

Modified: 
maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java?rev=290815&r1=290814&r2=290815&view=diff
==============================================================================
--- 
maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java
 (original)
+++ 
maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java
 Wed Sep 21 13:01:41 2005
@@ -89,6 +89,12 @@
                     }
                     else
                     {
+                        // NOTE: [jc; 21-sept-2005] won't this cause 
inconsistencies if the metadata wasn't found?
+                        // this will write out an essentially empty metadata 
file, which will result
+                        // in the loop below NOT merging anything (each 
successive pass is still empty),
+                        // which means that the last repository will be set as 
the artifact repo, rather
+                        // than leaving it null. This is the root cause of 
MNG-900, but I'm not sure how
+                        // to fix it.
                         metadata.storeInLocalRepository( localRepository, 
repository );
                     }
                 }

Modified: 
maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.java?rev=290815&r1=290814&r2=290815&view=diff
==============================================================================
--- 
maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.java
 (original)
+++ 
maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.java
 Wed Sep 21 13:01:41 2005
@@ -109,9 +109,17 @@
             else
             {
                 // Locally installed file is newer, don't use the resolved 
version
-                getLogger().debug( artifact.getArtifactId() + ": using locally 
installed snapshot" );
+                getLogger().debug( artifact.getArtifactId() + ": using locally 
installed snapshot");
             }
         }
+        
+        if ( version.equals( artifact.getBaseVersion() ) )
+        {
+            // odd: we hit here when: using legecy repo, not local, and no 
snapshot version meta data was availble
+            // but the repository was set to one of the remote repos (and it 
was the wrong one).
+            artifact.setRepository( null );
+        }
+        
         return version;
     }
 
@@ -138,6 +146,10 @@
                 throw new ArtifactMetadataRetrievalException( "Error reading 
local metadata", e );
             }
         }
+        else
+        {
+            localMetadata = null;
+        }
 
         boolean alreadyResolved = alreadyResolved( artifact );
         if ( !alreadyResolved )
@@ -157,7 +169,8 @@
                 }
                 else
                 {
-                    boolean checkForUpdates = policy.checkOutOfDate( 
localMetadata.getLastModified() );
+                    boolean checkForUpdates = localMetadata == null
+                        || policy.checkOutOfDate( 
localMetadata.getLastModified() );
 
                     if ( checkForUpdates )
                     {
@@ -174,13 +187,12 @@
 
                             getLogger().warn( "Using old-style versioning 
metadata from remote repo for " + artifact );
 
-                            int difference = remoteMetadata.compareTo( 
localMetadata );
-                            if ( difference > 0 )
+                            if ( localMetadata == null || 
remoteMetadata.compareTo( localMetadata ) > 0 )
                             {
                                 // remote is newer
                                 artifact.setRepository( repository );
-
                                 localMetadata = remoteMetadata;
+                                getLogger().debug( "Found repository for the 
artifact." );
                             }
                         }
                         catch ( ResourceDoesNotExistException e )
@@ -204,7 +216,7 @@
 
             // touch the file if it was checked for updates, but don't create 
it if it did't exist to avoid
             // storing SNAPSHOT as the actual version which doesn't exist 
remotely.
-            if ( checkedUpdates && localMetadata.getLastModified().getTime() > 
0 )
+            if ( checkedUpdates && localMetadata != null && 
localMetadata.getLastModified().getTime() > 0 )
             {
                 localMetadata.storeInLocalRepository( localRepository );
             }
@@ -212,7 +224,7 @@
             resolvedArtifactCache.add( getCacheKey( artifact ) );
         }
 
-        if ( artifact.getFile().exists() && !localMetadata.newerThanFile( 
artifact.getFile() ) )
+        if ( localMetadata != null && artifact.getFile().exists() && 
!localMetadata.newerThanFile( artifact.getFile() ) )
         {
             if ( getLogger().isDebugEnabled() && !alreadyResolved )
             {
@@ -221,6 +233,7 @@
             }
             localMetadata = null;
         }
+        
         return localMetadata != null ? localMetadata.constructVersion() : null;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to