[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-26 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
##
@@ -242,21 +274,17 @@ public DefaultGraphBuilder( BuildResumptionDataRepository 
buildResumptionDataRep
 {
 List result = projects;
 
-if ( !request.getExcludedProjects().isEmpty() )
+ProjectActivation projectActivation = request.getProjectActivation();
+Set requiredSelectors = 
projectActivation.getRequiredInactiveProjectSelectors();
+Set optionalSelectors = 
projectActivation.getOptionalInactiveProjectSelectors();
+if ( !requiredSelectors.isEmpty() || !optionalSelectors.isEmpty() )
 {
-File reactorDirectory = getReactorDirectory( request );
+Set excludedProjects = new HashSet<>( 
requiredSelectors.size() + optionalSelectors.size() );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, requiredSelectors, true ) );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, optionalSelectors, false ) );

Review comment:
   But only because you throw the exception, right?





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-26 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
##
@@ -176,38 +177,69 @@ public DefaultGraphBuilder( BuildResumptionDataRepository 
buildResumptionDataRep
 {
 List result = projects;
 
-if ( !request.getSelectedProjects().isEmpty() )
+ProjectActivation projectActivation = request.getProjectActivation();
+Set requiredSelectors = 
projectActivation.getRequiredActiveProjectSelectors();
+Set optionalSelectors = 
projectActivation.getOptionalActiveProjectSelectors();
+if ( !requiredSelectors.isEmpty() || !optionalSelectors.isEmpty() )
 {
-File reactorDirectory = getReactorDirectory( request );
+Set selectedProjects = new HashSet<>( 
requiredSelectors.size() + optionalSelectors.size() );
+selectedProjects.addAll( getProjectsBySelectors( request, 
projects, requiredSelectors, true ) );
+selectedProjects.addAll( getProjectsBySelectors( request, 
projects, optionalSelectors, false ) );
+
+// it can be empty when an optional project is missing from the 
reactor, fallback to returning all projects
+if ( !selectedProjects.isEmpty() )
+{
+result = new ArrayList<>( selectedProjects );
+
+result = includeAlsoMakeTransitively( result, request, graph );
+
+// Order the new list in the original order
+List sortedProjects = graph.getSortedProjects();
+result.sort( comparing( sortedProjects::indexOf ) );
+}
+}
+
+return result;
+}
 
-Collection selectedProjects = new LinkedHashSet<>();
+private Set getProjectsBySelectors( MavenExecutionRequest 
request, List projects,
+  Set 
projectSelectors, boolean required )
+throws MavenExecutionException
+{
+Set selectedProjects = new LinkedHashSet<>();
+File reactorDirectory = getReactorDirectory( request );
 
-for ( String selector : request.getSelectedProjects() )
+for ( String selector : projectSelectors )
+{
+Optional optSelectedProject = projects.stream()
+.filter( project -> isMatchingProject( project, selector, 
reactorDirectory ) )
+.findFirst();
+if ( !optSelectedProject.isPresent() )
 {
-MavenProject selectedProject = projects.stream()
-.filter( project -> isMatchingProject( project, 
selector, reactorDirectory ) )
-.findFirst()
-.orElseThrow( () -> new MavenExecutionException(
-"Could not find the selected project in the 
reactor: " + selector, request.getPom() ) );
-selectedProjects.add( selectedProject );
-
-List children = 
selectedProject.getCollectedProjects();
-if ( children != null )
+String message = "Could not find the selected project in the 
reactor: " + selector;
+if ( required )
+{
+throw new MavenExecutionException( message, 
request.getPom() );
+}
+else
 {
-selectedProjects.addAll( children );
+LOGGER.warn( message );

Review comment:
   Yes, makes sense for optional profiles only.





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-26 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
##
@@ -242,21 +274,17 @@ public DefaultGraphBuilder( BuildResumptionDataRepository 
buildResumptionDataRep
 {
 List result = projects;
 
-if ( !request.getExcludedProjects().isEmpty() )
+ProjectActivation projectActivation = request.getProjectActivation();
+Set requiredSelectors = 
projectActivation.getRequiredInactiveProjectSelectors();
+Set optionalSelectors = 
projectActivation.getOptionalInactiveProjectSelectors();
+if ( !requiredSelectors.isEmpty() || !optionalSelectors.isEmpty() )
 {
-File reactorDirectory = getReactorDirectory( request );
+Set excludedProjects = new HashSet<>( 
requiredSelectors.size() + optionalSelectors.size() );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, requiredSelectors, true ) );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, optionalSelectors, false ) );

Review comment:
   All four steps make sense here. Though, I am still confused about the 
"No goals here...".





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-26 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/execution/ProjectActivation.java
##
@@ -0,0 +1,173 @@
+package org.apache.maven.execution;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Predicate;
+
+import static java.util.stream.Collectors.toSet;
+
+/**
+ * Container for storing the request from the user to activate or de-activate 
certain projects and optionally fail the
+ * build if those projects do not exist.
+ */
+public class ProjectActivation
+{
+private final Map activations = new 
HashMap<>();
+
+/**
+ * Adds a project activation to the request.
+ * @param selector The selector of the project.

Review comment:
   Accepted.





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-16 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
##
@@ -242,21 +274,17 @@ public DefaultGraphBuilder( BuildResumptionDataRepository 
buildResumptionDataRep
 {
 List result = projects;
 
-if ( !request.getExcludedProjects().isEmpty() )
+ProjectActivation projectActivation = request.getProjectActivation();
+Set requiredSelectors = 
projectActivation.getRequiredInactiveProjectSelectors();
+Set optionalSelectors = 
projectActivation.getOptionalInactiveProjectSelectors();
+if ( !requiredSelectors.isEmpty() || !optionalSelectors.isEmpty() )
 {
-File reactorDirectory = getReactorDirectory( request );
+Set excludedProjects = new HashSet<>( 
requiredSelectors.size() + optionalSelectors.size() );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, requiredSelectors, true ) );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, optionalSelectors, false ) );

Review comment:
   Fixed the symptom. That's what I understand and it should carry a 
comment about that. One should explore the "No goal..." issue later.





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-16 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
##
@@ -242,21 +274,17 @@ public DefaultGraphBuilder( BuildResumptionDataRepository 
buildResumptionDataRep
 {
 List result = projects;
 
-if ( !request.getExcludedProjects().isEmpty() )
+ProjectActivation projectActivation = request.getProjectActivation();
+Set requiredSelectors = 
projectActivation.getRequiredInactiveProjectSelectors();
+Set optionalSelectors = 
projectActivation.getOptionalInactiveProjectSelectors();
+if ( !requiredSelectors.isEmpty() || !optionalSelectors.isEmpty() )
 {
-File reactorDirectory = getReactorDirectory( request );
+Set excludedProjects = new HashSet<>( 
requiredSelectors.size() + optionalSelectors.size() );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, requiredSelectors, true ) );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, optionalSelectors, false ) );

Review comment:
   I can't tell what the correct behavior would be, but not saying no goals 
given. I guess this is a separate discussion.





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-15 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
##
@@ -242,21 +274,17 @@ public DefaultGraphBuilder( BuildResumptionDataRepository 
buildResumptionDataRep
 {
 List result = projects;
 
-if ( !request.getExcludedProjects().isEmpty() )
+ProjectActivation projectActivation = request.getProjectActivation();
+Set requiredSelectors = 
projectActivation.getRequiredInactiveProjectSelectors();
+Set optionalSelectors = 
projectActivation.getOptionalInactiveProjectSelectors();
+if ( !requiredSelectors.isEmpty() || !optionalSelectors.isEmpty() )
 {
-File reactorDirectory = getReactorDirectory( request );
+Set excludedProjects = new HashSet<>( 
requiredSelectors.size() + optionalSelectors.size() );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, requiredSelectors, true ) );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, optionalSelectors, false ) );

Review comment:
   That's acceptable. I think we need to place a comment above that 
checking saying it is a workaround and create an issue with the actual cause 
for later analysis because as soon as this goes to master it will be forgotten!





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-15 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
##
@@ -242,21 +274,17 @@ public DefaultGraphBuilder( BuildResumptionDataRepository 
buildResumptionDataRep
 {
 List result = projects;
 
-if ( !request.getExcludedProjects().isEmpty() )
+ProjectActivation projectActivation = request.getProjectActivation();
+Set requiredSelectors = 
projectActivation.getRequiredInactiveProjectSelectors();
+Set optionalSelectors = 
projectActivation.getOptionalInactiveProjectSelectors();
+if ( !requiredSelectors.isEmpty() || !optionalSelectors.isEmpty() )
 {
-File reactorDirectory = getReactorDirectory( request );
+Set excludedProjects = new HashSet<>( 
requiredSelectors.size() + optionalSelectors.size() );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, requiredSelectors, true ) );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, optionalSelectors, false ) );

Review comment:
   But that would actually only take care of the symptom, wouldn't it?





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-15 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
##
@@ -242,21 +274,17 @@ public DefaultGraphBuilder( BuildResumptionDataRepository 
buildResumptionDataRep
 {
 List result = projects;
 
-if ( !request.getExcludedProjects().isEmpty() )
+ProjectActivation projectActivation = request.getProjectActivation();
+Set requiredSelectors = 
projectActivation.getRequiredInactiveProjectSelectors();
+Set optionalSelectors = 
projectActivation.getOptionalInactiveProjectSelectors();
+if ( !requiredSelectors.isEmpty() || !optionalSelectors.isEmpty() )
 {
-File reactorDirectory = getReactorDirectory( request );
+Set excludedProjects = new HashSet<>( 
requiredSelectors.size() + optionalSelectors.size() );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, requiredSelectors, true ) );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, optionalSelectors, false ) );

Review comment:
   but that would actually only take care of the symptom, wouldn't it?





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-15 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
##
@@ -242,21 +274,17 @@ public DefaultGraphBuilder( BuildResumptionDataRepository 
buildResumptionDataRep
 {
 List result = projects;
 
-if ( !request.getExcludedProjects().isEmpty() )
+ProjectActivation projectActivation = request.getProjectActivation();
+Set requiredSelectors = 
projectActivation.getRequiredInactiveProjectSelectors();
+Set optionalSelectors = 
projectActivation.getOptionalInactiveProjectSelectors();
+if ( !requiredSelectors.isEmpty() || !optionalSelectors.isEmpty() )
 {
-File reactorDirectory = getReactorDirectory( request );
+Set excludedProjects = new HashSet<>( 
requiredSelectors.size() + optionalSelectors.size() );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, requiredSelectors, true ) );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, optionalSelectors, false ) );

Review comment:
   But shouldn't that be a null sum game? "No goal ..." sounds wrong in any 
case, doesn't it?





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-14 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
##
@@ -242,21 +274,17 @@ public DefaultGraphBuilder( BuildResumptionDataRepository 
buildResumptionDataRep
 {
 List result = projects;
 
-if ( !request.getExcludedProjects().isEmpty() )
+ProjectActivation projectActivation = request.getProjectActivation();
+Set requiredSelectors = 
projectActivation.getRequiredInactiveProjectSelectors();
+Set optionalSelectors = 
projectActivation.getOptionalInactiveProjectSelectors();
+if ( !requiredSelectors.isEmpty() || !optionalSelectors.isEmpty() )
 {
-File reactorDirectory = getReactorDirectory( request );
+Set excludedProjects = new HashSet<>( 
requiredSelectors.size() + optionalSelectors.size() );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, requiredSelectors, true ) );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, optionalSelectors, false ) );

Review comment:
   OK...





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-14 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
##
@@ -242,21 +274,17 @@ public DefaultGraphBuilder( BuildResumptionDataRepository 
buildResumptionDataRep
 {
 List result = projects;
 
-if ( !request.getExcludedProjects().isEmpty() )
+ProjectActivation projectActivation = request.getProjectActivation();
+Set requiredSelectors = 
projectActivation.getRequiredInactiveProjectSelectors();
+Set optionalSelectors = 
projectActivation.getOptionalInactiveProjectSelectors();
+if ( !requiredSelectors.isEmpty() || !optionalSelectors.isEmpty() )
 {
-File reactorDirectory = getReactorDirectory( request );
+Set excludedProjects = new HashSet<>( 
requiredSelectors.size() + optionalSelectors.size() );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, requiredSelectors, true ) );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, optionalSelectors, false ) );

Review comment:
   Interesting, thanks. What will happen with `-pl !proj,+proj`?





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-14 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/execution/ProjectActivation.java
##
@@ -0,0 +1,173 @@
+package org.apache.maven.execution;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Predicate;
+
+import static java.util.stream.Collectors.toSet;
+
+/**
+ * Container for storing the request from the user to activate or de-activate 
certain projects and optionally fail the
+ * build if those projects do not exist.
+ */
+public class ProjectActivation
+{
+private final Map activations = new 
HashMap<>();
+
+/**
+ * Adds a project activation to the request.
+ * @param selector The selector of the project.

Review comment:
   Make it class level or maybe we have definition at maven-site?





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-14 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/execution/ProfileActivation.java
##
@@ -74,7 +44,7 @@ static ActivationSettings of( final boolean active, final 
boolean optional )
 @Deprecated
 public List getActiveProfiles()
 {
-return new ArrayList<>( getProfileIds( pa -> pa.active ) );
+return Collections.unmodifiableList( new ArrayList<>( getProfileIds( 
pa -> pa.active ) ) );

Review comment:
   Agreed.





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




[GitHub] [maven] michael-o commented on a change in pull request #446: [MNG-6511] - Optional project selection

2021-02-13 Thread GitBox


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



##
File path: 
maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
##
@@ -278,55 +290,61 @@
 MavenExecutionRequest setProfiles( List profiles );
 
 /**
- * @deprecated Use {@link #getProfileActivation()}.
+ * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
  */
 @Deprecated
 MavenExecutionRequest addActiveProfile( String profile );
 
 /**
- * @deprecated Use {@link #getProfileActivation()}.
+ * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
  */
 @Deprecated
 MavenExecutionRequest addActiveProfiles( List profiles );
 
 /**
- * @deprecated Use {@link #getProfileActivation()}.
+ * @deprecated Since Maven 4: use {@link #getProfileActivation()}.

Review comment:
   I think these profile-related changes should be a separate PR.

##
File path: 
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
##
@@ -242,21 +274,17 @@ public DefaultGraphBuilder( BuildResumptionDataRepository 
buildResumptionDataRep
 {
 List result = projects;
 
-if ( !request.getExcludedProjects().isEmpty() )
+ProjectActivation projectActivation = request.getProjectActivation();
+Set requiredSelectors = 
projectActivation.getRequiredInactiveProjectSelectors();
+Set optionalSelectors = 
projectActivation.getOptionalInactiveProjectSelectors();
+if ( !requiredSelectors.isEmpty() || !optionalSelectors.isEmpty() )
 {
-File reactorDirectory = getReactorDirectory( request );
+Set excludedProjects = new HashSet<>( 
requiredSelectors.size() + optionalSelectors.size() );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, requiredSelectors, true ) );
+excludedProjects.addAll( getProjectsBySelectors( request, 
projects, optionalSelectors, false ) );

Review comment:
   Call me blind, but this just looks like 
[here](https://github.com/apache/maven/pull/446/files#diff-5a5fe4cfc363538b43d7a3e89cc8b12b64d7ae0f4159caa45740405a299b6e3eR180-R187),
 but method names are opposite. Can you explain please?

##
File path: 
maven-core/src/main/java/org/apache/maven/execution/ActivationSettings.java
##
@@ -0,0 +1,58 @@
+package org.apache.maven.execution;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Describes whether something (a profile or a project) should be activated or 
not, and if that is required or optional.

Review comment:
   This is now completely decoupled from profiles or projects, I think the 
docs on the parens are superfluous.

##
File path: 
maven-core/src/main/java/org/apache/maven/execution/ProfileActivation.java
##
@@ -74,7 +44,7 @@ static ActivationSettings of( final boolean active, final 
boolean optional )
 @Deprecated
 public List getActiveProfiles()
 {
-return new ArrayList<>( getProfileIds( pa -> pa.active ) );
+return Collections.unmodifiableList( new ArrayList<>( getProfileIds( 
pa -> pa.active ) ) );

Review comment:
   This is likely nitpicking, but the previous impl did not return an 
immutable collection. I think since this deprecated anyway, it should not 
change its behavior.

##
File path: 
maven-core/src/main/java/org/apache/maven/execution/ProjectActivation.java
##
@@ -0,0 +1,173 @@
+package org.apache.maven.execution;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS"