[
https://issues.apache.org/jira/browse/MENFORCER-257?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Robert Scholte updated MENFORCER-257:
-------------------------------------
Summary: RequireActiveProfile should respect inherited activated profiles
(was: Project enforcer-rules Class RequireActiveProfile - Modification proposal
for active profile inheritance)
> 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
> 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)