Java Code Examples for org.gradle.api.JavaVersion#current()

The following examples show how to use org.gradle.api.JavaVersion#current() . 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: Jvm.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @param os the OS
 * @param suppliedJavaBase initial location to discover from. May be jdk or jre.
 */
Jvm(OperatingSystem os, File suppliedJavaBase) {
    this.os = os;
    if (suppliedJavaBase == null) {
        //discover based on what's in the sys. property
        try {
            this.javaBase = new File(System.getProperty("java.home")).getCanonicalFile();
        } catch (IOException e) {
            throw new UncheckedException(e);
        }
        this.javaHome = findJavaHome(javaBase);
        this.javaVersion = JavaVersion.current();
        this.userSupplied = false;
    } else {
        //precisely use what the user wants and validate strictly further on
        this.javaBase = suppliedJavaBase;
        this.javaHome = suppliedJavaBase;
        this.userSupplied = true;
        this.javaVersion = null;
    }
}
 
Example 2
Source File: Jvm.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @param os the OS
 * @param suppliedJavaBase initial location to discover from. May be jdk or jre.
 */
Jvm(OperatingSystem os, File suppliedJavaBase) {
    this.os = os;
    if (suppliedJavaBase == null) {
        //discover based on what's in the sys. property
        try {
            this.javaBase = new File(System.getProperty("java.home")).getCanonicalFile();
        } catch (IOException e) {
            throw new UncheckedException(e);
        }
        this.javaHome = findJavaHome(javaBase);
        this.javaVersion = JavaVersion.current();
        this.userSupplied = false;
    } else {
        //precisely use what the user wants and validate strictly further on
        this.javaBase = suppliedJavaBase;
        this.javaHome = suppliedJavaBase;
        this.userSupplied = true;
        this.javaVersion = null;
    }
}
 
Example 3
Source File: Jvm.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @param os the OS
 * @param suppliedJavaBase initial location to discover from. May be jdk or jre.
 */
Jvm(OperatingSystem os, File suppliedJavaBase) {
    this.os = os;
    if (suppliedJavaBase == null) {
        //discover based on what's in the sys. property
        try {
            this.javaBase = new File(System.getProperty("java.home")).getCanonicalFile();
        } catch (IOException e) {
            throw new UncheckedException(e);
        }
        this.javaHome = findJavaHome(javaBase);
        this.javaVersion = JavaVersion.current();
        this.userSupplied = false;
    } else {
        //precisely use what the user wants and validate strictly further on
        this.javaBase = suppliedJavaBase;
        this.javaHome = suppliedJavaBase;
        this.userSupplied = true;
        this.javaVersion = null;
    }
}
 
Example 4
Source File: Jvm.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @param os the OS
 * @param suppliedJavaBase initial location to discover from. May be jdk or jre.
 */
Jvm(OperatingSystem os, File suppliedJavaBase) {
    this.os = os;
    if (suppliedJavaBase == null) {
        //discover based on what's in the sys. property
        try {
            this.javaBase = new File(System.getProperty("java.home")).getCanonicalFile();
        } catch (IOException e) {
            throw new UncheckedException(e);
        }
        this.javaHome = findJavaHome(javaBase);
        this.javaVersion = JavaVersion.current();
        this.userSupplied = false;
    } else {
        //precisely use what the user wants and validate strictly further on
        this.javaBase = suppliedJavaBase;
        this.javaHome = suppliedJavaBase;
        this.userSupplied = true;
        this.javaVersion = null;
    }
}
 
Example 5
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 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: DefaultJavaPlatform.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultJavaPlatform(String name) {
    this.name = name;
    this.targetCompatibility = JavaVersion.current();
}
 
Example 8
Source File: ConnectorServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private static void assertJava6() {
    JavaVersion javaVersion = JavaVersion.current();
    if (!javaVersion.isJava6Compatible()) {
        throw UnsupportedJavaRuntimeException.usingUnsupportedVersion("Gradle Tooling API", JavaVersion.VERSION_1_6);
    }
}
 
Example 9
Source File: DefaultJavaToolChain.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultJavaToolChain(JavaCompilerFactory compilerFactory, ExecActionFactory execActionFactory) {
    this.compilerFactory = compilerFactory;
    this.execActionFactory = execActionFactory;
    this.javaVersion = JavaVersion.current();
}
 
Example 10
Source File: DefaultJavaPlatform.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultJavaPlatform(String name) {
    this.name = name;
    this.targetCompatibility = JavaVersion.current();
}
 
Example 11
Source File: ConnectorServices.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private static void assertJava6() {
    JavaVersion javaVersion = JavaVersion.current();
    if (!javaVersion.isJava6Compatible()) {
        throw UnsupportedJavaRuntimeException.usingUnsupportedVersion("Gradle Tooling API", JavaVersion.VERSION_1_6);
    }
}
 
Example 12
Source File: DefaultJavaToolChain.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultJavaToolChain(JavaCompilerFactory compilerFactory, ExecActionFactory execActionFactory) {
    this.compilerFactory = compilerFactory;
    this.execActionFactory = execActionFactory;
    this.javaVersion = JavaVersion.current();
}