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.Nonnull; 26 27 /** 28 * Builds the effective settings from a user settings file and/or a global settings file. 29 */ 30 public interface SettingsBuilder extends Service { 31 32 /** 33 * Builds the effective settings of the specified settings files. 34 * 35 * @param request the settings building request that holds the parameters, must not be {@code null} 36 * @return the result of the settings building, never {@code null} 37 * @throws SettingsBuilderException if the effective settings could not be built 38 */ 39 @Nonnull 40 SettingsBuilderResult build(@Nonnull SettingsBuilderRequest request); 41 42 /** 43 * Builds the effective settings of the specified settings sources. 44 * 45 * @return the result of the settings building, never {@code null} 46 * @throws SettingsBuilderException if the effective settings could not be built 47 */ 48 @Nonnull 49 default SettingsBuilderResult build( 50 @Nonnull Session session, @Nonnull Source globalSettingsSource, @Nonnull Source userSettingsSource) { 51 return build(session, globalSettingsSource, null, userSettingsSource); 52 } 53 54 /** 55 * Builds the effective settings of the specified settings paths. 56 * 57 * @return the result of the settings building, never {@code null} 58 * @throws SettingsBuilderException if the effective settings could not be built 59 */ 60 @Nonnull 61 default SettingsBuilderResult build( 62 @Nonnull Session session, @Nonnull Path globalSettingsPath, @Nonnull Path userSettingsPath) { 63 return build(session, globalSettingsPath, null, userSettingsPath); 64 } 65 66 /** 67 * Builds the effective settings of the specified settings sources. 68 * 69 * @return the result of the settings building, never {@code null} 70 * @throws SettingsBuilderException if the effective settings could not be built 71 */ 72 @Nonnull 73 default SettingsBuilderResult build( 74 @Nonnull Session session, 75 @Nonnull Source globalSettingsSource, 76 @Nonnull Source projectSettingsSource, 77 @Nonnull Source userSettingsSource) { 78 return build( 79 SettingsBuilderRequest.build(session, globalSettingsSource, projectSettingsSource, userSettingsSource)); 80 } 81 82 /** 83 * Builds the effective settings of the specified settings paths. 84 * 85 * @return the result of the settings building, never {@code null} 86 * @throws SettingsBuilderException if the effective settings could not be built 87 */ 88 @Nonnull 89 default SettingsBuilderResult build( 90 @Nonnull Session session, 91 @Nonnull Path globalSettingsPath, 92 @Nonnull Path projectSettingsPath, 93 @Nonnull Path userSettingsPath) { 94 return build(SettingsBuilderRequest.build(session, globalSettingsPath, projectSettingsPath, userSettingsPath)); 95 } 96 }