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.toolchain;
20  
21  import java.util.List;
22  import java.util.Map;
23  import org.apache.maven.execution.MavenSession;
24  
25  /**
26   * Public API for a toolchain-aware plugin to get expected toolchain instance.
27   *
28   * @author mkleint
29   * @author Robert Scholte
30   * @since 2.0.9
31   */
32  public interface ToolchainManager {
33  
34      // NOTE: Some plugins like Surefire access this field directly!
35      @Deprecated
36      String ROLE = ToolchainManager.class.getName();
37  
38      /**
39       * Retrieve toolchain of specified type from build context. It is expected that
40       * <code>maven-toolchains-plugin</code> contains the configuration to select the appropriate
41       * toolchain and is executed at the beginning of the build.
42       *
43       * @param type the type, must not be {@code null}
44       * @param context the Maven session, must not be {@code null}
45       * @return the toolchain selected by <code>maven-toolchains-plugin</code>
46       */
47      Toolchain getToolchainFromBuildContext(String type, MavenSession context);
48  
49      /**
50       * Select all toolchains available in user settings matching the type and requirements,
51       * independently from <code>maven-toolchains-plugin</code>.
52       *
53       * @param session the Maven session, must not be {@code null}
54       * @param type the type, must not be {@code null}
55       * @param requirements the requirements, may be {@code null}
56       * @return the matching toolchains, never {@code null}
57       * @since 3.3.0
58       */
59      List<Toolchain> getToolchains(MavenSession session, String type, Map<String, String> requirements);
60  }