You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/06/20 08:09:02 UTC

[GitHub] [maven] michael-o commented on a diff in pull request #701: [MNG-7443] Make logging consistent between optional profiles and projects

michael-o commented on code in PR #701:
URL: https://github.com/apache/maven/pull/701#discussion_r901366846


##########
maven-core/src/main/java/org/apache/maven/DefaultMaven.java:
##########
@@ -132,6 +137,7 @@ public DefaultMaven(
         this.buildResumptionAnalyzer = buildResumptionAnalyzer;
         this.buildResumptionDataRepository = buildResumptionDataRepository;
         this.superPomProvider = superPomProvider;
+        this.projectSelector = new ProjectSelector();

Review Comment:
   This isn't subject to DI?



##########
maven-core/src/main/java/org/apache/maven/DefaultMaven.java:
##########
@@ -631,6 +638,21 @@ private void validateRequiredProfiles( MavenSession session, ProfileActivation p
         }
     }
 
+    /**
+     * Check whether any of the requested optional projects were not activated or deactivated.
+     * @param request the {@link MavenExecutionRequest}.
+     * @param session the {@link MavenSession}.
+     */
+    private void validateOptionalProjects( MavenExecutionRequest request, MavenSession session )
+    {
+        final ProjectActivation projectActivation = request.getProjectActivation();
+        final Set<String> allOptionalSelectors = Sets.union( projectActivation.getOptionalActiveProjectSelectors(),
+                projectActivation.getOptionalInactiveProjectSelectors() );
+        // We intentionally ignore the results of this method.
+        // As a side effect it will log the optional projects that could not be resolve.

Review Comment:
   ...not be resolved.



##########
maven-core/src/main/java/org/apache/maven/graph/ProjectSelector.java:
##########
@@ -0,0 +1,143 @@
+package org.apache.maven.graph;
+
+/*
+ * 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 org.apache.maven.MavenExecutionException;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.project.MavenProject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+
+import static com.google.common.base.Strings.isNullOrEmpty;
+
+public final class ProjectSelector
+{
+    private static final Logger LOGGER = LoggerFactory.getLogger( ProjectSelector.class );
+
+    public Set<MavenProject> getRequiredProjectsBySelectors( MavenExecutionRequest request, List<MavenProject> projects,
+                                                             Set<String> projectSelectors )
+            throws MavenExecutionException
+    {
+        Set<MavenProject> selectedProjects = new LinkedHashSet<>();
+        File baseDirectory = !isNullOrEmpty( request.getBaseDirectory() )
+                ? new File( request.getBaseDirectory() ) : null;

Review Comment:
   Since this is used multiple times, would it make sense to move toa private method?



##########
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java:
##########
@@ -254,12 +215,13 @@ private List<MavenProject> trimResumedProjects( List<MavenProject> projects, Pro
 
         if ( StringUtils.isNotEmpty( request.getResumeFrom() ) )
         {
-            File reactorDirectory = getReactorDirectory( request );
+            File reactorDirectory = !isNullOrEmpty( request.getBaseDirectory() )

Review Comment:
   Certain? `new File( "" )` isn't wrong, no?



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

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org