1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.maven.api.services; 20 21 import java.nio.file.Path; 22 23 import org.apache.maven.api.Service; 24 import org.apache.maven.api.Session; 25 import org.apache.maven.api.annotations.Experimental; 26 import org.apache.maven.api.annotations.Nonnull; 27 28 /** 29 * Builds the effective settings from a user settings file and/or a global settings file. 30 * 31 * @since 4.0.0 32 */ 33 @Experimental 34 public interface SettingsBuilder extends Service { 35 36 /** 37 * Builds the effective settings of the specified settings files. 38 * 39 * @param request the settings building request that holds the parameters, must not be {@code null} 40 * @return the result of the settings building, never {@code null} 41 * @throws SettingsBuilderException if the effective settings could not be built 42 */ 43 @Nonnull 44 SettingsBuilderResult build(@Nonnull SettingsBuilderRequest request); 45 46 /** 47 * Builds the effective settings of the specified settings sources. 48 * 49 * @return the result of the settings building, never {@code null} 50 * @throws SettingsBuilderException if the effective settings could not be built 51 */ 52 @Nonnull 53 default SettingsBuilderResult build( 54 @Nonnull Session session, @Nonnull Source globalSettingsSource, @Nonnull Source userSettingsSource) { 55 return build(session, globalSettingsSource, null, userSettingsSource); 56 } 57 58 /** 59 * Builds the effective settings of the specified settings paths. 60 * 61 * @return the result of the settings building, never {@code null} 62 * @throws SettingsBuilderException if the effective settings could not be built 63 */ 64 @Nonnull 65 default SettingsBuilderResult build( 66 @Nonnull Session session, @Nonnull Path globalSettingsPath, @Nonnull Path userSettingsPath) { 67 return build(session, globalSettingsPath, null, userSettingsPath); 68 } 69 70 /** 71 * Builds the effective settings of the specified settings sources. 72 * 73 * @return the result of the settings building, never {@code null} 74 * @throws SettingsBuilderException if the effective settings could not be built 75 */ 76 @Nonnull 77 default SettingsBuilderResult build( 78 @Nonnull Session session, 79 @Nonnull Source globalSettingsSource, 80 @Nonnull Source projectSettingsSource, 81 @Nonnull Source userSettingsSource) { 82 return build( 83 SettingsBuilderRequest.build(session, globalSettingsSource, projectSettingsSource, userSettingsSource)); 84 } 85 86 /** 87 * Builds the effective settings of the specified settings paths. 88 * 89 * @return the result of the settings building, never {@code null} 90 * @throws SettingsBuilderException if the effective settings could not be built 91 */ 92 @Nonnull 93 default SettingsBuilderResult build( 94 @Nonnull Session session, 95 @Nonnull Path globalSettingsPath, 96 @Nonnull Path projectSettingsPath, 97 @Nonnull Path userSettingsPath) { 98 return build(SettingsBuilderRequest.build(session, globalSettingsPath, projectSettingsPath, userSettingsPath)); 99 } 100 }