Java Code Examples for org.gradle.jvm.toolchain.JavaToolChain

The following examples show how to use org.gradle.jvm.toolchain.JavaToolChain. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void execute(JvmLibrarySpec jvmLibrary) {
    List<String> targetPlatforms = jvmLibrary.getTargetPlatforms();
    // TODO:DAZ We should have a generic (JVM + Native) way to get the 'best' platform to build when no target is defined.
    // This logic needs to inspect the available platforms and find the closest one matching the current platform
    if (targetPlatforms.isEmpty()) {
        targetPlatforms = Collections.singletonList(new DefaultJavaPlatform(JavaVersion.current()).getName());
    }
    List<JavaPlatform> selectedPlatforms = platforms.select(JavaPlatform.class, targetPlatforms);
    for (JavaPlatform platform: selectedPlatforms) {
        JavaToolChain toolChain = toolChains.getForPlatform(platform);
        BinaryNamingSchemeBuilder componentBuilder = namingSchemeBuilder
                .withComponentName(jvmLibrary.getName())
                .withTypeString("jar");
        if (selectedPlatforms.size() > 1) { //Only add variant dimension for multiple jdk targets to avoid breaking the default naming scheme
            componentBuilder = componentBuilder.withVariantDimension(platform.getName());
        }
        BinaryNamingScheme namingScheme = componentBuilder.build(); //TODO freekh: move out?
        factory.createJarBinaries(jvmLibrary, namingScheme, toolChain, platform); //TODO: createJarBinaries is mutable! We should not be doing this - execute could return a list instead
    }
}
 
Example 2
public void execute(JvmLibrarySpec jvmLibrary) {
    List<String> targetPlatforms = jvmLibrary.getTargetPlatforms();
    // TODO:DAZ We should have a generic (JVM + Native) way to get the 'best' platform to build when no target is defined.
    // This logic needs to inspect the available platforms and find the closest one matching the current platform
    if (targetPlatforms.isEmpty()) {
        targetPlatforms = Collections.singletonList(new DefaultJavaPlatform(JavaVersion.current()).getName());
    }
    List<JavaPlatform> selectedPlatforms = platforms.select(JavaPlatform.class, targetPlatforms);
    for (JavaPlatform platform: selectedPlatforms) {
        JavaToolChain toolChain = toolChains.getForPlatform(platform);
        BinaryNamingSchemeBuilder componentBuilder = namingSchemeBuilder
                .withComponentName(jvmLibrary.getName())
                .withTypeString("jar");
        if (selectedPlatforms.size() > 1) { //Only add variant dimension for multiple jdk targets to avoid breaking the default naming scheme
            componentBuilder = componentBuilder.withVariantDimension(platform.getName());
        }
        BinaryNamingScheme namingScheme = componentBuilder.build(); //TODO freekh: move out?
        factory.createJarBinaries(jvmLibrary, namingScheme, toolChain, platform); //TODO: createJarBinaries is mutable! We should not be doing this - execute could return a list instead
    }
}
 
Example 3
Source Project: javaide   Source File: JavaCompile.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the tool chain that will be used to compile the Java source.
 *
 * @return The tool chain.
 */
@Nested
@Incubating
public JavaToolChain getToolChain() {
    if (toolChain != null) {
        return toolChain;
    }
    return getJavaToolChainFactory().forCompileOptions(getOptions());
}
 
Example 4
Source Project: javaide   Source File: JavaBasePlugin.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Inject
public JavaBasePlugin(Instantiator instantiator, JavaToolChain javaToolChain, ITaskFactory taskFactory, ModelRegistry modelRegistry) {
    this.instantiator = instantiator;
    this.javaToolChain = javaToolChain;
    this.taskFactory = taskFactory;
    this.modelRegistry = modelRegistry;
}
 
Example 5
Source Project: gradle-plugins   Source File: ResolveJavadocLinks.java    License: MIT License 5 votes vote down vote up
private String getJavaSeLink() {
    JavaVersion javaVersion = JavaVersion.current();

    JavaToolChain toolChain = javadoc.getToolChain();
    if (toolChain instanceof JavaToolChainInternal) {
        javaVersion = ((JavaToolChainInternal) toolChain).getJavaVersion();
    }

    if (javaVersion.isJava11Compatible()) {
        return "https://docs.oracle.com/en/java/javase/" + javaVersion.getMajorVersion() + "/docs/api/";
    }
    else {
        return "https://docs.oracle.com/javase/" + javaVersion.getMajorVersion() + "/docs/api/";
    }
}
 
Example 6
Source Project: gradle-plugins   Source File: ResolveJavadocLinks.java    License: MIT License 5 votes vote down vote up
private String getJavaSeLink() {
    JavaVersion javaVersion = JavaVersion.current();

    JavaToolChain toolChain = javadoc.getToolChain();
    if (toolChain instanceof JavaToolChainInternal) {
        javaVersion = ((JavaToolChainInternal) toolChain).getJavaVersion();
    }

    if (javaVersion.isJava11Compatible()) {
        return "https://docs.oracle.com/en/java/javase/" + javaVersion.getMajorVersion() + "/docs/api/";
    }
    else {
        return "https://docs.oracle.com/javase/" + javaVersion.getMajorVersion() + "/docs/api/";
    }
}
 
Example 7
public JavaToolChain getForPlatform(JavaPlatform targetPlatform) {
    return toolChain;
}
 
Example 8
public void createJarBinaries(JvmLibrarySpec jvmLibrary, BinaryNamingScheme namingScheme, JavaToolChain toolChain, JavaPlatform platform) {
    DefaultJarBinarySpec jarBinary = instantiator.newInstance(DefaultJarBinarySpec.class, jvmLibrary, namingScheme, toolChain, platform);
    setupDefaults(jarBinary);
    jarBinary.source(jvmLibrary.getSource());
    jvmLibrary.getBinaries().add(jarBinary);
}
 
Example 9
public DefaultJarBinarySpec(JvmLibrarySpec library, BinaryNamingScheme namingScheme, JavaToolChain toolChain, JavaPlatform platform) {
    this.library = library;
    this.namingScheme = namingScheme;
    this.toolChain = toolChain;
    this.platform = platform;
}
 
Example 10
public JavaToolChain getToolChain() {
    return toolChain;
}
 
Example 11
/**
 * Returns the tool chain that will be used to compile the Java source.
 *
 * @return The tool chain.
 */
@Incubating @Inject
public JavaToolChain getToolChain() {
    // Implementation is generated
    throw new UnsupportedOperationException();
}
 
Example 12
/**
 * Sets the tool chain that should be used to compile the Java source.
 *
 * @param toolChain The tool chain.
 */
@Incubating
public void setToolChain(JavaToolChain toolChain) {
    // Implementation is generated
    throw new UnsupportedOperationException();
}
 
Example 13
Source Project: pushfish-android   Source File: Javadoc.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Returns the tool chain that will be used to generate the Javadoc.
 */
@Incubating @Inject
public JavaToolChain getToolChain() {
    // Implementation is generated
    throw new UnsupportedOperationException();
}
 
Example 14
Source Project: pushfish-android   Source File: Javadoc.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Sets the tool chain to use to generate the Javadoc.
 */
@Incubating
public void setToolChain(JavaToolChain toolChain) {
    // Implementation is generated
    throw new UnsupportedOperationException();
}
 
Example 15
public DefaultClassDirectoryBinarySpec(String name, JavaToolChain toolChain, JavaPlatform platform) {
    this.name = name;
    this.toolChain = toolChain;
    this.platform = platform;
    this.namingScheme = new ClassDirectoryBinaryNamingScheme(removeClassesSuffix(name));
}
 
Example 16
public JavaToolChain getToolChain() {
    return toolChain;
}
 
Example 17
@Inject
public LegacyJavaComponentPlugin(Instantiator instantiator, JavaToolChain toolChain) {
    this.instantiator = instantiator;
    this.toolChain = toolChain;
}
 
Example 18
public JavaToolChain getForPlatform(JavaPlatform targetPlatform) {
    return toolChain;
}
 
Example 19
public void createJarBinaries(JvmLibrarySpec jvmLibrary, BinaryNamingScheme namingScheme, JavaToolChain toolChain, JavaPlatform platform) {
    DefaultJarBinarySpec jarBinary = instantiator.newInstance(DefaultJarBinarySpec.class, jvmLibrary, namingScheme, toolChain, platform);
    setupDefaults(jarBinary);
    jarBinary.source(jvmLibrary.getSource());
    jvmLibrary.getBinaries().add(jarBinary);
}
 
Example 20
public DefaultJarBinarySpec(JvmLibrarySpec library, BinaryNamingScheme namingScheme, JavaToolChain toolChain, JavaPlatform platform) {
    this.library = library;
    this.namingScheme = namingScheme;
    this.toolChain = toolChain;
    this.platform = platform;
}
 
Example 21
public JavaToolChain getToolChain() {
    return toolChain;
}
 
Example 22
/**
 * Returns the tool chain that will be used to compile the Java source.
 *
 * @return The tool chain.
 */
@Incubating @Inject
public JavaToolChain getToolChain() {
    // Implementation is generated
    throw new UnsupportedOperationException();
}
 
Example 23
/**
 * Sets the tool chain that should be used to compile the Java source.
 *
 * @param toolChain The tool chain.
 */
@Incubating
public void setToolChain(JavaToolChain toolChain) {
    // Implementation is generated
    throw new UnsupportedOperationException();
}
 
Example 24
Source Project: Pushjet-Android   Source File: Javadoc.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Returns the tool chain that will be used to generate the Javadoc.
 */
@Incubating @Inject
public JavaToolChain getToolChain() {
    // Implementation is generated
    throw new UnsupportedOperationException();
}
 
Example 25
Source Project: Pushjet-Android   Source File: Javadoc.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Sets the tool chain to use to generate the Javadoc.
 */
@Incubating
public void setToolChain(JavaToolChain toolChain) {
    // Implementation is generated
    throw new UnsupportedOperationException();
}
 
Example 26
public DefaultClassDirectoryBinarySpec(String name, JavaToolChain toolChain, JavaPlatform platform) {
    this.name = name;
    this.toolChain = toolChain;
    this.platform = platform;
    this.namingScheme = new ClassDirectoryBinaryNamingScheme(removeClassesSuffix(name));
}
 
Example 27
public JavaToolChain getToolChain() {
    return toolChain;
}
 
Example 28
@Inject
public LegacyJavaComponentPlugin(Instantiator instantiator, JavaToolChain toolChain) {
    this.instantiator = instantiator;
    this.toolChain = toolChain;
}
 
Example 29
/**
 * Returns the {@link org.gradle.jvm.toolchain.JavaToolChain} that will be used to build this binary.
 */
JavaToolChain getToolChain();
 
Example 30
Source Project: javaide   Source File: JavaCompile.java    License: GNU General Public License v3.0 2 votes vote down vote up
/**
 * Sets the tool chain that should be used to compile the Java source.
 *
 * @param toolChain The tool chain.
 */
@Incubating
public void setToolChain(JavaToolChain toolChain) {
    this.toolChain = toolChain;
}