当前位置: 首页>>代码示例>>Java>>正文


Java JavaVersion类代码示例

本文整理汇总了Java中org.gradle.api.JavaVersion的典型用法代码示例。如果您正苦于以下问题:Java JavaVersion类的具体用法?Java JavaVersion怎么用?Java JavaVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JavaVersion类属于org.gradle.api包,在下文中一共展示了JavaVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkJdk

import org.gradle.api.JavaVersion; //导入依赖的package包/类
public ProbeResult checkJdk(File jdkPath) {
    if (!jdkPath.exists()) {
        return ProbeResult.failure(InstallType.NO_SUCH_DIRECTORY, "No such directory: " + jdkPath);
    }
    EnumMap<SysProp, String> metadata = cache.getUnchecked(jdkPath);
    String version = metadata.get(SysProp.VERSION);
    if (UNKNOWN.equals(version)) {
        return ProbeResult.failure(InstallType.INVALID_JDK, metadata.get(SysProp.Z_ERROR));
    }
    try {
        JavaVersion.toVersion(version);
    } catch (IllegalArgumentException ex) {
        // if the version string cannot be parsed
        return ProbeResult.failure(InstallType.INVALID_JDK, "Cannot parse version number: " + version);
    }
    if (javaExe(jdkPath, "javac").exists()) {
        return ProbeResult.success(InstallType.IS_JDK, metadata);
    }
    return ProbeResult.success(InstallType.IS_JRE, metadata);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:JavaInstallationProbe.java

示例2: run

import org.gradle.api.JavaVersion; //导入依赖的package包/类
@TaskAction
public void run() throws IOException, InterruptedException {
    new FindBugsClasspathValidator(JavaVersion.current()).validateClasspath(
        Iterables.transform(getFindbugsClasspath().getFiles(), new Function<File, String>() {
            @Override
            public String apply(File input) {
                return input.getName();
            }
        }));
    FindBugsSpec spec = generateSpec();
    FindBugsWorkerManager manager = new FindBugsWorkerManager();

    getLogging().captureStandardOutput(LogLevel.DEBUG);
    getLogging().captureStandardError(LogLevel.DEBUG);

    FindBugsResult result = manager.runWorker(getProject().getProjectDir(), getWorkerProcessBuilderFactory(), getFindbugsClasspath(), spec);
    evaluateResult(result);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:FindBugs.java

示例3: findJvms

import org.gradle.api.JavaVersion; //导入依赖的package包/类
private void findJvms(WindowsRegistry windowsRegistry, String sdkSubkey, Collection<JvmInstallation> jvms, boolean jdk, JvmInstallation.Arch arch) {
    List<String> versions;
    try {
        versions = windowsRegistry.getSubkeys(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, sdkSubkey);
    } catch (MissingRegistryEntryException e) {
        // Ignore
        return;
    }

    for (String version : versions) {
        if (version.matches("\\d+\\.\\d+")) {
            continue;
        }
        String javaHome = windowsRegistry.getStringValue(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, sdkSubkey + '\\' + version, "JavaHome");
        jvms.add(new JvmInstallation(JavaVersion.toVersion(version), version, new File(javaHome), jdk, arch));
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:WindowsOracleJvmLocator.java

示例4: findJvms

import org.gradle.api.JavaVersion; //导入依赖的package包/类
public Collection<JvmInstallation> findJvms() {
    List<JvmInstallation> jvms = new ArrayList<JvmInstallation>();
    if (libDir.isDirectory()) {
        for (File javaHome : libDir.listFiles()) {
            Matcher matcher = JAVA_HOME_DIR_PATTERN.matcher(javaHome.getName());
            if (!matcher.matches()) {
                continue;
            }
            if (!new File(javaHome, "jre/bin/java").isFile()) {
                continue;
            }
            String version = matcher.group(1);
            String arch = matcher.group(2);
            boolean jdk = new File(javaHome, "bin/javac").isFile();
            jvms.add(new JvmInstallation(JavaVersion.toVersion(version), version, fileCanonicalizer.canonicalize(javaHome), jdk, toArch(arch)));
        }
    }
    return jvms;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:UbuntuJvmLocator.java

示例5: findJvms

import org.gradle.api.JavaVersion; //导入依赖的package包/类
public List<JvmInstallation> findJvms() {
    List<JvmInstallation> jvms = new ArrayList<JvmInstallation>();
    if (OperatingSystem.current().isLinux()) {
        jvms = addJvm(jvms, JavaVersion.VERSION_1_5, "1.5.0", new File("/opt/jdk/sun-jdk-5"), true, JvmInstallation.Arch.i386);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_6, "1.6.0", new File("/opt/jdk/sun-jdk-6"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_6, "1.6.0", new File("/opt/jdk/ibm-jdk-6"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_7, "1.7.0", new File("/opt/jdk/oracle-jdk-7"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_8, "1.8.0", new File("/opt/jdk/oracle-jdk-8"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_9, "1.9.0", new File("/opt/jdk/oracle-jdk-9"), true, JvmInstallation.Arch.x86_64);
    }
    return CollectionUtils.filter(jvms, new Spec<JvmInstallation>() {
        public boolean isSatisfiedBy(JvmInstallation element) {
            return element.getJavaHome().isDirectory();
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:AvailableJavaHomes.java

示例6: worksWith

import org.gradle.api.JavaVersion; //导入依赖的package包/类
private boolean worksWith(JavaVersion javaVersion) {
    // 0.9-rc-1 was broken for Java 5
    if (isVersion("0.9-rc-1") && javaVersion == JavaVersion.VERSION_1_5) {
        return false;
    }

    // 1.x works on Java 5 - 8
    if (isSameOrOlder("1.12")) {
        return javaVersion.compareTo(JavaVersion.VERSION_1_5) >= 0 && javaVersion.compareTo(JavaVersion.VERSION_1_8) <= 0;
    }

    // 2.x and 3.0-milestone-1 work on Java 6 - 8
    if (isSameOrOlder("3.0-milestone-1")) {
        return javaVersion.compareTo(JavaVersion.VERSION_1_6) >= 0 && javaVersion.compareTo(JavaVersion.VERSION_1_8) <= 0;
    }

    // 3.x works on Java 7 - 9
    return javaVersion.compareTo(JavaVersion.VERSION_1_7) >= 0 && javaVersion.compareTo(JavaVersion.VERSION_1_9) <= 0;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:DefaultGradleDistribution.java

示例7: getImplicitBuildJvmArgs

import org.gradle.api.JavaVersion; //导入依赖的package包/类
@Override
protected List<String> getImplicitBuildJvmArgs() {
    if (!isUseDaemon() || !isSharedDaemons()) {
        return super.getImplicitBuildJvmArgs();
    }

    // Add JVM heap settings only for shared daemons
    List<String> buildJvmOpts = new ArrayList<String>(super.getImplicitBuildJvmArgs());

    if (JVM_VERSION_DETECTOR.getJavaVersion(Jvm.forHome(getJavaHome())).compareTo(JavaVersion.VERSION_1_8) < 0) {
        buildJvmOpts.add("-XX:MaxPermSize=320m");
    }

    buildJvmOpts.add("-XX:+HeapDumpOnOutOfMemoryError");
    buildJvmOpts.add("-XX:HeapDumpPath=" + buildContext.getGradleUserHomeDir().getAbsolutePath());
    return buildJvmOpts;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:DaemonGradleExecuter.java

示例8: parseJavaVersionCommandOutput

import org.gradle.api.JavaVersion; //导入依赖的package包/类
private JavaVersion parseJavaVersionCommandOutput(String javaExecutable, BufferedReader reader) {
    try {
        String versionStr = reader.readLine();
        while (versionStr != null) {
            Matcher matcher = Pattern.compile("(?:java|openjdk) version \"(.+?)\"").matcher(versionStr);
            if (matcher.matches()) {
                return JavaVersion.toVersion(matcher.group(1));
            }
            versionStr = reader.readLine();
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }

    throw new GradleException(String.format("Could not determine Java version using executable %s.", javaExecutable));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:DefaultJvmVersionDetector.java

示例9: JdkTools

import org.gradle.api.JavaVersion; //导入依赖的package包/类
JdkTools(JavaInfo javaInfo) {
    DefaultClassLoaderFactory defaultClassLoaderFactory = new DefaultClassLoaderFactory();
    JavaVersion javaVersion = Jvm.current().getJavaVersion();
    boolean java9Compatible = javaVersion.isJava9Compatible();
    ClassLoader filteringClassLoader = getSystemFilteringClassLoader(defaultClassLoaderFactory, java9Compatible);
    if (!java9Compatible) {
        File toolsJar = javaInfo.getToolsJar();
        if (toolsJar == null) {
            throw new IllegalStateException("Could not find tools.jar. Please check that "
                                            + javaInfo.getJavaHome().getAbsolutePath()
                                            + " contains a valid JDK installation.");
        }
        DefaultClassPath defaultClassPath = new DefaultClassPath(toolsJar);
        isolatedToolsLoader = new VisitableURLClassLoader(filteringClassLoader, defaultClassPath.getAsURLs());
        isJava9Compatible = false;
    } else {
        isolatedToolsLoader = filteringClassLoader;
        isJava9Compatible = true;
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:JdkTools.java

示例10: store

import org.gradle.api.JavaVersion; //导入依赖的package包/类
@Override
protected void store(Properties properties) {
    properties.put("org.eclipse.jdt.core.compiler.compliance", sourceCompatibility.toString());
    properties.put("org.eclipse.jdt.core.compiler.source", sourceCompatibility.toString());

    if (sourceCompatibility.compareTo(JavaVersion.VERSION_1_3) <= 0) {
        properties.put("org.eclipse.jdt.core.compiler.problem.assertIdentifier", "ignore");
        properties.put("org.eclipse.jdt.core.compiler.problem.enumIdentifier", "ignore");
    } else if (sourceCompatibility == JavaVersion.VERSION_1_4) {
        properties.put("org.eclipse.jdt.core.compiler.problem.assertIdentifier", "error");
        properties.put("org.eclipse.jdt.core.compiler.problem.enumIdentifier", "warning");
    } else {
        properties.put("org.eclipse.jdt.core.compiler.problem.assertIdentifier", "error");
        properties.put("org.eclipse.jdt.core.compiler.problem.enumIdentifier", "error");
    }

    properties.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", targetCompatibility.toString());
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:Jdt.java

示例11: configure

import org.gradle.api.JavaVersion; //导入依赖的package包/类
public void configure(List<IdeaModule> modules,
                      String jdkName, IdeaLanguageLevel languageLevel, JavaVersion bytecodeVersion,
                      Collection<String> wildcards, Collection<ProjectLibrary> projectLibraries, String vcs) {
    if (!isNullOrEmpty(jdkName)) {
        jdk = new Jdk(jdkName, languageLevel);
    }
    this.bytecodeVersion = bytecodeVersion;
    this.modulePaths.addAll(Lists.transform(modules, new Function<IdeaModule, Path>() {
        @Override
        public Path apply(IdeaModule module) {
            return pathFactory.relativePath("PROJECT_DIR", module.getOutputFile());
        }
    }));
    this.wildcards.addAll(wildcards);
    this.modules = modules;
    // overwrite rather than append libraries
    this.projectLibraries = Sets.newLinkedHashSet(projectLibraries);
    this.vcs = vcs;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:Project.java

示例12: storeBytecodeLevels

import org.gradle.api.JavaVersion; //导入依赖的package包/类
private void storeBytecodeLevels() {
    Node bytecodeLevelConfiguration = findOrCreateBytecodeLevelConfiguration();
    bytecodeLevelConfiguration.attributes().put("target", bytecodeVersion.toString());
    for (IdeaModule module : modules) {
        List<Node> bytecodeLevelModules = getChildren(bytecodeLevelConfiguration, "module");
        Node moduleNode = findFirstWithAttributeValue(bytecodeLevelModules, "name", module.getName());
        JavaVersion moduleBytecodeVersionOverwrite = module.getTargetBytecodeVersion();
        if (moduleBytecodeVersionOverwrite == null) {
            if (moduleNode != null) {
                bytecodeLevelConfiguration.remove(moduleNode);
            }
        } else {
            if (moduleNode == null) {
                moduleNode = bytecodeLevelConfiguration.appendNode("module");
                moduleNode.attributes().put("name", module.getName());
            }
            moduleNode.attributes().put("target", moduleBytecodeVersionOverwrite.toString());
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:Project.java

示例13: getDefaultTargetJdk

import org.gradle.api.JavaVersion; //导入依赖的package包/类
public TargetJdk getDefaultTargetJdk(JavaVersion javaVersion) {
    try {
        return TargetJdk.toVersion(javaVersion.toString());
    } catch (IllegalArgumentException ignored) {
        // TargetJDK does not include 1.1, 1.2 and 1.8;
        // Use same fallback as PMD
        return TargetJdk.VERSION_1_4;
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:PmdPlugin.java

示例14: validateClasspath

import org.gradle.api.JavaVersion; //导入依赖的package包/类
public void validateClasspath(Iterable<String> fileNamesOnClasspath) {
    VersionNumber v = getFindbugsVersion(fileNamesOnClasspath);
    boolean java8orMore = javaVersion.compareTo(JavaVersion.VERSION_1_7) > 0;
    boolean findbugs2orLess = v.getMajor() < 3;
    if (java8orMore && findbugs2orLess) {
        throw new FindBugsVersionTooLowException("The version of FindBugs (" + v + ") inferred from FindBugs classpath is too low to work with currently used Java version (" + javaVersion + ")."
                + " Please use higher version of FindBugs. Inspected FindBugs classpath: " + fileNamesOnClasspath);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:FindBugsClasspathValidator.java

示例15: Jvm

import org.gradle.api.JavaVersion; //导入依赖的package包/类
private Jvm(OperatingSystem os, File suppliedJavaBase, JavaVersion javaVersion, boolean userSupplied) {
    this.os = os;
    this.javaBase = suppliedJavaBase;
    this.javaHome = findJavaHome(suppliedJavaBase);
    this.javaVersion = javaVersion;
    this.userSupplied = userSupplied;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:Jvm.java


注:本文中的org.gradle.api.JavaVersion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。