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


Java Sdk.getHomeDirectory方法代码示例

本文整理汇总了Java中com.intellij.openapi.projectRoots.Sdk.getHomeDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java Sdk.getHomeDirectory方法的具体用法?Java Sdk.getHomeDirectory怎么用?Java Sdk.getHomeDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.projectRoots.Sdk的用法示例。


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

示例1: checkTargetJPDAInstalled

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
private static void checkTargetJPDAInstalled(JavaParameters parameters) throws ExecutionException {
  final Sdk jdk = parameters.getJdk();
  if (jdk == null) {
    throw new ExecutionException(DebuggerBundle.message("error.jdk.not.specified"));
  }
  final JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk);
  String versionString = jdk.getVersionString();
  if (version == JavaSdkVersion.JDK_1_0 || version == JavaSdkVersion.JDK_1_1) {
    throw new ExecutionException(DebuggerBundle.message("error.unsupported.jdk.version", versionString));
  }
  if (SystemInfo.isWindows && version == JavaSdkVersion.JDK_1_2) {
    final VirtualFile homeDirectory = jdk.getHomeDirectory();
    if (homeDirectory == null || !homeDirectory.isValid()) {
      throw new ExecutionException(DebuggerBundle.message("error.invalid.jdk.home", versionString));
    }
    //noinspection HardCodedStringLiteral
    File dllFile = new File(
      homeDirectory.getPath().replace('/', File.separatorChar) + File.separator + "bin" + File.separator + "jdwp.dll"
    );
    if (!dllFile.exists()) {
      GetJPDADialog dialog = new GetJPDADialog();
      dialog.show();
      throw new ExecutionException(DebuggerBundle.message("error.debug.libraries.missing"));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:DebuggerManagerImpl.java

示例2: getInitialSdkLocation

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
/**
 * Returns initial SDK location. That will be the SDK location from the installer
 * handoff file in the handoff case, sdk location location from the preference if set
 * or platform-dependant default path.
 */
@NotNull
public static File getInitialSdkLocation(@NotNull FirstRunWizardMode mode) {
  File dest = mode.getSdkLocation();
  if (dest != null) {
    return dest;
  }
  else {
    List<Sdk> sdks = AndroidSdkUtils.getAllAndroidSdks();
    Sdk sdk = Iterables.getFirst(sdks, null);
    if (sdk != null) {
      VirtualFile homeDirectory = sdk.getHomeDirectory();
      if (homeDirectory != null) {
        return VfsUtilCore.virtualToIoFile(homeDirectory);
      }
    }
    return getDefaultSdkLocation();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:FirstRunWizardDefaults.java

示例3: getValidJdkToRunModule

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@NotNull
public static Sdk getValidJdkToRunModule(final Module module, boolean productionOnly) throws CantRunException {
  Sdk jdk = getJdkToRunModule(module, productionOnly);
  if (jdk == null) {
    throw CantRunException.noJdkForModule(module);
  }
  final VirtualFile homeDirectory = jdk.getHomeDirectory();
  if (homeDirectory == null || !homeDirectory.isValid()) {
    throw CantRunException.jdkMisconfigured(jdk, module);
  }
  return jdk;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:JavaParameters.java

示例4: PropertyFileGeneratorImpl

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
/**
 * A constctor that extracts all neeed properties for ant build from the project.
 *
 * @param project    a project to examine
 * @param genOptions generation options
 */
public PropertyFileGeneratorImpl(Project project, GenerationOptions genOptions) {
  // path variables
  final PathMacros pathMacros = PathMacros.getInstance();
  final Set<String> macroNamesSet = pathMacros.getUserMacroNames();
  if (macroNamesSet.size() > 0) {
    final String[] macroNames = ArrayUtil.toStringArray(macroNamesSet);
    Arrays.sort(macroNames);
    for (final String macroName : macroNames) {
      addProperty(BuildProperties.getPathMacroProperty(macroName), pathMacros.getValue(macroName));
    }
  }
  // jdk homes
  if (genOptions.forceTargetJdk) {
    final Sdk[] usedJdks = BuildProperties.getUsedJdks(project);
    for (Sdk jdk : usedJdks) {
      if (jdk.getHomeDirectory() == null) {
        continue;
      }
      final File homeDir = BuildProperties.toCanonicalFile(VfsUtil.virtualToIoFile(jdk.getHomeDirectory()));
      addProperty(BuildProperties.getJdkHomeProperty(jdk.getName()), homeDir.getPath().replace(File.separatorChar, '/'));
    }
  }
  // generate idea.home property
  if (genOptions.isIdeaHomeGenerated()) {
    addProperty(BuildProperties.PROPERTY_IDEA_HOME, PathManager.getHomePath());
  }

  if (genOptions.enableFormCompiler) {
    addProperty(BuildProperties.PROPERTY_INCLUDE_JAVA_RUNTIME_FOR_INSTRUMENTATION, genOptions.forceTargetJdk? "false" : "true");
  }

  ChunkBuildExtension.generateAllProperties(this, project, genOptions);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:PropertyFileGeneratorImpl.java

示例5: expand

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Nullable
@Override
public String expand(DataContext dataContext) throws ExecutionCancelledException {
  Module module = LangDataKeys.MODULE.getData(dataContext);
  if (module == null) {
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project == null) {
      return null;
    }
    Module[] modules = ModuleManager.getInstance(project).getModules();
    if (modules.length == 0) {
      return null;
    }
    module = modules[0];
  }
  Sdk sdk = PythonSdkType.findPythonSdk(module);
  if (sdk != null) {
    VirtualFile homeDir = sdk.getHomeDirectory();
    if (homeDir == null) {
      return null;
    }
    String path = PathUtil.getLocalPath(homeDir.getParent());
    if (path != null) {
      return FileUtil.toSystemDependentName(path);
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:InterpreterDirectoryMacro.java

示例6: isCondaVEnv

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public static boolean isCondaVEnv(Sdk sdk) {
  final String condaName = "conda-meta";
  final VirtualFile homeDirectory = sdk.getHomeDirectory();
  if (homeDirectory == null) return false;
  final VirtualFile condaExecutable = SystemInfo.isWindows ? homeDirectory.getParent().findChild(condaName) :
                                      homeDirectory.getParent().getParent().findChild(condaName);
  return condaExecutable != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PyCondaPackageManagerImpl.java

示例7: getSdkPath

import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public static String getSdkPath(@Nullable Sdk sdk) {
  if (sdk == null) return null;

  VirtualFile homeDirectory = sdk.getHomeDirectory();
  if (homeDirectory == null) return null;

  if (!"jre".equals(homeDirectory.getName())) {
    VirtualFile jreDir = homeDirectory.findChild("jre");
    if (jreDir != null) {
      homeDirectory = jreDir;
    }
  }

  return homeDirectory.getPath();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:MavenUtil.java


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