@Override protected void setUp() throws Exception { super.setUp(); myOldDefaultProjectSdk = ProjectRootManager.getInstance(myProjectManager.getDefaultProject()).getProjectSdk(); Sdk projectSdk = ProjectRootManager.getInstance(getProject()).getProjectSdk(); for (final Sdk jdk : ProjectJdkTable.getInstance().getAllJdks()) { if (projectSdk != jdk) { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { ProjectJdkTable.getInstance().removeJdk(jdk); } }); } } }
@Nullable private static Sdk findJdk(@NotNull JavaSdkVersion version) { JavaSdk javaSdk = JavaSdk.getInstance(); List<Sdk> javaSdks = ProjectJdkTable.getInstance().getSdksOfType(javaSdk); Sdk candidate = null; for (Sdk sdk : javaSdks) { JavaSdkVersion v = javaSdk.getVersion(sdk); if (v == version) { return sdk; } else if (candidate == null && v != null && version.getMaxLanguageLevel().isAtLeast(version.getMaxLanguageLevel())) { candidate = sdk; } } return candidate; }
public void testEditLibraryForModuleLoadFromXml() throws IOException { final File tempDirectory = createTempDirectory(); ApplicationManager.getApplication().runWriteAction(() -> { Module a = loadModule(PathManagerEx.getHomePath(getClass()) + "/java/java-tests/testData/moduleRootManager/rootsChanged/emptyModule/a.iml"); assertEventsCount(1); final Sdk jdk = IdeaTestUtil.getMockJdk17(); ProjectJdkTable.getInstance().addJdk(jdk); assertEventsCount(0); ModuleRootModificationUtil.setModuleSdk(a, jdk); assertEventsCount(1); final SdkModificator sdkModificator = jdk.getSdkModificator(); sdkModificator.addRoot(getVirtualFile(tempDirectory), OrderRootType.CLASSES); sdkModificator.commitChanges(); }); assertEventsCount(1); }
public void fillList(final @Nullable SdkType type, final @Nullable Sdk[] globalSdks) { myListModel.clear(); final Sdk[] jdks; if (myProject == null || myProject.isDefault()) { final Sdk[] allJdks = globalSdks != null ? globalSdks : ProjectJdkTable.getInstance().getAllJdks(); jdks = getCompatibleJdks(type, Arrays.asList(allJdks)); } else { final ProjectSdksModel projectJdksModel = ProjectStructureConfigurable.getInstance(myProject).getProjectJdksModel(); if (!projectJdksModel.isInitialized()){ //should be initialized projectJdksModel.reset(myProject); } final Collection<Sdk> collection = projectJdksModel.getProjectSdks().values(); jdks = getCompatibleJdks(type, collection); } Arrays.sort(jdks, new Comparator<Sdk>() { public int compare(final Sdk o1, final Sdk o2) { return o1.getName().compareToIgnoreCase(o2.getName()); } }); for (Sdk jdk : jdks) { myListModel.addElement(jdk); } }
@Override public void jdkNameChanged(final Sdk jdk, final String previousName) { mergeRootsChangesDuring(new Runnable() { @Override public void run() { for (ProjectJdkTable.Listener listener : getListeners()) { listener.jdkNameChanged(jdk, previousName); } } }); String currentName = getProjectSdkName(); if (previousName != null && previousName.equals(currentName)) { // if already had jdk name and that name was the name of the jdk just changed myProjectSdkName = jdk.getName(); myProjectSdkType = jdk.getSdkType().getName(); } }
/** * Tries to create an SDK identified by path; if successful, add the SDK to the global SDK table. * * @param path identifies the SDK * @param sdkType * @return newly created SDK, or null. */ @Nullable public static Sdk createAndAddSDK(final String path, SdkType sdkType) { VirtualFile sdkHome = ApplicationManager.getApplication().runWriteAction(new Computable<VirtualFile>() { @Override public VirtualFile compute() { return LocalFileSystem.getInstance().refreshAndFindFileByPath(path); } }); if (sdkHome != null) { final Sdk newSdk = setupSdk(ProjectJdkTable.getInstance().getAllJdks(), sdkHome, sdkType, true, null, null); if (newSdk != null) { addSdk(newSdk); } return newSdk; } return null; }
public static void selectSdkHome(@NotNull final SdkType sdkType, @NotNull final Consumer<String> consumer) { final FileChooserDescriptor descriptor = sdkType.getHomeChooserDescriptor(); if (ApplicationManager.getApplication().isUnitTestMode()) { Sdk sdk = ProjectJdkTable.getInstance().findMostRecentSdkOfType(sdkType); if (sdk == null) throw new RuntimeException("No SDK of type " + sdkType + " found"); consumer.consume(sdk.getHomePath()); return; } FileChooser.chooseFiles(descriptor, null, getSuggestedSdkRoot(sdkType), new Consumer<List<VirtualFile>>() { @Override public void consume(final List<VirtualFile> chosen) { final String path = chosen.get(0).getPath(); if (sdkType.isValidSdkHome(path)) { consumer.consume(path); return; } final String adjustedPath = sdkType.adjustSelectedSdkHome(path); if (sdkType.isValidSdkHome(adjustedPath)) { consumer.consume(adjustedPath); } } }); }
public void rebuildSdksListAndSelectSdk(final Sdk selectedSdk) { final List<Sdk> sdks = ProjectJdkTable.getInstance().getSdksOfType(AndroidSdkType.getInstance()); final JComboBox sdksComboBox = getComboBox(); sdksComboBox.setModel(new DefaultComboBoxModel(sdks.toArray())); if (selectedSdk != null) { for (Sdk candidateSdk : sdks) { if (candidateSdk != null && candidateSdk.getName().equals(selectedSdk.getName())) { sdksComboBox.setSelectedItem(candidateSdk); return; } } } sdksComboBox.setSelectedItem(null); }
@Nullable public static Sdk createNewAndroidPlatform(@NotNull IAndroidTarget target, @NotNull String sdkPath, @NotNull String sdkName, @Nullable Sdk jdk, boolean addRoots) { ProjectJdkTable table = ProjectJdkTable.getInstance(); String tmpName = createUniqueSdkName(SDK_NAME, Arrays.asList(table.getAllJdks())); final Sdk sdk = table.createSdk(tmpName, AndroidSdkType.getInstance()); SdkModificator sdkModificator = sdk.getSdkModificator(); sdkModificator.setHomePath(sdkPath); sdkModificator.commitChanges(); setUpSdk(sdk, sdkName, table.getAllJdks(), target, jdk, addRoots); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { ProjectJdkTable.getInstance().addJdk(sdk); } }); return sdk; }
private static void setupPlatform(@NotNull Module module) { String targetHashString = getTargetHashStringFromPropertyFile(module); if (targetHashString != null && findAndSetSdkWithHashString(module, targetHashString)) { return; } PropertiesComponent component = PropertiesComponent.getInstance(); if (component.isValueSet(DEFAULT_PLATFORM_NAME_PROPERTY)) { String defaultPlatformName = component.getValue(DEFAULT_PLATFORM_NAME_PROPERTY); Sdk defaultLib = ProjectJdkTable.getInstance().findJdk(defaultPlatformName, AndroidSdkType.getInstance().getName()); if (defaultLib != null && tryToSetAndroidPlatform(module, defaultLib)) { return; } } for (Sdk sdk : getAllAndroidSdks()) { AndroidPlatform platform = AndroidPlatform.getInstance(sdk); if (platform != null && checkSdkRoots(sdk, platform.getTarget(), false) && tryToSetAndroidPlatform(module, sdk)) { component.setValue(DEFAULT_PLATFORM_NAME_PROPERTY, sdk.getName()); return; } } }
@Nullable public static Sdk findAppropriateAndroidPlatform(@NotNull IAndroidTarget target, @NotNull AndroidSdkData sdkData, boolean forMaven) { for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) { String homePath = sdk.getHomePath(); if (homePath != null && isAndroidSdk(sdk)) { AndroidSdkData currentSdkData = getSdkData(homePath); if (sdkData.equals(currentSdkData)) { AndroidSdkAdditionalData data = getAndroidSdkAdditionalData(sdk); if (data != null) { IAndroidTarget currentTarget = data.getBuildTarget(currentSdkData); if (currentTarget != null && target.hashString().equals(currentTarget.hashString()) && checkSdkRoots(sdk, target, forMaven)) { return sdk; } } } } } return null; }
@Nullable public Sdk getJavaSdk() { final ProjectJdkTable jdkTable = ProjectJdkTable.getInstance(); if (myJavaSdk == null) { if (myJavaSdkName != null) { myJavaSdk = jdkTable.findJdk(myJavaSdkName); myJavaSdkName = null; } else { for (Sdk jdk : jdkTable.getAllJdks()) { if (Jdks.isApplicableJdk(jdk)) { myJavaSdk = jdk; break; } } } } return myJavaSdk; }
@Override public void run() { final Set<String> sdkNames = getSdkNamesFromModules(myProblemModules); if (sdkNames.size() == 1) { final Sdk sdk = ProjectJdkTable.getInstance().findJdk(sdkNames.iterator().next()); if (sdk != null && sdk.getSdkType() instanceof AndroidSdkType) { final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(myProject); if (ShowSettingsUtil.getInstance().editConfigurable(myProject, config, new Runnable() { @Override public void run() { config.select(sdk, true); } })) { askAndRebuild(myProject); } return; } } final String moduleToSelect = myProblemModules.size() > 0 ? myProblemModules.iterator().next().getName() : null; if (ModulesConfigurator.showDialog(myProject, moduleToSelect, ClasspathEditor.NAME)) { askAndRebuild(myProject); } }
@Nullable public static Sdk chooseOrCreateJavaSdk(@Nullable LanguageLevel langLevel) { if (langLevel == null) { langLevel = DEFAULT_LANG_LEVEL; } for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) { if (isApplicableJdk(sdk, langLevel)) { return sdk; } } String jdkHomePath = getJdkHomePath(langLevel); if (jdkHomePath != null) { return createJdk(jdkHomePath); } return null; }
@Override protected void setUp() throws Exception { super.setUp(); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { ProjectJdkTable jdkTable = ProjectJdkTable.getInstance(); Sdk defaultJdk = jdkTable.createSdk(ANDROID, AndroidSdkType.getInstance()); jdkTable.addJdk(defaultJdk); mySdks.add(defaultJdk); Project defaultProject = ProjectManager.getInstance().getDefaultProject(); ProjectRootManager.getInstance(defaultProject).setProjectSdk(defaultJdk); } }); }
public void testSatisfied() throws Exception { ProjectSdksModel model = new ProjectSdksModel(); model.addSdk(IdeaTestUtil.getMockJdk17()); ProjectJdkTable jdkTable = ProjectJdkTable.getInstance(); Sdk sdk = jdkTable.createSdk("a", AndroidSdkType.getInstance()); mySdks.add(sdk); jdkTable.addJdk(sdk); AnAction action = getAddAction(model); try { action.actionPerformed(new TestActionEvent(action)); fail("Exception should be thrown"); } catch (Exception e) { assertEquals(AndroidBundle.message("cannot.parse.sdk.error"), e.getMessage()); } }
private void doTestSdkVersionAttributeValueCompletion() throws Throwable { final ProjectJdkTable projectJdkTable = ProjectJdkTable.getInstance(); final Sdk sdk = ModuleRootManager.getInstance(myModule).getSdk(); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { projectJdkTable.addJdk(sdk); } }); try { doTestCompletionVariants(getTestName(true) + ".xml", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "MNC"); } finally { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { projectJdkTable.removeJdk(sdk); } }); } }
@Override public void setUp() throws Exception { myJdkHome = IdeaTestUtil.requireRealJdkHome(); super.setUp(); assumeThat(gradleVersion, versionMatcherRule.getMatcher()); new WriteAction() { @Override protected void run(@NotNull Result result) throws Throwable { Sdk oldJdk = ProjectJdkTable.getInstance().findJdk(GRADLE_JDK_NAME); if (oldJdk != null) { ProjectJdkTable.getInstance().removeJdk(oldJdk); } VirtualFile jdkHomeDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(myJdkHome)); Sdk jdk = SdkConfigurationUtil.setupSdk(new Sdk[0], jdkHomeDir, JavaSdk.getInstance(), true, null, GRADLE_JDK_NAME); assertNotNull("Cannot create JDK for " + myJdkHome, jdk); ProjectJdkTable.getInstance().addJdk(jdk); } }.execute(); myProjectSettings = new GradleProjectSettings(); GradleSettings.getInstance(myProject).setGradleVmOptions("-Xmx64m -XX:MaxPermSize=64m"); System.setProperty(ExternalSystemExecutionSettings.REMOTE_PROCESS_IDLE_TTL_IN_MS_KEY, String.valueOf(GRADLE_DAEMON_TTL_MS)); configureWrapper(); }
@Override public void tearDown() throws Exception { if (myJdkHome == null) { //super.setUp() wasn't called return; } try { new WriteAction() { @Override protected void run(@NotNull Result result) throws Throwable { Sdk old = ProjectJdkTable.getInstance().findJdk(GRADLE_JDK_NAME); if (old != null) { SdkConfigurationUtil.removeSdk(old); } } }.execute(); Messages.setTestDialog(TestDialog.DEFAULT); FileUtil.delete(BuildManager.getInstance().getBuildSystemDirectory()); } finally { super.tearDown(); } }
@Override protected void setupJdk(Element root, ModifiableRootModel model, @Nullable Sdk sdk) { final String inheritJdk = root.getAttributeValue(INHERIT_JDK); if (inheritJdk != null && Boolean.parseBoolean(inheritJdk)) { model.inheritSdk(); } else { final String jdkName = root.getAttributeValue("jdk"); if (jdkName != null) { final Sdk jdkByName = ProjectJdkTable.getInstance().findJdk(jdkName); if (jdkByName != null) { model.setSdk(jdkByName); } } } }
@Override protected void setUpModuleJdk(ModifiableRootModel rootModel, Collection<String> unknownJdks, EclipseModuleManager eclipseModuleManager, String jdkName) { if (jdkName == null) { rootModel.inheritSdk(); } else { final Sdk moduleJdk = ProjectJdkTable.getInstance().findJdk(jdkName); if (moduleJdk != null) { rootModel.setSdk(moduleJdk); } else { rootModel.setInvalidSdk(jdkName, IdeaXml.JAVA_SDK_TYPE); eclipseModuleManager.setInvalidJdk(jdkName); unknownJdks.add(jdkName); } } rearrangeOrderEntryOfType(rootModel, JdkOrderEntry.class); }
@Nullable public final Sdk getTargetJdk() { final XmlTag tag = getXmlTag(); final PsiFile containingFile = tag.getContainingFile(); final AntBuildFileImpl buildFile = (AntBuildFileImpl)AntConfigurationBase.getInstance(containingFile.getProject()).getAntBuildFile(containingFile); if (buildFile != null) { String jdkName = AntBuildFileImpl.CUSTOM_JDK_NAME.get(buildFile.getAllOptions()); if (jdkName == null || jdkName.length() == 0) { jdkName = AntConfigurationImpl.DEFAULT_JDK_NAME.get(buildFile.getAllOptions()); } if (jdkName != null && jdkName.length() > 0) { return ProjectJdkTable.getInstance().findJdk(jdkName); } } return ProjectRootManager.getInstance(tag.getProject()).getProjectSdk(); }
@Nullable public Sdk getJavaSdk() { final ProjectJdkTable jdkTable = ProjectJdkTable.getInstance(); if (myJavaSdk == null) { if (myJavaSdkName != null) { myJavaSdk = jdkTable.findJdk(myJavaSdkName); myJavaSdkName = null; } else { for (Sdk jdk : jdkTable.getAllJdks()) { if (IdeaJdk.isValidInternalJdk(myCurrentJdk, jdk)) { myJavaSdk = jdk; break; } } } } return myJavaSdk; }
@Override public void readExternal(Element element) throws InvalidDataException { super.readExternal(element); // Target is persisted as a tag to permit multiple targets in the future. Element targetElement = element.getChild(TARGET_TAG); if (targetElement != null && !Strings.isNullOrEmpty(targetElement.getTextTrim())) { target = (Label) TargetExpression.fromStringSafe(targetElement.getTextTrim()); } else { target = null; } blazeFlags.readExternal(element); exeFlags.readExternal(element); String sdkName = element.getAttributeValue(SDK_ATTR); if (!Strings.isNullOrEmpty(sdkName)) { pluginSdk = ProjectJdkTable.getInstance().findJdk(sdkName); } vmParameters = Strings.emptyToNull(element.getAttributeValue(VM_PARAMS_ATTR)); programParameters = Strings.emptyToNull(element.getAttributeValue(PROGRAM_PARAMS_ATTR)); String keepInSyncString = element.getAttributeValue(KEEP_IN_SYNC_TAG); keepInSync = keepInSyncString != null ? Boolean.parseBoolean(keepInSyncString) : null; }
public OCamlToolWindowSettingsForm(@NotNull final Project project) { myProject = project; final List<Sdk> allSdks = ProjectJdkTable.getInstance().getSdksOfType(OCamlSdkType.getInstance()); allSdks.add(0, null); mySdkComboBox.setModel(new CollectionComboBoxModel(allSdks, null)); mySdkComboBox.setRenderer(new SdkListCellRenderer("<Project Default>")); myConfigureButton.addActionListener(new ActionListener() { public void actionPerformed(@NotNull final ActionEvent e) { final ProjectJdksEditor editor = new ProjectJdksEditor((Sdk) mySdkComboBox.getSelectedItem(), myProject, mySdkComboBox); editor.show(); if (editor.isOK()) { setSelectedSdk(editor.getSelectedJdk()); } } }); final FileChooserDescriptor workingDirChooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false); workingDirChooserDescriptor.setRoot(myProject.getBaseDir()); myWorkingDirectoryEditor.addBrowseFolderListener("Select Working Directory", "", myProject, workingDirChooserDescriptor); }
public void loadState(@NotNull final OCamlState state) { final String systemIndependentHomePath = state.getTopLevelSdkHomePath(); if (systemIndependentHomePath == null) { myTopLevelSdk = null; } else { final List<Sdk> ocamlSdks = ProjectJdkTable.getInstance().getSdksOfType(OCamlSdkType.getInstance()); for (final Sdk ocamlSdk : ocamlSdks) { if (systemIndependentHomePath.equals(FileUtil.toSystemIndependentName(ocamlSdk.getHomePath()))) { myTopLevelSdk = ocamlSdk; break; } } } myTopLevelCmdParams = OCamlStringUtil.getNotNull(state.getTopLevelCmdOptions()); myTopLevelCmdWorkingDir = OCamlStringUtil.getNotNull(state.getTopLevelCmdWorkingDir()); }
/** * Find if pants sdk is already configured, return the existing sdk if it exists, * otherwise add to the config and return. */ private Sdk addIfNotExists(final Sdk pantsSdk) { final JavaSdk javaSdk = JavaSdk.getInstance(); List<Sdk> sdks = ProjectJdkTable.getInstance().getSdksOfType(javaSdk); for (Sdk sdk : sdks) { if (javaSdk.getVersion(sdk) == javaSdk.getVersion(pantsSdk)) { return sdk; } } ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { ProjectJdkTable.getInstance().addJdk(pantsSdk); } }); return pantsSdk; }
public void testFindJdk() { final File executable = PantsUtil.findPantsExecutable(getProjectFolder()).get(); assertEquals(Lists.newArrayList(), getAllJdks().collect(Collectors.toList())); final Sdk sdkA = getDefaultJavaSdk(executable.getPath()).get(); assertEquals(Lists.newArrayList(sdkA), getSameJdks(sdkA)); final List<Sdk> singleSdkInTable = getSameJdks(sdkA); assertTrue(singleSdkInTable.get(0).getName().contains("pants")); final List<Sdk> twoEntriesSameSdk = Lists.newArrayList(sdkA, sdkA); // manually adding the same jdk to the table should result in two identical // entries ApplicationManager.getApplication().runWriteAction(() -> { // no need to use disposable here, because this should not add a new jdk ProjectJdkTable.getInstance().addJdk(sdkA); }); assertEquals(twoEntriesSameSdk, getSameJdks(sdkA)); // calling getDefaultJavaSdk should only add a new entry to the table if it // needs to make one final Sdk sdkB = getDefaultJavaSdk(executable.getPath()).get(); // Make sure they are identical, meaning that no new JDK was created on the 2nd find. assertTrue(sdkA == sdkB); assertEquals(twoEntriesSameSdk, getSameJdks(sdkA)); }
/** * @return cesta k JRE */ private String getJrePath() //TODO: Udělat nějak eleganěnji. Například stahovat vždy cele JRE do alternativního adresáře { SdkTypeId id = ProjectJdkTable.getInstance().getDefaultSdkType() ; if ( id != null ) { List<Sdk> sdk = ProjectJdkTable.getInstance().getSdksOfType(ProjectJdkTable.getInstance().getDefaultSdkType()) ; if ( ! sdk.isEmpty() ) { return modifyForAlternativeJvm( sdk.get(0).getHomePath() + File.separatorChar ) ; } } return getPluginDescriptor().getPath().getAbsolutePath() + File.separatorChar + GITHUB_PROJECT + File.separatorChar ; }
@Nullable private Sdk findDefracSdk() { final Sdk projectSdk = DefracProjectUtil.getProjectSdk(getProject()); if(DefracSdkUtil.isDefracSdk(projectSdk)) { return projectSdk; } final Sdk[] sdks = ProjectJdkTable.getInstance().getAllJdks(); for(final Sdk sdk : sdks) { if(DefracSdkUtil.isDefracSdk(sdk)) { return sdk; } } return null; }
@Nullable public Sdk getJavaSdk() { if(javaSdk != null) { return javaSdk; } final ProjectJdkTable jdkTable = ProjectJdkTable.getInstance(); if(!isNullOrEmpty(javaSdkName)) { javaSdk = jdkTable.findJdk(javaSdkName); javaSdkName = null; } else { for(final Sdk jdk : jdkTable.getAllJdks()) { if(isApplicableJdk(jdk)) { javaSdk = jdk; break; } } } return javaSdk; }
@Override public void tearDown() throws Exception { if (myWizard != null) { Disposer.dispose(myWizard.getDisposable()); } if (myCreatedProject != null) { myProjectManager.closeProject(myCreatedProject); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { Disposer.dispose(myCreatedProject); } }); } ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { for (Sdk sdk : mySdks) { ProjectJdkTable.getInstance().removeJdk(sdk); } } }); SelectTemplateSettings.getInstance().setLastTemplate(null, null); super.tearDown(); }
public static void selectSdkHome(final SdkType sdkType, @NotNull final Consumer<String> consumer) { final FileChooserDescriptor descriptor = sdkType.getHomeChooserDescriptor(); if (ApplicationManager.getApplication().isUnitTestMode()) { Sdk sdk = ProjectJdkTable.getInstance().findMostRecentSdkOfType(sdkType); if (sdk == null) throw new RuntimeException("No SDK of type " + sdkType + " found"); consumer.consume(sdk.getHomePath()); return; } FileChooser.chooseFiles(descriptor, null, getSuggestedSdkRoot(sdkType), new Consumer<List<VirtualFile>>() { @Override public void consume(final List<VirtualFile> chosen) { final String path = chosen.get(0).getPath(); if (sdkType.isValidSdkHome(path)) { consumer.consume(path); return; } final String adjustedPath = sdkType.adjustSelectedSdkHome(path); if (sdkType.isValidSdkHome(adjustedPath)) { consumer.consume(adjustedPath); } } }); }
@Override protected void setUpJdk() { super.setUpJdk(); new WriteAction() { protected void run(final Result result) { ProjectJdkTable table = ProjectJdkTable.getInstance(); myPluginSdk = table.createSdk("IDEA plugin SDK", SdkType.findInstance(IdeaJdk.class)); SdkModificator modificator = myPluginSdk.getSdkModificator(); modificator.setSdkAdditionalData(new Sandbox(getSandboxPath(), getTestProjectJdk(), myPluginSdk)); String rootPath = FileUtil.toSystemIndependentName(PathManager.getJarPathForClass(FileUtilRt.class)); modificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByPath(rootPath), OrderRootType.CLASSES); modificator.commitChanges(); table.addJdk(myPluginSdk); } }.execute(); }
public static Sdk getDefaultJDK(){ Sdk[] allJdks = ProjectJdkTable.getInstance().getAllJdks(); if (allJdks == null || allJdks.length == 0) { throw new RuntimeException("Please setup your project JDK first"); } Sdk jdk = allJdks[0]; return jdk; }