View Javadoc
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  import org.apache.maven.api.Service;
23  import org.apache.maven.api.Session;
24  import org.apache.maven.api.annotations.Nonnull;
25  
26  /**
27   * Builds the effective settings from a user settings file and/or a global settings file.
28   */
29  public interface SettingsBuilder extends Service {
30  
31      /**
32       * Builds the effective settings of the specified settings files.
33       *
34       * @param request the settings building request that holds the parameters, must not be {@code null}
35       * @return the result of the settings building, never {@code null}
36       * @throws SettingsBuilderException if the effective settings could not be built
37       */
38      @Nonnull
39      SettingsBuilderResult build(@Nonnull SettingsBuilderRequest request);
40  
41      /**
42       * Builds the effective settings of the specified settings sources.
43       *
44       * @return the result of the settings building, never {@code null}
45       * @throws SettingsBuilderException if the effective settings could not be built
46       */
47      @Nonnull
48      default SettingsBuilderResult build(
49              @Nonnull Session session, @Nonnull Source globalSettingsSource, @Nonnull Source userSettingsSource) {
50          return build(SettingsBuilderRequest.build(session, globalSettingsSource, userSettingsSource));
51      }
52  
53      /**
54       * Builds the effective settings of the specified settings paths.
55       *
56       * @return the result of the settings building, never {@code null}
57       * @throws SettingsBuilderException if the effective settings could not be built
58       */
59      @Nonnull
60      default SettingsBuilderResult build(
61              @Nonnull Session session, @Nonnull Path globalSettingsPath, @Nonnull Path userSettingsPath) {
62          return build(SettingsBuilderRequest.build(session, globalSettingsPath, userSettingsPath));
63      }
64  }