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

Loss of profile information in workaround for MNG-4900

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 3.3.9, 3.5.0
    • None
    • Core
    • Windows
    • Patch

    Description

      Please, forgive me not providing example project reproducing the bug.
      It's very tricky and hopefully not necessary, since the 1-line fix is provided.

      Using profiles together with maven-javadoc-plugin results in the following problem:

      • Configuration from active profiles is not considered during dependency resolution started problematically from the maven-javadoc-plugin.

      This leads to unpredictable behavior, that is somewhat hard to reproduce.

      Here is the technical inside and the 1-line fix:

      In the DefaultMavenProjectBuilder.toRequest():

      if ( profileManager != null ) {
         ...
      } else {
        ...
        /*
         * MNG-4900: Hack to workaround deficiency of legacy API which makes it impossible for plugins to access the
         * global profile manager which is required to build a POM like a CLI invocation does. Failure to consider
         * the activated profiles can cause repo declarations to be lost which in turn will result in artifact
         * resolution failures, in particular when using the enhanced local repo which guards access to local files
         * based on the configured remote repos.
         */
          request.setActiveProfileIds( req.getActiveProfiles() );
          request.setInactiveProfileIds( req.getInactiveProfiles() );
      }
      

      Here we copy active and inactive profile ids, but we don't copy the list of all profile ids. Missing line:

                          request.setProfiles( req.getProfiles() );
      

      As the result the method DefaultProfileManager.getActiveProfiles() always returns an empty list:

        List<Profile> activeProfiles = new ArrayList<>( profiles.size() );
        for ( Profile profile : profiles ) {
           ...
        }
        return activeProfiles;
      

      "profiles" here is empty, since it wasn't copied together with "getActiveProfiles()" and "getInactiveProfiles()"

      Adding the missing line fixes the problem.

      Attachments

        1. MNG-6130.patch
          0.8 kB
          Boris Brodski

        Issue Links

          Activity

            People

              Unassigned Unassigned
              boris_brodski Boris Brodski
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: