org.gradle.jvm.toolchain.JavaToolChain Java Examples

The following examples show how to use org.gradle.jvm.toolchain.JavaToolChain. 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
Source File: JvmLibrarySpecInitializer.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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
Source File: JvmLibrarySpecInitializer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 File: JavaBasePlugin.java    From javaide with 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 #4
Source File: ResolveJavadocLinks.java    From gradle-plugins with 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 #5
Source File: JavaCompile.java    From javaide with 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 #6
Source File: ResolveJavadocLinks.java    From gradle-plugins with 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
Source File: DefaultJarBinarySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaToolChain getToolChain() {
    return toolChain;
}
 
Example #8
Source File: DefaultJavaToolChainRegistry.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaToolChain getForPlatform(JavaPlatform targetPlatform) {
    return toolChain;
}
 
Example #9
Source File: DefaultJarBinariesFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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 #10
Source File: DefaultJarBinarySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultJarBinarySpec(JvmLibrarySpec library, BinaryNamingScheme namingScheme, JavaToolChain toolChain, JavaPlatform platform) {
    this.library = library;
    this.namingScheme = namingScheme;
    this.toolChain = toolChain;
    this.platform = platform;
}
 
Example #11
Source File: LegacyJavaComponentPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Inject
public LegacyJavaComponentPlugin(Instantiator instantiator, JavaToolChain toolChain) {
    this.instantiator = instantiator;
    this.toolChain = toolChain;
}
 
Example #12
Source File: JavaCompile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * 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 #13
Source File: JavaCompile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 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) {
    // Implementation is generated
    throw new UnsupportedOperationException();
}
 
Example #14
Source File: Javadoc.java    From Pushjet-Android with 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 #15
Source File: Javadoc.java    From Pushjet-Android with 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 #16
Source File: DefaultClassDirectoryBinarySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultClassDirectoryBinarySpec(String name, JavaToolChain toolChain, JavaPlatform platform) {
    this.name = name;
    this.toolChain = toolChain;
    this.platform = platform;
    this.namingScheme = new ClassDirectoryBinaryNamingScheme(removeClassesSuffix(name));
}
 
Example #17
Source File: DefaultClassDirectoryBinarySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaToolChain getToolChain() {
    return toolChain;
}
 
Example #18
Source File: LegacyJavaComponentPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Inject
public LegacyJavaComponentPlugin(Instantiator instantiator, JavaToolChain toolChain) {
    this.instantiator = instantiator;
    this.toolChain = toolChain;
}
 
Example #19
Source File: DefaultClassDirectoryBinarySpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaToolChain getToolChain() {
    return toolChain;
}
 
Example #20
Source File: DefaultClassDirectoryBinarySpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultClassDirectoryBinarySpec(String name, JavaToolChain toolChain, JavaPlatform platform) {
    this.name = name;
    this.toolChain = toolChain;
    this.platform = platform;
    this.namingScheme = new ClassDirectoryBinaryNamingScheme(removeClassesSuffix(name));
}
 
Example #21
Source File: Javadoc.java    From pushfish-android with 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 #22
Source File: Javadoc.java    From pushfish-android with 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 #23
Source File: JavaCompile.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 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) {
    // Implementation is generated
    throw new UnsupportedOperationException();
}
 
Example #24
Source File: JavaCompile.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * 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 #25
Source File: DefaultJarBinarySpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaToolChain getToolChain() {
    return toolChain;
}
 
Example #26
Source File: DefaultJarBinarySpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultJarBinarySpec(JvmLibrarySpec library, BinaryNamingScheme namingScheme, JavaToolChain toolChain, JavaPlatform platform) {
    this.library = library;
    this.namingScheme = namingScheme;
    this.toolChain = toolChain;
    this.platform = platform;
}
 
Example #27
Source File: DefaultJarBinariesFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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 #28
Source File: DefaultJavaToolChainRegistry.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaToolChain getForPlatform(JavaPlatform targetPlatform) {
    return toolChain;
}
 
Example #29
Source File: JavaCompile.java    From javaide with 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;
}
 
Example #30
Source File: JvmBinarySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Returns the {@link org.gradle.jvm.toolchain.JavaToolChain} that will be used to build this binary.
 */
JavaToolChain getToolChain();