michael-o commented on a change in pull request #429:
URL: https://github.com/apache/maven/pull/429#discussion_r567248901



##########
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, especially because you have used it already in line 534.




----------------------------------------------------------------
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


Reply via email to