Uploaded image for project: 'Maven Enforcer Plugin'
  1. Maven Enforcer Plugin
  2. MENFORCER-257

RequireActiveProfile should respect inherited activated profiles

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.4.1
    • 3.0.0
    • Plugin
    • None

    Description

      Active profiles are not inherited from a parent pom, following a proposal to handle this issue:

      From:

      protected boolean isProfileActive( MavenProject project, String profileName )
          {
              @SuppressWarnings( "unchecked" )
              List<Profile> activeProfiles = project.getActiveProfiles();
              if ( activeProfiles != null && !activeProfiles.isEmpty() )
              {
                  for ( Profile profile : activeProfiles )
                  {
                      if ( profile.getId().equals( profileName ) )
                      {
                          return true;
                      }
                  }
              }
      
              return false;
          }
      

      To:

      @SuppressWarnings("unchecked")
          protected boolean isProfileActive(MavenProject project, String profileName) {
              boolean active = false;
              while(!active && project != null) {
                  active = isProfileActive(project.getActiveProfiles(), profileName);
                  project = project.getParent();
              }
              return active;
          }
      
          protected boolean isProfileActive(List<Profile> activeProfiles, String profileName) {
              if (activeProfiles != null && !activeProfiles.isEmpty()) {
                  for (Profile profile : activeProfiles) {
                      if (profile.getId().equals(profileName)) {
                          return true;
                      }
                  }
              }
              return false;
          } 
      

      Attachments

        Issue Links

          Activity

            People

              rfscholte Robert Scholte
              sasperti Stefano Asperti
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: