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
/**
 * @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
/**
 * @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
/**
 * @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
/**
 * @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 Project: gradle-plugins   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   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 DefaultJavaPlatform(String name) {
    this.name = name;
    this.targetCompatibility = JavaVersion.current();
}
 
Example 8
private static void assertJava6() {
    JavaVersion javaVersion = JavaVersion.current();
    if (!javaVersion.isJava6Compatible()) {
        throw UnsupportedJavaRuntimeException.usingUnsupportedVersion("Gradle Tooling API", JavaVersion.VERSION_1_6);
    }
}
 
Example 9
public DefaultJavaToolChain(JavaCompilerFactory compilerFactory, ExecActionFactory execActionFactory) {
    this.compilerFactory = compilerFactory;
    this.execActionFactory = execActionFactory;
    this.javaVersion = JavaVersion.current();
}
 
Example 10
public DefaultJavaPlatform(String name) {
    this.name = name;
    this.targetCompatibility = JavaVersion.current();
}
 
Example 11
private static void assertJava6() {
    JavaVersion javaVersion = JavaVersion.current();
    if (!javaVersion.isJava6Compatible()) {
        throw UnsupportedJavaRuntimeException.usingUnsupportedVersion("Gradle Tooling API", JavaVersion.VERSION_1_6);
    }
}
 
Example 12
public DefaultJavaToolChain(JavaCompilerFactory compilerFactory, ExecActionFactory execActionFactory) {
    this.compilerFactory = compilerFactory;
    this.execActionFactory = execActionFactory;
    this.javaVersion = JavaVersion.current();
}