Package: groovy.grape.maven

## [Groovy] Class GrapeChecksumPolicyProvider

- groovy.grape.maven.GrapeChecksumPolicyProvider

- All Implemented Interfaces and Traits:
    ChecksumPolicyProvider

      @AutoFinal
      @CompileStatic
      class GrapeChecksumPolicyProvider
      extends Object
      implements ChecksumPolicyProvider

  Supplies the checksum policy Grape uses for remote artifact downloads.

  Maven Resolver's stock `CHECKSUM_POLICY_FAIL` rejects a download both when a published checksum does not match and when no checksum is published at all. Grape wants only the first of those: a mismatch means the bytes are not what the repository said they would be and must never reach the classpath, whereas a repository that simply publishes no `.sha1`/`.md5` is a common and legitimate situation, particularly for internal and older repositories.

  This provider therefore delegates to the stock org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider for every policy and wraps only the `fail` policy, relaxing its org.eclipse.aether.spi.connector.checksum.ChecksumPolicy#onNoMoreChecksums() response. The result matches the semantics the Ivy-backed engine has always had, so both Grape engines behave alike.

  Since:
    6.0.0

- - ### Constructor Summary

    Constructors
    Constructor and description
    `GrapeChecksumPolicyProvider(ChecksumPolicyProvider delegate)` Wraps the stock checksum policy provider.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `String` | `getEffectiveChecksumPolicy(RepositorySystemSession session, String policy1, String policy2)` Returns the least strict of the two supplied policies.
    `` | `ChecksumPolicy` | `newChecksumPolicy(RepositorySystemSession session, RemoteRepository repository, TransferResource resource, String policy)` Returns the policy for the given resource, relaxing `fail` to tolerate artifacts that publish no checksum.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### GrapeChecksumPolicyProvider(ChecksumPolicyProvider delegate)

      Wraps the stock checksum policy provider.

      Parameters:
        `delegate` - the stock provider whose policies are wrapped

  - ### Method Detail

    - #### @Override
      String getEffectiveChecksumPolicy(RepositorySystemSession session, String policy1, String policy2)

      Returns the least strict of the two supplied policies.

      Parameters:
        `session` - the session during which the request is made
        `policy1` - a policy to compare
        `policy2` - a policy to compare
      Returns:
        the least strict policy of the two

    - #### @Override
      ChecksumPolicy newChecksumPolicy(RepositorySystemSession session, RemoteRepository repository, TransferResource resource, String policy)

      Returns the policy for the given resource, relaxing `fail` to tolerate artifacts that publish no checksum.

      Parameters:
        `session` - the session during which the request is made
        `repository` - the repository hosting the resource
        `resource` - the resource the policy will be applied to
        `policy` - the identifier of the policy to apply
      Returns:
        the policy to apply, or `null` if checksums should be ignored