michael-o commented on a change in pull request #429: URL: https://github.com/apache/maven/pull/429#discussion_r565375083
########## 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: Thanks, I will go through. ---------------------------------------------------------------- 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: [email protected]
