Package: groovy.grape.ivy

## [Groovy] Class StrictLocalM2Resolver

- groovy.grape.ivy.StrictLocalM2Resolver

-     @CompileStatic
      class StrictLocalM2Resolver
      extends IBiblioResolver

  IBiblioResolver subclass that, for a local Maven repository (file://), validates that the primary artifact actually exists alongside the POM before reporting the descriptor as found. Without this, a half-populated local m2 entry (POM present, JAR missing — common after Apache release-vote staging workflows or partial Maven downloads) causes Ivy's chain to bind resolution to localm2 and then fail to download the missing JAR, never falling through to Maven Central. Override is on findIvyFileRef rather than getDependency to avoid grape-cache poisoning: returning null at descriptor-lookup time prevents Ivy from caching the descriptor with resolver=localm2. Strict behaviour is unconditional — if this resolver is in use, the check runs. Operators who don't want it can simply not declare this resolver in their ~/.groovy/grapeConfig.xml, dropping back to the stock Ivy <ibiblio> resolver. Strictness is still skipped automatically for snapshot revisions (Maven uses timestamp-suffixed filenames there), for non-m2-compatible configurations, and when the resolver root is not a file URL.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `StrictLocalM2Resolver()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `File` | `computeM2Dir(ModuleRevisionId mrid)` Visible for testing: compute the local m2 directory for a module revision based on the resolver's root.
    `` | `ResolvedResource` | `findIvyFileRef(DependencyDescriptor dd, ResolveData data)`
    `` | `static String` | `readPackaging(File pomFile)` Visible for testing: read the `<packaging>` element from a POM file.
    `` | `boolean` | `shouldRejectAsHalfPopulated(ModuleRevisionId mrid, File pomFile)` Visible for testing: decide whether to reject this localm2 lookup as half-populated.

- - ### Constructor Detail

    - #### StrictLocalM2Resolver()

  - ### Method Detail

    - #### File computeM2Dir(ModuleRevisionId mrid)

      Visible for testing: compute the local m2 directory for a module revision based on the resolver's root.

    - #### @Override
      ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data)

    - #### static String readPackaging(File pomFile)

      Visible for testing: read the `<packaging>` element from a POM file. Returns null if the element is absent or the file cannot be read.

    - #### boolean shouldRejectAsHalfPopulated(ModuleRevisionId mrid, File pomFile)

      Visible for testing: decide whether to reject this localm2 lookup as half-populated. Returns true iff the resolver is m2-compatible, the revision is not a snapshot, the resolver root is a file URL, and no primary artifact matching the POM's packaging exists alongside the POM.