protected boolean selectToolchain()

in src/main/java/org/apache/maven/plugins/toolchain/ToolchainMojo.java [128:162]


    protected boolean selectToolchain(String type, Map<String, String> params) throws MojoExecutionException {
        getLog().info("Required toolchain: " + getToolchainRequirementAsString(type, params));
        int typeFound = 0;

        try {
            ToolchainPrivate[] tcs = getToolchains(type);

            for (ToolchainPrivate tc : tcs) {
                if (!type.equals(tc.getType())) {
                    // useful because of MNG-5716
                    continue;
                }

                typeFound++;

                if (tc.matchesRequirements(params)) {
                    getLog().info("Found matching toolchain for type " + type + ": " + tc);

                    // store matching toolchain to build context
                    synchronized (LOCK) {
                        toolchainManagerPrivate.storeToolchainToBuildContext(tc, session);
                    }

                    return true;
                }
            }
        } catch (MisconfiguredToolchainException ex) {
            throw new MojoExecutionException("Misconfigured toolchains.", ex);
        }

        getLog().error("No toolchain " + ((typeFound == 0) ? "found" : ("matched from " + typeFound + " found"))
                + " for type " + type);

        return false;
    }