You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jd...@apache.org on 2005/06/20 20:53:54 UTC

svn commit: r191536 - in /maven/components/trunk: maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/ maven-artifact/src/main/java/org/apache/maven/artifact/ maven-artifact/src/main/java/org/apache/maven/artifact/manager/ maven-artifact/src...

Author: jdcasey
Date: Mon Jun 20 11:53:53 2005
New Revision: 191536

URL: http://svn.apache.org/viewcvs?rev=191536&view=rev
Log:
Resolving issue: MNG-339

o Added checksumPolicy to artifact repository construction, which meant changing all the places where the factory was called.

o Added two command-line switches (-C=strict-checksum-checking, -c=lax-checksum-checking, or warning)

o Added checksum policy to all repository definitions (profiles.mdo, settings.mdo, maven.mdo)

o Changed the maven-artifact-ant stuff to use a Repository definition with checksumPolicy added to it

NOTE: I just realized that I haven't touched the inheritance/conversion of repository stuff from profiles/settings.xml to the model. I'll do this, and commit the additional changes.

Currently, the default checksum policy is to warn, since there are still bad checksums out there that prevent bootstrapping. Once we chase these down, we can change to default-strict checking. When verifying checksums, SHA-1 is attempted first, with MD5 acting as a backup verification method. If the checksum verification fails legitimately (not related to the process of retrieving/reading the checksum file), then the verification process is repeated ONCE ONLY.


Modified:
    maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
    maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java
    maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/ChecksumFailedException.java
    maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
    maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java
    maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java
    maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java
    maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
    maven/components/trunk/maven-model/maven.mdo
    maven/components/trunk/maven-profile/profiles.mdo
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java
    maven/components/trunk/maven-settings/settings.mdo

Modified: maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java?rev=191536&r1=191535&r2=191536&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java (original)
+++ maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java Mon Jun 20 11:53:53 2005
@@ -18,6 +18,7 @@
 
 import org.apache.maven.artifact.manager.WagonManager;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -31,6 +32,7 @@
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
 import org.codehaus.plexus.PlexusContainerException;
+import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.embed.Embedder;
 import org.codehaus.plexus.util.IOUtil;
@@ -96,17 +98,34 @@
             manager.addProxy( proxy.getType(), proxy.getHost(), proxy.getPort(), proxy.getUserName(),
                               proxy.getPassword(), proxy.getNonProxyHosts() );
         }
-
+        
+        ArtifactRepositoryFactory repositoryFactory = null;
+        
         ArtifactRepository artifactRepository;
-        if ( repository.getSnapshotPolicy() != null )
+        
+        try
         {
-            artifactRepository = new ArtifactRepository( "remote", repository.getUrl(), repositoryLayout,
-                                                         repository.getSnapshotPolicy() );
+            repositoryFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
+            
+            String snapshotPolicy = repository.getSnapshotPolicy();
+            String checksumPolicy = repository.getChecksumPolicy();
+            
+            artifactRepository = repositoryFactory.createArtifactRepository( "remote", repository.getUrl(), 
+                                                                             repositoryLayout, snapshotPolicy, 
+                                                                             checksumPolicy );
         }
-        else
+        finally
         {
-            artifactRepository = new ArtifactRepository( "remote", repository.getUrl(), repositoryLayout );
+            try
+            {
+                getEmbedder().release( repositoryFactory );
+            }
+            catch ( ComponentLifecycleException e )
+            {
+                // TODO: Warn the user, or not?
+            }
         }
+
         return artifactRepository;
     }
 

Modified: maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java?rev=191536&r1=191535&r2=191536&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java (original)
+++ maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java Mon Jun 20 11:53:53 2005
@@ -30,7 +30,9 @@
     private Authentication authentication;
 
     private String snapshotPolicy;
-
+    
+    private String checksumPolicy;
+    
     private Proxy proxy;
 
     public String getUrl()
@@ -71,5 +73,15 @@
     public Proxy getProxy()
     {
         return proxy;
+    }
+
+    public String getChecksumPolicy()
+    {
+        return checksumPolicy;
+    }
+
+    public void setChecksumPolicy( String checksumPolicy )
+    {
+        this.checksumPolicy = checksumPolicy;
     }
 }

Modified: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/ChecksumFailedException.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/ChecksumFailedException.java?rev=191536&r1=191535&r2=191536&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/ChecksumFailedException.java (original)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/ChecksumFailedException.java Mon Jun 20 11:53:53 2005
@@ -30,4 +30,9 @@
     {
         super( s );
     }
+    
+    public ChecksumFailedException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
 }

Modified: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java?rev=191536&r1=191535&r2=191536&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java (original)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java Mon Jun 20 11:53:53 2005
@@ -25,6 +25,7 @@
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.UnsupportedProtocolException;
 import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.WagonException;
 import org.apache.maven.wagon.authentication.AuthenticationException;
 import org.apache.maven.wagon.authentication.AuthenticationInfo;
 import org.apache.maven.wagon.authorization.AuthorizationException;
@@ -77,8 +78,8 @@
         }
         catch ( ComponentLookupException e )
         {
-            throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: " +
-                                                    protocol, e );
+            throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: "
+                + protocol, e );
         }
 
         return wagon;
@@ -98,7 +99,7 @@
     }
 
     private void putRemoteFile( ArtifactRepository repository, File source, String remotePath,
-                                TransferListener downloadMonitor )
+                               TransferListener downloadMonitor )
         throws TransferFailedException
     {
         String protocol = repository.getProtocol();
@@ -241,7 +242,7 @@
     }
 
     private void getRemoteFile( ArtifactRepository repository, File destination, String remotePath,
-                                TransferListener downloadMonitor )
+                               TransferListener downloadMonitor )
         throws TransferFailedException, ResourceDoesNotExistException, ChecksumFailedException
     {
         // TODO: better excetpions - transfer failed is not enough?
@@ -270,11 +271,15 @@
         }
 
         // TODO: configure on repository
-        ChecksumObserver checksumObserver;
+        ChecksumObserver md5ChecksumObserver;
+        ChecksumObserver sha1ChecksumObserver;
         try
         {
-            checksumObserver = new ChecksumObserver( "MD5" );
-            wagon.addTransferListener( checksumObserver );
+            md5ChecksumObserver = new ChecksumObserver( "MD5" );
+            wagon.addTransferListener( md5ChecksumObserver );
+
+            sha1ChecksumObserver = new ChecksumObserver( "SHA-1" );
+            wagon.addTransferListener( sha1ChecksumObserver );
         }
         catch ( NoSuchAlgorithmException e )
         {
@@ -288,36 +293,92 @@
         {
             wagon.connect( repository, getAuthenticationInfo( repository.getId() ), getProxy( protocol ) );
 
-            // This should take care of creating destination directory now on
-            wagon.get( remotePath, temp );
-
-            try
+            boolean firstRun = true;
+            boolean retry = false;
+            
+            // this will run at most twice. The first time, the firstRun flag is turned off, and if the retry flag
+            // is set on the first run, it will be turned off and not re-set on the second try. This is because the
+            // only way the retry flag can be set is if ( firstRun == true ).
+            while( firstRun || retry )
             {
-                // grab it first, because it's about to change...
-                String actualChecksum = checksumObserver.getActualChecksum();
-
-                File checksumFile = new File( destination + ".md5" );
-                wagon.get( remotePath + ".md5", checksumFile );
-
-                String expectedChecksum = FileUtils.fileRead( checksumFile );
-                if ( !expectedChecksum.equals( actualChecksum ) )
+                // reset the retry flag.
+                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 )
                 {
-                    getLogger().warn(
-                        "*** CHECKSUM MISMATCH - currently disabled fail due to bad repository checksums ***" );
+                    wagon.removeTransferListener( downloadMonitor );
+                }
 
-                    // TODO: optionally retry?
-                    /*                   throw new ChecksumFailedException( "Checksum failed on download: local = '" + actualChecksum +
-                     "'; remote = '" + expectedChecksum + "'" );
-                     */
+                // try to verify the SHA-1 checksum for this file.
+                try
+                {
+                    verifyChecksum( sha1ChecksumObserver, destination, remotePath, ".sha1", wagon );
+                }
+                catch ( WagonException sha1TryException )
+                {
+                    // 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 ( sha1TryException instanceof ChecksumFailedException )
+                    {
+                        // if this is the second try, handle the problem...otherwise, let it try again.
+                        if( firstRun )
+                        {
+                            retry = true;
+                        }
+                        else
+                        {
+                            handleChecksumFailure( repository, sha1TryException.getMessage(), sha1TryException.getCause() );
+                        }
+                    }
+                    // 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.
+                    else
+                    {
+                        try
+                        {
+                            verifyChecksum( md5ChecksumObserver, destination, remotePath, ".md5", wagon );
+                        }
+                        catch ( WagonException md5TryException )
+                        {
+                            // 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( md5TryException instanceof ChecksumFailedException )
+                            {
+                                // only retry once.
+                                if( firstRun )
+                                {
+                                    retry = true;
+                                }
+                                else
+                                {
+                                    handleChecksumFailure( repository, md5TryException.getMessage(), md5TryException.getCause() );
+                                }
+                            }
+                            // otherwise, this was a failed transfer, and we don't want to retry.
+                            else
+                            {
+                                handleChecksumFailure( repository, "Error retrieving checksum file for " + destination, md5TryException );
+                            }
+                        }
+                    }
+                }
+                finally
+                {
+                    // reinstate the download monitor...
+                    if ( downloadMonitor != null )
+                    {
+                        wagon.addTransferListener( downloadMonitor );
+                    }
+                    
+                    // unset the firstRun flag, so we don't get caught in an infinite loop...
+                    firstRun = false;
                 }
-            }
-            catch ( ResourceDoesNotExistException e )
-            {
-                getLogger().warn( "No checksum exists - assuming a valid download" );
-            }
-            catch ( IOException e )
-            {
-                getLogger().error( "Unable to read checksum - assuming a valid download", e );
             }
         }
         catch ( ConnectionException e )
@@ -365,6 +426,47 @@
         }
     }
 
+    private void handleChecksumFailure( ArtifactRepository repository, String message, Throwable cause )
+        throws ChecksumFailedException
+    {
+        if( ArtifactRepository.CHECKSUM_POLICY_FAIL.equals( repository.getChecksumPolicy() ) )
+        {
+            throw new ChecksumFailedException( message, cause );
+        }
+        else
+        {
+            getLogger().warn( "*** CHECKSUM FAILED - " + message + " - IGNORING" );
+        }
+    }
+
+    private void verifyChecksum( ChecksumObserver checksumObserver, File destination, String remotePath,
+                                String checksumFileExtension, Wagon wagon )
+        throws WagonException
+    {
+        try
+        {
+            // grab it first, because it's about to change...
+            String actualChecksum = checksumObserver.getActualChecksum();
+
+            File checksumFile = new File( destination + ".sha1" );
+            wagon.get( remotePath + ".sha1", checksumFile );
+
+            String expectedChecksum = FileUtils.fileRead( checksumFile );
+            if ( !expectedChecksum.equals( actualChecksum ) )
+            {
+                //                getLogger().warn(
+                //                    "*** CHECKSUM MISMATCH - currently disabled fail due to bad repository checksums ***" );
+
+                throw new ChecksumFailedException( "Checksum failed on download: local = '" + actualChecksum
+                    + "'; remote = '" + expectedChecksum + "'" );
+            }
+        }
+        catch ( IOException e )
+        {
+            throw new TransferFailedException( "Invalid SHA-1 checksum file", e );
+        }
+    }
+
     private void disconnectWagon( Wagon wagon )
     {
         try
@@ -416,8 +518,7 @@
      * property format: <code>*.foo.com|localhost</code>.
      * @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,
-                          String nonProxyHosts )
+    public void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts )
     {
         ProxyInfo proxyInfo = new ProxyInfo();
         proxyInfo.setHost( host );
@@ -445,7 +546,7 @@
     }
 
     public void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey,
-                                       String passphrase )
+                                      String passphrase )
     {
         AuthenticationInfo authInfo = new AuthenticationInfo();
 

Modified: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java?rev=191536&r1=191535&r2=191536&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java (original)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java Mon Jun 20 11:53:53 2005
@@ -32,6 +32,8 @@
     extends Repository
 {
     private final String snapshotPolicy;
+    
+    private final String checksumPolicy;
 
     private final ArtifactRepositoryLayout layout;
 
@@ -42,19 +44,29 @@
     public static final String SNAPSHOT_POLICY_DAILY = "daily";
 
     public static final String SNAPSHOT_POLICY_INTERVAL = "interval";
+    
+    public static final String CHECKSUM_POLICY_FAIL = "fail";
+    
+    public static final String CHECKSUM_POLICY_WARN = "warn";
+    
+    public static final String CHECKSUM_ALGORITHM_SHA1 = "SHA-1";
+    
+    public static final String CHECKSUM_ALGORITHM_MD5 = "MD5";
 
     public ArtifactRepository( String id, String url, ArtifactRepositoryLayout layout )
     {
-        this( id, url, layout, SNAPSHOT_POLICY_NEVER );
+        this( id, url, layout, SNAPSHOT_POLICY_NEVER, CHECKSUM_POLICY_WARN );
     }
 
-    public ArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, String snapshotPolicy )
+    public ArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, String snapshotPolicy, String checksumPolicy )
     {
         super( id, url );
 
         this.layout = layout;
 
         this.snapshotPolicy = snapshotPolicy;
+        
+        this.checksumPolicy = checksumPolicy;
     }
 
     public String pathOf( Artifact artifact )
@@ -71,9 +83,19 @@
     {
         return snapshotPolicy;
     }
-
+    
+    public String getChecksumPolicy()
+    {
+        return checksumPolicy;
+    }
+    
+    public boolean failOnChecksumMismatch()
+    {
+        return CHECKSUM_POLICY_FAIL.equals( checksumPolicy );
+    }
+    
     public ArtifactRepository createMirror( Repository mirror )
     {
-        return new ArtifactRepository( mirror.getId(), mirror.getUrl(), layout, snapshotPolicy );
+        return new ArtifactRepository( mirror.getId(), mirror.getUrl(), layout, snapshotPolicy, checksumPolicy );
     }
 }

Modified: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java?rev=191536&r1=191535&r2=191536&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java (original)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java Mon Jun 20 11:53:53 2005
@@ -28,7 +28,9 @@
 
     public ArtifactRepository createArtifactRepository( String id, String url,
                                                         ArtifactRepositoryLayout repositoryLayout,
-                                                        String snapshotPolicy );
+                                                        String snapshotPolicy, String checksumPolicy );
 
     void setGlobalSnapshotPolicy( String snapshotPolicy );
+    
+    void setGlobalChecksumPolicy( String checksumPolicy );
 }

Modified: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java?rev=191536&r1=191535&r2=191536&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java (original)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java Mon Jun 20 11:53:53 2005
@@ -28,19 +28,40 @@
 {
     // TODO: use settings?
     private String globalSnapshotPolicy = null;
+    
+    private String globalChecksumPolicy = null;
 
     public ArtifactRepository createArtifactRepository( String id, String url,
                                                         ArtifactRepositoryLayout repositoryLayout,
-                                                        String snapshotPolicy )
+                                                        String snapshotPolicy, String checksumPolicy )
     {
         ArtifactRepository repo = null;
+        
+        String snapPolicy = snapshotPolicy;
 
         if ( globalSnapshotPolicy != null )
         {
-            snapshotPolicy = globalSnapshotPolicy;
+            snapPolicy = globalSnapshotPolicy;
         }
-
-        repo = new ArtifactRepository( id, url, repositoryLayout, snapshotPolicy );
+        
+        if ( snapPolicy == null )
+        {
+            snapPolicy = ArtifactRepository.SNAPSHOT_POLICY_NEVER;
+        }
+        
+        String csumPolicy = checksumPolicy;
+        
+        if ( globalChecksumPolicy != null )
+        {
+            csumPolicy = globalChecksumPolicy;
+        }
+        
+        if ( csumPolicy == null )
+        {
+            csumPolicy = ArtifactRepository.CHECKSUM_POLICY_FAIL;
+        }
+        
+        repo = new ArtifactRepository( id, url, repositoryLayout, snapPolicy, csumPolicy );
 
         return repo;
     }
@@ -48,5 +69,10 @@
     public void setGlobalSnapshotPolicy( String snapshotPolicy )
     {
         this.globalSnapshotPolicy = snapshotPolicy;
+    }
+    
+    public void setGlobalChecksumPolicy( String checksumPolicy )
+    {
+        this.globalChecksumPolicy = checksumPolicy;
     }
 }

Modified: maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java?rev=191536&r1=191535&r2=191536&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java (original)
+++ maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java Mon Jun 20 11:53:53 2005
@@ -90,7 +90,7 @@
         ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
                                                                                  "legacy" );
 
-        ArtifactRepository repository = new ArtifactRepository( "test", "file://" + f.getPath(), repoLayout );
+        ArtifactRepository repository = new ArtifactRepository( "test", "file://" + f.getPath(), repoLayout, ArtifactRepository.SNAPSHOT_POLICY_NEVER, ArtifactRepository.CHECKSUM_POLICY_WARN );
 
         return repository;
     }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java?rev=191536&r1=191535&r2=191536&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java Mon Jun 20 11:53:53 2005
@@ -392,6 +392,20 @@
         {
             artifactRepositoryFactory.setGlobalSnapshotPolicy( ArtifactRepository.SNAPSHOT_POLICY_ALWAYS );
         }
+        
+        if ( commandLine.hasOption( CLIManager.CHECKSUM_FAILURE_POLICY ) )
+        {
+            System.out.println( "+ Enabling strict checksum verification on all artifact downloads.");
+            
+            artifactRepositoryFactory.setGlobalChecksumPolicy( ArtifactRepository.CHECKSUM_POLICY_FAIL );
+        }
+        else if ( commandLine.hasOption( CLIManager.CHECKSUM_WARNING_POLICY ) )
+        {
+            System.out.println( "+ Disabling strict checksum verification on all artifact downloads.");
+            
+            artifactRepositoryFactory.setGlobalChecksumPolicy( ArtifactRepository.CHECKSUM_POLICY_WARN );
+        }
+        
         return localRepository;
     }
 
@@ -508,6 +522,10 @@
         public static final char ACTIVATE_PROFILES = 'P';
         
         public static final char FORCE_PLUGIN_UPDATES = 'F';
+        
+        public static final char CHECKSUM_FAILURE_POLICY = 'C';
+        
+        public static final char CHECKSUM_WARNING_POLICY = 'c';
 
         public CLIManager()
         {
@@ -536,6 +554,8 @@
                 "Comma-delimited list of profiles to activate").hasArg().create( ACTIVATE_PROFILES ) );
             options.addOption( OptionBuilder.withLongOpt( "batch-mode" ).withDescription( "Run in non-interactive (batch) mode" ).create( BATCH_MODE ) );
             options.addOption( OptionBuilder.withLongOpt( "update-plugins" ).withDescription( "Force upToDate check for any relevant registered plugins" ).create( FORCE_PLUGIN_UPDATES ) );
+            options.addOption( OptionBuilder.withLongOpt( "strict-checksums" ).withDescription( "Fail the build if checksums don't match" ).create( CHECKSUM_FAILURE_POLICY ) );
+            options.addOption( OptionBuilder.withLongOpt( "lax-checksums" ).withDescription( "Warn if checksums don't match" ).create( CHECKSUM_WARNING_POLICY ) );
         }
 
         public CommandLine parse( String[] args )

Modified: maven/components/trunk/maven-model/maven.mdo
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-model/maven.mdo?rev=191536&r1=191535&r2=191536&view=diff
==============================================================================
--- maven/components/trunk/maven-model/maven.mdo (original)
+++ maven/components/trunk/maven-model/maven.mdo Mon Jun 20 11:53:53 2005
@@ -1999,6 +1999,13 @@
           <type>String</type>
           <defaultValue>default</defaultValue>
         </field>
+        <field>
+          <name>checksumPolicy</name>
+          <version>4.0.0</version>
+          <description>What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are "fail" or "warn"</description>
+          <type>String</type>
+          <defaultValue>warn</defaultValue>
+        </field>
       </fields>
       <codeSegments>
         <codeSegment>

Modified: maven/components/trunk/maven-profile/profiles.mdo
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-profile/profiles.mdo?rev=191536&r1=191535&r2=191536&view=diff
==============================================================================
--- maven/components/trunk/maven-profile/profiles.mdo (original)
+++ maven/components/trunk/maven-profile/profiles.mdo Mon Jun 20 11:53:53 2005
@@ -181,6 +181,13 @@
           <type>String</type>
           <defaultValue>default</defaultValue>
         </field>
+        <field>
+          <name>checksumPolicy</name>
+          <version>1.0.0</version>
+          <description>What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are "fail" or "warn"</description>
+          <type>String</type>
+          <defaultValue>warn</defaultValue>
+        </field>
       </fields>
       <codeSegments>
         <codeSegment>

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java?rev=191536&r1=191535&r2=191536&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java Mon Jun 20 11:53:53 2005
@@ -66,9 +66,12 @@
             String id = repo.getId();
             String url = repo.getUrl();
             String snapshotPolicy = repo.getSnapshotPolicy();
+            String checksumPolicy = repo.getChecksumPolicy();
+            
             // TODO: make this a map inside the factory instead, so no lookup needed
             ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container );
-            return artifactRepositoryFactory.createArtifactRepository( id, url, layout, snapshotPolicy );
+            
+            return artifactRepositoryFactory.createArtifactRepository( id, url, layout, snapshotPolicy, checksumPolicy );
         }
         else
         {

Modified: maven/components/trunk/maven-settings/settings.mdo
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-settings/settings.mdo?rev=191536&r1=191535&r2=191536&view=diff
==============================================================================
--- maven/components/trunk/maven-settings/settings.mdo (original)
+++ maven/components/trunk/maven-settings/settings.mdo Mon Jun 20 11:53:53 2005
@@ -612,6 +612,13 @@
           <type>String</type>
           <defaultValue>default</defaultValue>
         </field>
+        <field>
+          <name>checksumPolicy</name>
+          <version>1.0.0</version>
+          <description>What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are "fail" or "warn"</description>
+          <type>String</type>
+          <defaultValue>warn</defaultValue>
+        </field>
       </fields>
       <codeSegments>
         <codeSegment>



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