Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 96860 invoked from network); 7 Feb 2006 04:57:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Feb 2006 04:57:42 -0000 Received: (qmail 98066 invoked by uid 500); 7 Feb 2006 04:57:34 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 97998 invoked by uid 500); 7 Feb 2006 04:57:34 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 97980 invoked by uid 99); 7 Feb 2006 04:57:34 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Feb 2006 20:57:34 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 06 Feb 2006 20:57:32 -0800 Received: (qmail 96759 invoked by uid 65534); 7 Feb 2006 04:57:12 -0000 Message-ID: <20060207045712.96758.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r375486 - in /maven/components/branches/maven-2.0.x: maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/ maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/ maven-core-it/ maven-core-it/it0092/ maven... Date: Tue, 07 Feb 2006 04:57:10 -0000 To: commits@maven.apache.org From: brett@apache.org X-Mailer: svnmailer-1.0.6 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: brett Date: Mon Feb 6 20:57:07 2006 New Revision: 375486 URL: http://svn.apache.org/viewcvs?rev=375486&view=rev Log: [MNG-1908] merge rev 375454 and 375485 from trunk Added: maven/components/branches/maven-2.0.x/maven-core-it/it0092/ (props changed) - copied from r375454, maven/components/trunk/maven-core-it/it0092/ maven/components/branches/maven-2.0.x/maven-core-it/it0092/expected-results.txt - copied unchanged from r375454, maven/components/trunk/maven-core-it/it0092/expected-results.txt maven/components/branches/maven-2.0.x/maven-core-it/it0092/goals.txt - copied unchanged from r375454, maven/components/trunk/maven-core-it/it0092/goals.txt maven/components/branches/maven-2.0.x/maven-core-it/it0092/pom.xml - copied unchanged from r375454, maven/components/trunk/maven-core-it/it0092/pom.xml maven/components/branches/maven-2.0.x/maven-core-it/it0092/prebuild-hook.txt - copied unchanged from r375454, maven/components/trunk/maven-core-it/it0092/prebuild-hook.txt maven/components/branches/maven-2.0.x/maven-core-it/it0092/repository/ - copied from r375454, maven/components/trunk/maven-core-it/it0092/repository/ maven/components/branches/maven-2.0.x/maven-core-it/it0092/repository/org.apache.maven/ - copied from r375454, maven/components/trunk/maven-core-it/it0092/repository/org.apache.maven/ maven/components/branches/maven-2.0.x/maven-core-it/it0092/repository/org.apache.maven/jars/ - copied from r375454, maven/components/trunk/maven-core-it/it0092/repository/org.apache.maven/jars/ maven/components/branches/maven-2.0.x/maven-core-it/it0092/repository/org.apache.maven/jars/maven-core-it-support-1.0-SNAPSHOT.jar - copied unchanged from r375454, maven/components/trunk/maven-core-it/it0092/repository/org.apache.maven/jars/maven-core-it-support-1.0-SNAPSHOT.jar Modified: maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java maven/components/branches/maven-2.0.x/maven-core-it/README.txt maven/components/branches/maven-2.0.x/maven-core-it/integration-tests.txt Modified: maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java?rev=375486&r1=375485&r2=375486&view=diff ============================================================================== --- maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java (original) +++ maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java Mon Feb 6 20:57:07 2006 @@ -73,7 +73,7 @@ private Map serverPermissionsMap = new HashMap(); private Map mirrors = new HashMap(); - + private Map serverConfigurationMap = new HashMap(); private TransferListener downloadMonitor; @@ -128,14 +128,14 @@ try { wagon = getWagon( protocol ); - + configureWagon( wagon, repository ); } catch ( UnsupportedProtocolException e ) { throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e ); } - + if ( downloadMonitor != null ) { wagon.addTransferListener( downloadMonitor ); @@ -349,6 +349,8 @@ File temp = new File( destination + ".tmp" ); temp.deleteOnExit(); + boolean downloaded = false; + try { wagon.connect( new Repository( repository.getId(), repository.getUrl() ), @@ -366,51 +368,38 @@ retry = false; // This should take care of creating destination directory now on - wagon.get( remotePath, temp ); - - // keep the checksum files from showing up on the download monitor... - if ( downloadMonitor != null ) + if ( destination.exists() ) { - wagon.removeTransferListener( downloadMonitor ); + downloaded = wagon.getIfNewer( remotePath, temp, destination.lastModified() ); } - - // try to verify the SHA-1 checksum for this file. - try + else { - verifyChecksum( sha1ChecksumObserver, destination, temp, remotePath, ".sha1", wagon ); + wagon.get( remotePath, temp ); + downloaded = true; } - catch ( ChecksumFailedException e ) + + if ( downloaded ) { - // if we catch a ChecksumFailedException, it means the transfer/read succeeded, but the checksum - // doesn't match. This could be a problem with the server (ibiblio HTTP-200 error page), so we'll - // try this up to two times. On the second try, we'll handle it as a bona-fide error, based on the - // repository's checksum checking policy. - if ( firstRun ) - { - getLogger().warn( "*** CHECKSUM FAILED - " + e.getMessage() + " - RETRYING" ); - retry = true; - } - else + // keep the checksum files from showing up on the download monitor... + if ( downloadMonitor != null ) { - handleChecksumFailure( checksumPolicy, e.getMessage(), e.getCause() ); + wagon.removeTransferListener( downloadMonitor ); } - } - catch ( ResourceDoesNotExistException sha1TryException ) - { - getLogger().debug( "SHA1 not found, trying MD5", sha1TryException ); - // if this IS NOT a ChecksumFailedException, it was a problem with transfer/read of the checksum - // file...we'll try again with the MD5 checksum. + // try to verify the SHA-1 checksum for this file. try { - verifyChecksum( md5ChecksumObserver, destination, temp, remotePath, ".md5", wagon ); + verifyChecksum( sha1ChecksumObserver, destination, temp, remotePath, ".sha1", wagon ); } catch ( ChecksumFailedException e ) { - // if we also fail to verify based on the MD5 checksum, and the checksum transfer/read - // succeeded, then we need to determine whether to retry or handle it as a failure. + // if we catch a ChecksumFailedException, it means the transfer/read succeeded, but the checksum + // doesn't match. This could be a problem with the server (ibiblio HTTP-200 error page), so we'll + // try this up to two times. On the second try, we'll handle it as a bona-fide error, based on the + // repository's checksum checking policy. if ( firstRun ) { + getLogger().warn( "*** CHECKSUM FAILED - " + e.getMessage() + " - RETRYING" ); retry = true; } else @@ -418,18 +407,42 @@ handleChecksumFailure( checksumPolicy, e.getMessage(), e.getCause() ); } } - catch ( ResourceDoesNotExistException md5TryException ) + catch ( ResourceDoesNotExistException sha1TryException ) { - // this was a failed transfer, and we don't want to retry. - handleChecksumFailure( checksumPolicy, "Error retrieving checksum file for " + remotePath, - md5TryException ); + getLogger().debug( "SHA1 not found, trying MD5", sha1TryException ); + + // if this IS NOT a ChecksumFailedException, it was a problem with transfer/read of the checksum + // file...we'll try again with the MD5 checksum. + try + { + verifyChecksum( md5ChecksumObserver, destination, temp, remotePath, ".md5", wagon ); + } + catch ( ChecksumFailedException e ) + { + // if we also fail to verify based on the MD5 checksum, and the checksum transfer/read + // succeeded, then we need to determine whether to retry or handle it as a failure. + if ( firstRun ) + { + retry = true; + } + else + { + handleChecksumFailure( checksumPolicy, e.getMessage(), e.getCause() ); + } + } + catch ( ResourceDoesNotExistException md5TryException ) + { + // this was a failed transfer, and we don't want to retry. + handleChecksumFailure( checksumPolicy, "Error retrieving checksum file for " + remotePath, + md5TryException ); + } } - } - // reinstate the download monitor... - if ( downloadMonitor != null ) - { - wagon.addTransferListener( downloadMonitor ); + // reinstate the download monitor... + if ( downloadMonitor != null ) + { + wagon.addTransferListener( downloadMonitor ); + } } // unset the firstRun flag, so we don't get caught in an infinite loop... @@ -455,29 +468,32 @@ releaseWagon( wagon ); } - if ( !temp.exists() ) + if ( downloaded ) { - throw new ResourceDoesNotExistException( "Downloaded file does not exist: " + temp ); - } + if ( !temp.exists() ) + { + throw new ResourceDoesNotExistException( "Downloaded file does not exist: " + temp ); + } - // The temporary file is named destination + ".tmp" and is done this way to ensure - // that the temporary file is in the same file system as the destination because the - // File.renameTo operation doesn't really work across file systems. - // So we will attempt to do a File.renameTo for efficiency and atomicity, if this fails - // then we will use a brute force copy and delete the temporary file. + // The temporary file is named destination + ".tmp" and is done this way to ensure + // that the temporary file is in the same file system as the destination because the + // File.renameTo operation doesn't really work across file systems. + // So we will attempt to do a File.renameTo for efficiency and atomicity, if this fails + // then we will use a brute force copy and delete the temporary file. - if ( !temp.renameTo( destination ) ) - { - try + if ( !temp.renameTo( destination ) ) { - FileUtils.copyFile( temp, destination ); + try + { + FileUtils.copyFile( temp, destination ); - temp.delete(); - } - catch ( IOException e ) - { - throw new TransferFailedException( - "Error copying temporary file to the final destination: " + e.getMessage(), e ); + temp.delete(); + } + catch ( IOException e ) + { + throw new TransferFailedException( + "Error copying temporary file to the final destination: " + e.getMessage(), e ); + } } } } @@ -506,8 +522,8 @@ // otherwise it is ignore } - private void verifyChecksum( ChecksumObserver checksumObserver, File destination, File tempDestination, String remotePath, - String checksumFileExtension, Wagon wagon ) + private void verifyChecksum( ChecksumObserver checksumObserver, File destination, File tempDestination, + String remotePath, String checksumFileExtension, Wagon wagon ) throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException { try @@ -543,7 +559,10 @@ if ( expectedChecksum.equals( actualChecksum ) ) { File checksumFile = new File( destination + checksumFileExtension ); - if ( checksumFile.exists() ) checksumFile.delete(); + if ( checksumFile.exists() ) + { + checksumFile.delete(); + } FileUtils.copyFile( tempChecksumFile, checksumFile ); } else @@ -600,13 +619,13 @@ /** * Set the proxy used for a particular protocol. * - * @param protocol the protocol (required) - * @param host the proxy host name (required) - * @param port the proxy port (required) - * @param username the username for the proxy, or null if there is none - * @param password the password for the proxy, or null if there is none + * @param protocol the protocol (required) + * @param host the proxy host name (required) + * @param port the proxy port (required) + * @param username the username for the proxy, or null if there is none + * @param password the password for the proxy, or null if there is none * @param nonProxyHosts the set of hosts not to use the proxy for. Follows Java system - * property format: *.foo.com|localhost. + * property format: *.foo.com|localhost. * @todo [BP] would be nice to configure this via plexus in some way */ public void addProxy( String protocol, String host, int port, String username, String password, @@ -698,12 +717,12 @@ { this.interactive = interactive; } - + /** * Applies the server configuration to the wagon - * - * @param wagon the wagon to configure + * + * @param wagon the wagon to configure * @param repository the repository that has the configuration * @throws WagonConfigurationException wraps any error given during configuration of the wagon instance */ @@ -724,7 +743,9 @@ } catch ( final ComponentLookupException e ) { - throw new WagonConfigurationException( repositoryId, "Unable to lookup wagon configurator. Wagon configuration cannot be applied.", e ); + throw new WagonConfigurationException( repositoryId, + "Unable to lookup wagon configurator. Wagon configuration cannot be applied.", + e ); } catch ( ComponentConfigurationException e ) { @@ -747,7 +768,7 @@ } } } - + public void addConfiguration( String repositoryId, Xpp3Dom configuration ) { Modified: maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java?rev=375486&r1=375485&r2=375486&view=diff ============================================================================== --- maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java (original) +++ maven/components/branches/maven-2.0.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java Mon Feb 6 20:57:07 2006 @@ -21,6 +21,7 @@ import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.transform.ArtifactTransformationManager; import org.apache.maven.wagon.ResourceDoesNotExistException; @@ -32,6 +33,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -104,6 +106,32 @@ transformationManager.transformForResolve( artifact, remoteRepositories, localRepository ); File destination = artifact.getFile(); + List repositories = remoteRepositories; + + // TODO: would prefer the snapshot transformation took care of this. Maybe we need a "shouldresolve" flag. + if ( artifact.isSnapshot() && artifact.getBaseVersion().equals( artifact.getVersion() ) && + destination.exists() ) + { + Date comparisonDate = new Date( destination.lastModified() ); + + // cull to list of repositories that would like an update + repositories = new ArrayList( remoteRepositories ); + for ( Iterator i = repositories.iterator(); i.hasNext(); ) + { + ArtifactRepository repository = (ArtifactRepository) i.next(); + ArtifactRepositoryPolicy policy = repository.getSnapshots(); + if ( !policy.isEnabled() || !policy.checkOutOfDate( comparisonDate ) ) + { + i.remove(); + } + } + + if ( !repositories.isEmpty() ) + { + // someone wants to check for updates + force = true; + } + } boolean resolved = false; if ( !destination.exists() || force ) { @@ -121,7 +149,7 @@ } else { - wagonManager.getArtifact( artifact, remoteRepositories ); + wagonManager.getArtifact( artifact, repositories ); } if ( !artifact.isResolved() ) @@ -238,11 +266,11 @@ missingArtifacts.add( node.getArtifact() ); } } - + if ( missingArtifacts.size() > 0 ) { String message = "required artifacts missing:\n"; - for( Iterator i=missingArtifacts.iterator(); i.hasNext(); ) + for ( Iterator i = missingArtifacts.iterator(); i.hasNext(); ) { Artifact missingArtifact = (Artifact) i.next(); message += " " + missingArtifact.getId() + "\n"; Modified: maven/components/branches/maven-2.0.x/maven-core-it/README.txt URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/maven-core-it/README.txt?rev=375486&r1=375485&r2=375486&view=diff ============================================================================== --- maven/components/branches/maven-2.0.x/maven-core-it/README.txt (original) +++ maven/components/branches/maven-2.0.x/maven-core-it/README.txt Mon Feb 6 20:57:07 2006 @@ -244,6 +244,9 @@ it0089: Test that Checkstyle PackageNamesLoader.loadModuleFactory(..) method will complete as-is with the context classloader available to the plugin. + +it0092: Test that legacy repositories with legacy snapshots download correctly. + ------------------------------------------------------------------------------- - generated sources Modified: maven/components/branches/maven-2.0.x/maven-core-it/integration-tests.txt URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/maven-core-it/integration-tests.txt?rev=375486&r1=375485&r2=375486&view=diff ============================================================================== --- maven/components/branches/maven-2.0.x/maven-core-it/integration-tests.txt (original) +++ maven/components/branches/maven-2.0.x/maven-core-it/integration-tests.txt Mon Feb 6 20:57:07 2006 @@ -1,3 +1,4 @@ +it0092 it0089 it0088 it0087 Propchange: maven/components/branches/maven-2.0.x/maven-core-it/it0092/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Feb 6 20:57:07 2006 @@ -0,0 +1,2 @@ +log.txt +target