Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6732

DefaultArtifactDescriptorReader.loadPom to check IGNORE_MISSING policy upon ArtifactTransferException

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.6.1
    • 4.0.x-candidate
    • Core
    • None

    Description

      Problem

      Sometimes Linkage Checker enforcer rule does not receive resolved artifact list because of a missing artifact even when the missing artifact is unused after Maven's dependency mediation.

      Background

      The enforcer rule fails to retrieve artifact list through DefaultProjectDependenciesResolver.resolve when applied to grpc-java-by-example/chat-example/chat-vaadin-client because of the missing xerces:xerces-impl:2.6.2, even though the artifact does not appear in the final dependency graph. The artifact does not appear in the graph because of Maven's dependency mediation.

      Artifact xerces:xerces-impl:2.6.2 is not published in Maven Central.

      In contrast, the enforcer rule can retrieve artifact list when applied to https://github.com/suztomo/spring-cloud-gcp/tree/v1.1.2-linkage-checker project even though it outputs "[WARNING] The POM for xerces:xerces-impl:jar:2.6.2 is missing, no dependency information available". The missing artifact does not appear in final dependency graph.

      https://github.com/GoogleCloudPlatform/cloud-opensource-java/issues/834

      Diagnosis

      Currently DefaultArtifactDescriptorReader.loadPom method checks "ArtifactDescriptorPolicy.IGNORE_MISSING" policy upon ArtifactNotFoundException. This allows DefaultProjectDependenciesResolver.resolve calls repoSystem.resolveDependencies to obtain partially resolved artifact list, rather than failing entirely, when there is a missing artifact (such as xerces:xerces-impl:2.6.2)

      However, when a retired Maven repository is involved (such as http://repository.codehaus.org/ ), DefaultArtifactDescriptorReader.loadPom gets an ArtifactTransferException and throws ArtifactDescriptorException without checking "ArtifactDescriptorPolicy.IGNORE_MISSING" policy (excerpt below), and thus DefaultProjectDependenciesResolver.resolve does not return partially resolved artifact list.

                  catch ( ArtifactResolutionException e )
                  {
                      if ( e.getCause() instanceof ArtifactNotFoundException )
                      {
                          missingDescriptor( session, trace, a, (Exception) e.getCause() );
                          if ( ( getPolicy( session, a, request ) & ArtifactDescriptorPolicy.IGNORE_MISSING ) != 0 )
                          {
                              return null;
                          }
                      }
                      result.addException( e );
                      throw new ArtifactDescriptorException( result );
                  }
      

      from DefaultArtifactDescriptorReader.java

      ArtifactNotFoundException is a special case of ArtifactTransferException.

      Example Project

      Example project to demonstrate the diagnosis: https://github.com/suztomo/maven-missing-artifact . In this example, even though module-b and module-c have the same dependency section, module-c fails to run Maven because of a repository section containing a retired repository URL.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              suztomo Tomo Suzuki
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h