MartinKanters commented on a change in pull request #429: URL: https://github.com/apache/maven/pull/429#discussion_r565133975
########## File path: maven-core/src/main/java/org/apache/maven/DefaultMaven.java ########## @@ -493,25 +508,88 @@ private void validatePrerequisitesForNonMavenPluginProjects( List<MavenProject> } } - private void validateActivatedProfiles( List<MavenProject> projects, List<String> activeProfileIds ) + /** + * Get all profiles that are detected in either the projects, any parent of the projects or the settings. + * @param session The Maven session + * @return A {@link Set} of profile identifiers, never {@code null}. + */ + private Set<String> getAllProfiles( MavenSession session ) { - Collection<String> notActivatedProfileIds = new LinkedHashSet<>( activeProfileIds ); - - for ( MavenProject project : projects ) + final Set<MavenProject> projectsIncludingParents = new HashSet<>(); + for ( MavenProject project : session.getProjects() ) { - for ( List<String> profileIds : project.getInjectedProfileIds().values() ) + boolean isAdded = projectsIncludingParents.add( project ); + MavenProject parent = project.getParent(); + while ( isAdded && parent != null ) { - notActivatedProfileIds.removeAll( profileIds ); + isAdded = projectsIncludingParents.add( parent ); + parent = parent.getParent(); } } - for ( String notActivatedProfileId : notActivatedProfileIds ) + final Stream<String> projectProfiles = projectsIncludingParents.stream() + .map( MavenProject::getModel ) + .map( Model::getProfiles ) + .flatMap( Collection::stream ) + .map( Profile::getId ); + final Stream<String> settingsProfiles = session.getSettings().getProfiles().stream() + .map( IdentifiableBase::getId ); Review comment: I agree that `IdentifiableBase` is not favorable in terms of readability. I think the reason why we took this is because the Profile on this line is from another package so we will have to use the fqn then or not the method reference: - `org.apache.maven.settings.Profile::getId` - `profile -> profile.getId()` I'll go for the former, but am interested in hearing your opinion. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org