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


Java JdkVersionDetector类代码示例

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


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

示例1: readVersionFromProcessOutput

import org.jetbrains.jps.model.java.JdkVersionDetector; //导入依赖的package包/类
@Deprecated
@Nullable
public static String readVersionFromProcessOutput(@NotNull String homePath, @NonNls @NotNull String[] command, @NonNls String versionLineMarker) {
  return JdkVersionDetector.getInstance().readVersionFromProcessOutput(homePath, command, versionLineMarker, ACTION_RUNNER);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:SdkVersionUtil.java

示例2: detectJdkVersion

import org.jetbrains.jps.model.java.JdkVersionDetector; //导入依赖的package包/类
@Nullable
public static String detectJdkVersion(@NotNull String homePath) {
  return JdkVersionDetector.getInstance().detectJdkVersion(homePath, ACTION_RUNNER);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:SdkVersionUtil.java

示例3: getJdkVersionInfo

import org.jetbrains.jps.model.java.JdkVersionDetector; //导入依赖的package包/类
@Nullable
public static JdkVersionDetector.JdkVersionInfo getJdkVersionInfo(@NotNull String homePath) {
  return JdkVersionDetector.getInstance().detectJdkVersionInfo(homePath, ACTION_RUNNER);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:SdkVersionUtil.java

示例4: getDefaultJavaSdk

import org.jetbrains.jps.model.java.JdkVersionDetector; //导入依赖的package包/类
/**
 * @param pantsExecutable path to the pants executable file for the
 * project. This function will return erroneous output if you use a directory path. The
 * pants executable can be found from a project path with {@link #findPantsExecutable(String)}.
 * @param parentDisposable Disposable object to use if a new JDK is added to
 * the project jdk table (otherwise null). Integration tests should use getTestRootDisposable() for
 * this argument to avoid exceptions during teardown.
 * @return The default Sdk object to use for the project at the given pants
 * executable path.
 *
 * This method will add a JDK to the project JDK table if it needs to create
 * one, which mutates global state (protected by a read/write lock).
 */
public static Optional<Sdk> getDefaultJavaSdk(@NotNull final String pantsExecutable, @Nullable final Disposable parentDisposable) {
  Optional<Sdk> sdkForPants = Arrays.stream(ProjectJdkTable.getInstance().getAllJdks())
    // If a JDK belongs to this particular `pantsExecutable`, then its name will contain the path to Pants.
    .filter(sdk -> sdk.getName().contains(pantsExecutable) && sdk.getSdkType() instanceof JavaSdk)
    .findFirst();

  if (sdkForPants.isPresent()) {
    SdkModificator modificator = sdkForPants.get().getSdkModificator();
    JavaSdkImpl.attachJdkAnnotations(modificator);
    ApplicationManager.getApplication().invokeAndWait(() -> {
        ApplicationManager.getApplication().runWriteAction(() -> {
            modificator.commitChanges();
        });
    });
    return sdkForPants;
  }

  final SimpleExportResult exportResult = SimpleExportResult.getExportResult(pantsExecutable);
  if (versionCompare(exportResult.getVersion(), "1.0.7") < 0) {
    return Optional.empty();
  }

  boolean strict = PantsOptions.getPantsOptions(pantsExecutable).usesStrictJvmVersionForJUnit();
  Optional<String> jdkHome = exportResult.getJdkHome(strict);
  if (!jdkHome.isPresent()) {
    return Optional.empty();
  }

  String jdkName = null;
  JdkVersionDetector.JdkVersionInfo jdkInfo = JdkVersionDetector.getInstance().detectJdkVersionInfo(jdkHome.get());
  if (jdkInfo != null) {
    // Using IJ's framework to detect jdk version. so jdkInfo.getVersion() returns `java version "1.8.0_121"`
    for (String version : ContainerUtil.newArrayList("1.6", "1.7", "1.8", "1.9")) {
      if (jdkInfo.getVersion().contains(version)) {
        jdkName = String.format("%s_from_%s", version, pantsExecutable);
        break;
      }
    }
  }
  if (jdkName == null) {
    jdkName = String.format("1.x_from_%s", pantsExecutable);
  }

  // Finally if we need to create a new JDK, it needs to be registered in the `ProjectJdkTable` on the IDE level
  // before it can be used.
  Sdk jdk = JavaSdk.getInstance().createJdk(jdkName, jdkHome.get());
  ApplicationManager.getApplication().invokeAndWait(() -> {
      ApplicationManager.getApplication().runWriteAction(() -> {
          if (parentDisposable == null) {
            ProjectJdkTable.getInstance().addJdk(jdk);
          } else {
            ProjectJdkTable.getInstance().addJdk(jdk, parentDisposable);
          }
      });
  });
  return Optional.of(jdk);
}
 
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:71,代码来源:PantsUtil.java

示例5: readVersionFromProcessOutput

import org.jetbrains.jps.model.java.JdkVersionDetector; //导入依赖的package包/类
@Nullable
public static String readVersionFromProcessOutput(String homePath, @NonNls String[] command, @NonNls String versionLineMarker) {
  return JdkVersionDetector.getInstance().readVersionFromProcessOutput(homePath, command, versionLineMarker, ACTION_RUNNER);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:5,代码来源:SdkVersionUtil.java

示例6: detectJdkVersion

import org.jetbrains.jps.model.java.JdkVersionDetector; //导入依赖的package包/类
@Nullable
public static String detectJdkVersion(String homePath) {
  return JdkVersionDetector.getInstance().detectJdkVersion(homePath, ACTION_RUNNER);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:5,代码来源:SdkVersionUtil.java


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