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