Example usage for org.apache.maven.toolchain ToolchainPrivate matchesRequirements

List of usage examples for org.apache.maven.toolchain ToolchainPrivate matchesRequirements

Introduction

In this page you can find the example usage for org.apache.maven.toolchain ToolchainPrivate matchesRequirements.

Prototype

boolean matchesRequirements(Map<String, String> requirements);

Source Link

Document

Let the toolchain decide if it matches requirements defined in the toolchain plugin configuration.

Usage

From source file:org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo.java

License:Apache License

private DefaultJavaToolChain findMatchingJavaToolChain(final ExecutionEnvironment environment)
        throws MojoExecutionException {
    try {//w ww  .  j a  v a 2  s  .com
        final Map requirements = Collections.singletonMap("id", environment.getProfileName());
        for (ToolchainPrivate javaToolChain : toolChainManager.getToolchainsForType("jdk", session)) {
            if (javaToolChain.matchesRequirements(requirements)) {
                if (javaToolChain instanceof DefaultJavaToolChain) {
                    return ((DefaultJavaToolChain) javaToolChain);
                }
            }
        }
        throw new MojoExecutionException("useJDK = BREE configured, but no toolchain of type 'jdk' with id '"
                + environment.getProfileName()
                + "' found. See http://maven.apache.org/guides/mini/guide-using-toolchains.html");
    } catch (MisconfiguredToolchainException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}

From source file:org.eclipse.tycho.core.maven.ToolchainProvider.java

License:Open Source License

/**
 * Finds a matching {@link DefaultJavaToolChain} in the maven toolchains for a given maven
 * session and toolchain id. Returns the toolchain or null if no toolchain could be found.
 * /* w  ww.  ja  va2 s.c  o  m*/
 * @param session
 *            The maven session
 * @param toolchainId
 *            The id of the toolchain
 * @return the toolchain that matches or null if no toolchain could be found
 * @throws MojoExecutionException
 *             if the toolchains are misconfigured
 */
public DefaultJavaToolChain findMatchingJavaToolChain(final MavenSession session, final String toolchainId)
        throws MojoExecutionException {
    try {
        final Map<String, String> requirements = Collections.singletonMap("id", toolchainId);
        for (ToolchainPrivate javaToolChain : toolChainManager.getToolchainsForType("jdk", session)) {
            if (javaToolChain.matchesRequirements(requirements)) {
                if (javaToolChain instanceof DefaultJavaToolChain) {
                    return ((DefaultJavaToolChain) javaToolChain);
                }
            }
        }
        return null;

    } catch (MisconfiguredToolchainException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}