001package org.apache.maven.toolchain;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.List;
023import java.util.Map;
024
025import org.apache.maven.execution.MavenSession;
026
027
028/**
029 * Public API for a toolchain-aware plugin to get expected toolchain instance.
030 *
031 * @author mkleint
032 * @author Robert Scholte
033 * @since 2.0.9
034 */
035public interface ToolchainManager
036{
037
038    // NOTE: Some plugins like Surefire access this field directly!
039    @Deprecated
040    String ROLE = ToolchainManager.class.getName();
041
042    /**
043     * Retrieve toolchain of specified type from build context. It is expected that
044     * <code>maven-toolchains-plugin</code> contains the configuration to select the appropriate
045     * toolchain and is executed at the beginning of the build.
046     *
047     * @param session the Maven session, must not be {@code null}
048     * @param type the type, must not be {@code null}
049     * @return the toolchain selected by <code>maven-toolchains-plugin</code>
050     */
051    Toolchain getToolchainFromBuildContext( String type, MavenSession context );
052    
053    /**
054     * Select all toolchains available in user settings matching the type and requirements,
055     * independently from <code>maven-toolchains-plugin</code>.
056     * 
057     * @param session the Maven session, must not be {@code null}
058     * @param type the type, must not be {@code null}
059     * @param requirements the requirements, may be {@code null}
060     * @return the matching toolchains, never {@code null}
061     * @since 3.3.0
062     */
063    List<Toolchain> getToolchains( MavenSession session, String type, Map<String, String> requirements );
064}