Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 84D54200B5C for ; Thu, 11 Aug 2016 16:16:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 83BCF160A90; Thu, 11 Aug 2016 14:16:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AB5ED160AB5 for ; Thu, 11 Aug 2016 16:16:21 +0200 (CEST) Received: (qmail 90148 invoked by uid 500); 11 Aug 2016 14:16:20 -0000 Mailing-List: contact issues-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list issues@maven.apache.org Received: (qmail 89928 invoked by uid 99); 11 Aug 2016 14:16:20 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Aug 2016 14:16:20 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 8A3422C02A8 for ; Thu, 11 Aug 2016 14:16:20 +0000 (UTC) Date: Thu, 11 Aug 2016 14:16:20 +0000 (UTC) From: "Stefano Asperti (JIRA)" To: issues@maven.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (MENFORCER-257) Project enforcer-rules Class RequireActiveProfile - Modification proposal for active profile inheritance MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 11 Aug 2016 14:16:22 -0000 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 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 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)