本文整理汇总了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"));
}
}
}
示例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();
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}