You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Stefano Asperti (JIRA)" <ji...@apache.org> on 2016/08/11 14:16:20 UTC
[jira] [Created] (MENFORCER-257) Project enforcer-rules Class
RequireActiveProfile - Modification proposal for active profile inheritance
Stefano Asperti created MENFORCER-257:
-----------------------------------------
Summary: 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
Fix For: 1.4.2
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;
}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)