mthmulders commented on a change in pull request #429:
URL: https://github.com/apache/maven/pull/429#discussion_r565274300



##########
File path: 
maven-core/src/main/java/org/apache/maven/MissingProfileException.java
##########
@@ -0,0 +1,32 @@
+package org.apache.maven;
+
+/*
+ * 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.
+ */
+
+/**
+ * Signals that the user referenced a Maven profile that could not be located 
in either the project or the settings.
+ */
+public class MissingProfileException

Review comment:
       Renamed.

##########
File path: 
maven-core/src/main/java/org/apache/maven/MissingProfileException.java
##########
@@ -0,0 +1,32 @@
+package org.apache.maven;
+
+/*
+ * 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.
+ */
+
+/**
+ * Signals that the user referenced a Maven profile that could not be located 
in either the project or the settings.
+ */
+public class MissingProfileException
+        extends Exception

Review comment:
       Referencing a profile in your Maven invocation that does not exist is an 
error made by the user. The system (Maven) is not in an illegal state. So it 
could be `IllegalArgumentException` if you insist.

##########
File path: 
maven-core/src/main/java/org/apache/maven/execution/ProfileActivation.java
##########
@@ -0,0 +1,180 @@
+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.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 profiles and optionally fail the
+ * build if those profiles do not exist.
+ */
+public class ProfileActivation
+{
+
+    private static class ActivationSettings
+    {
+        /** Should the profile be active? */
+        final boolean active;
+        /** Should the build continue if the profile is not present? */
+        final boolean optional;
+
+        ActivationSettings( final boolean active, final boolean optional )
+        {
+            this.active = active;
+            this.optional = optional;
+        }
+    }
+
+    private final Map<String, ActivationSettings> activations = new 
HashMap<>();
+
+    /**
+     * Mimics the pre-Maven 4 "active profiles" list.
+     */
+    @Deprecated
+    public List<String> getActiveProfiles()
+    {
+        return new ArrayList<>( getProfileIds( pa -> pa.active ) );
+    }
+
+    /**
+     * Mimics the pre-Maven 4 "inactive profiles" list.
+     */
+    @Deprecated
+    public List<String> getInactiveProfiles()
+    {
+        return new ArrayList<>( getProfileIds( pa -> !pa.active ) );
+    }
+
+    /**
+     * Overwrites the active profiles based on a pre-Maven 4 "active profiles" 
list.
+     * @param activeProfileIds A {@link List} of profile IDs that must be 
activated.
+     */
+    @Deprecated
+    public void overwriteActiveProfiles( List<String> activeProfileIds )
+    {
+        getActiveProfiles().forEach( this.activations::remove );
+        activeProfileIds.forEach( this::activateOptionalProfile );
+    }
+
+    /**
+     * Overwrites the inactive profiles based on a pre-Maven 4 "inactive 
profiles" list.
+     * @param inactiveProfileIds A {@link List} of profile IDs that must be 
deactivated.
+     */
+    @Deprecated
+    public void overwriteInactiveProfiles( List<String> inactiveProfileIds )

Review comment:
       The logic in this class used to be in `DefaultMavenExecutionRequest`, 
but without the distinction between "optional" or "required" profiles. We 
wanted to move all logic regarding activating/deactivating profiles into the 
new class. The old behaviour (which doesn't distinguish between "optional" or 
"required") should be kept intact, as it is part of the `MavenExecutionRequest` 
contract. The methods in that contract have been deprecated as well - 
eventually, we should make explicit whether (de)activating a profile is 
required or optional.
   
   The Javadoc has been updated with a pointer to the replacement candidate.

##########
File path: 
maven-core/src/main/java/org/apache/maven/execution/ProfileActivation.java
##########
@@ -0,0 +1,180 @@
+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.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 profiles and optionally fail the
+ * build if those profiles do not exist.
+ */
+public class ProfileActivation

Review comment:
       We chose `Set` to express the fact that there can be no duplicate values 
in there. IMHO, declaring `Collection` is a downgrade since it loses 
information. Since `Set` is an interface itself we're not declaring the 
implementation type of the return value.




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