[ https://issues.apache.org/jira/browse/MNG-8081?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17841506#comment-17841506 ]
ASF GitHub Bot commented on MNG-8081: ------------------------------------- gnodet commented on code in PR #1446: URL: https://github.com/apache/maven/pull/1446#discussion_r1581850909 ########## maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java: ########## @@ -897,69 +904,91 @@ private List<org.apache.maven.api.model.Profile> interpolateActivations( List<org.apache.maven.api.model.Profile> profiles, DefaultProfileActivationContext context, DefaultModelProblemCollector problems) { - List<org.apache.maven.api.model.Profile> newProfiles = null; - for (int index = 0; index < profiles.size(); index++) { - org.apache.maven.api.model.Profile profile = profiles.get(index); - org.apache.maven.api.model.Activation activation = profile.getActivation(); - if (activation != null) { - org.apache.maven.api.model.ActivationFile file = activation.getFile(); - if (file != null) { - String oldExists = file.getExists(); - if (isNotEmpty(oldExists)) { + if (profiles.stream() + .map(org.apache.maven.api.model.Profile::getActivation) + .filter(Objects::nonNull) + .findFirst() + .isEmpty()) { Review Comment: use `anyMatch` here too ########## maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelBuilder.java: ########## @@ -377,69 +383,88 @@ private Model readEffectiveModel( private List<Profile> interpolateActivations( List<Profile> profiles, DefaultProfileActivationContext context, DefaultModelProblemCollector problems) { - List<Profile> newProfiles = null; - for (int index = 0; index < profiles.size(); index++) { - Profile profile = profiles.get(index); - Activation activation = profile.getActivation(); - if (activation != null) { - ActivationFile file = activation.getFile(); - if (file != null) { - String oldExists = file.getExists(); - if (isNotEmpty(oldExists)) { + if (profiles.stream() + .map(org.apache.maven.api.model.Profile::getActivation) + .filter(Objects::nonNull) + .findFirst() + .isEmpty()) { + return profiles; Review Comment: `.noneMatch(Objects::nonNull)` instead ? > default profile activation should consider available system and user > properties > ------------------------------------------------------------------------------- > > Key: MNG-8081 > URL: https://issues.apache.org/jira/browse/MNG-8081 > Project: Maven > Issue Type: Improvement > Components: Profiles > Affects Versions: 3.9.6, 4.0.0 > Reporter: Matthew Jason Benson > Assignee: Guillaume Nodet > Priority: Minor > Fix For: 3.9.7, 4.0.0, 4.0.0-beta-1 > > > As discussed in my open PR, my use case is to compare between environment > variables e.g.: > {code:java} > <activation> > <property> > <name>env.FOO</name> > <value>${env.BAR}</value> > </property> > </activation>{code} > Limiting the interpolation to user/system properties means that there is no > mindf*ck resulting from profile activation order, etc., and keeps this > request nonthreatening. -- This message was sent by Atlassian Jira (v8.20.10#820010)