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

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

Introduction

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

Prototype

ToolchainModel getModel();

Source Link

Usage

From source file:io.sarl.maven.compiler.AbstractSarlBatchCompilerMojo.java

License:Apache License

private String getBootClassPath() throws MojoExecutionException {
    final Toolchain toolchain = this.toolchainManager.getToolchainFromBuildContext("jdk", //$NON-NLS-1$
            this.mavenHelper.getSession());
    if (toolchain instanceof JavaToolChain && toolchain instanceof ToolchainPrivate) {
        final JavaToolChain javaToolChain = (JavaToolChain) toolchain;
        final ToolchainPrivate privateJavaToolChain = (ToolchainPrivate) toolchain;
        getLog().info(Locale.getString(AbstractSarlBatchCompilerMojo.class, "USING_TOOLCHAIN", javaToolChain)); //$NON-NLS-1$

        String[] includes = { "jre/lib/*", "jre/lib/ext/*", "jre/lib/endorsed/*" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        String[] excludes = new String[0];
        final Xpp3Dom config = (Xpp3Dom) privateJavaToolChain.getModel().getConfiguration();
        if (config != null) {
            final Xpp3Dom bootClassPath = config.getChild("bootClassPath"); //$NON-NLS-1$
            if (bootClassPath != null) {
                final Xpp3Dom includeParent = bootClassPath.getChild("includes"); //$NON-NLS-1$
                if (includeParent != null) {
                    includes = getValues(includeParent.getChildren("include")); //$NON-NLS-1$
                }//from   ww w.jav a 2 s  .  co  m
                final Xpp3Dom excludeParent = bootClassPath.getChild("excludes"); //$NON-NLS-1$
                if (excludeParent != null) {
                    excludes = getValues(excludeParent.getChildren("exclude")); //$NON-NLS-1$
                }
            }
        }

        try {
            return scanBootclasspath(Objects.toString(this.reflect.invoke(javaToolChain, "getJavaHome")), //$NON-NLS-1$
                    includes, excludes);
        } catch (Exception e) {
            throw new MojoExecutionException(e.getLocalizedMessage(), e);
        }
    }
    return ""; //$NON-NLS-1$
}

From source file:io.sarl.maven.docs.AbstractDocumentationMojo.java

License:Apache License

/** Replies the boot classpath.
 *
 * @return the boot classpath.//from  ww  w.j  a  v  a  2  s . com
 * @throws IOException in case of error.
 */
protected String getBootClassPath() throws IOException {
    final Toolchain toolchain = this.toolchainManager.getToolchainFromBuildContext("jdk", this.session); //$NON-NLS-1$
    if (toolchain instanceof JavaToolChain && toolchain instanceof ToolchainPrivate) {
        final JavaToolChain javaToolChain = (JavaToolChain) toolchain;
        final ToolchainPrivate privateJavaToolChain = (ToolchainPrivate) toolchain;
        String[] includes = { "jre/lib/*", "jre/lib/ext/*", "jre/lib/endorsed/*" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        String[] excludes = new String[0];
        final Xpp3Dom config = (Xpp3Dom) privateJavaToolChain.getModel().getConfiguration();
        if (config != null) {
            final Xpp3Dom bootClassPath = config.getChild("bootClassPath"); //$NON-NLS-1$
            if (bootClassPath != null) {
                final Xpp3Dom includeParent = bootClassPath.getChild("includes"); //$NON-NLS-1$
                if (includeParent != null) {
                    includes = getValues(includeParent.getChildren("include")); //$NON-NLS-1$
                }
                final Xpp3Dom excludeParent = bootClassPath.getChild("excludes"); //$NON-NLS-1$
                if (excludeParent != null) {
                    excludes = getValues(excludeParent.getChildren("exclude")); //$NON-NLS-1$
                }
            }
        }

        try {
            return scanBootclasspath(Objects.toString(this.reflect.invoke(javaToolChain, "getJavaHome")), //$NON-NLS-1$
                    includes, excludes);
        } catch (Exception e) {
            throw new IOException(e.getLocalizedMessage(), e);
        }
    }
    return ""; //$NON-NLS-1$
}