You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Robert Scholte (Jira)" <ji...@apache.org> on 2021/05/26 18:24:00 UTC
[jira] [Assigned] (MENFORCER-257) RequireActiveProfile should
respect inherited activated profiles
[ https://issues.apache.org/jira/browse/MENFORCER-257?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Robert Scholte reassigned MENFORCER-257:
----------------------------------------
Assignee: Robert Scholte
> RequireActiveProfile should respect inherited activated profiles
> ----------------------------------------------------------------
>
> 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
> Assignee: Robert Scholte
> 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
(v8.3.4#803005)