maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Scholte (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (MENFORCER-257) Project enforcer-rules Class RequireActiveProfile - Modification proposal for active profile inheritance
Date Mon, 25 Sep 2017 21:42:00 GMT

     [ https://issues.apache.org/jira/browse/MENFORCER-257?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Robert Scholte updated MENFORCER-257:
-------------------------------------
    Description: 
Active profiles are not inherited  from a parent pom, following a proposal to handle this
issue:

From:
{code}
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;
    }
{code}
To:
{code}
@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;
    } 
{code}

  was:
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;
    }    


> Project enforcer-rules Class RequireActiveProfile - Modification proposal for active
profile inheritance
> --------------------------------------------------------------------------------------------------------
>
>                 Key: MENFORCER-257
>                 URL: https://issues.apache.org/jira/browse/MENFORCER-257
>             Project: Maven Enforcer Plugin
>          Issue Type: Improvement
>          Components: Plugin
>    Affects Versions: 1.4.1
>            Reporter: Stefano Asperti
>            Priority: Minor
>
> Active profiles are not inherited  from a parent pom, following a proposal to handle
this issue:
> From:
> {code}
> 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;
>     }
> {code}
> To:
> {code}
> @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;
>     } 
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message