A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://plugins.jetbrains.com/docs/intellij/sdk.html below:

SDK | IntelliJ Platform Plugin SDK

SDK

Every project uses a Software Development Kit (SDK). For Java projects, the SDK is referred to as the JDK (Java Development Kit). The SDK determines which API library is used to build the project. If a project is multi-module, the project SDK by default is common for all modules within the project. Optionally, individual SDKs for each module can be configured.

Working with SDKs

The Workspace Model API is available since 2024.2 for use by third-party plugins and should be preferred over using the Project Model API.

See Interoperability with Project Model API and Usage Examples.

Getting Project SDK Information

The information about the project SDK is accessed via ProjectRootManager like the following example shows

Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk();

Getting and Setting Project SDK Attributes

See the project_model code sample to get more familiar with the SDK manipulation toolset.

Available SDKs

ProjectJdkTable can be used to query and modify configured SDKs.

Working with a Custom SDK

To create a custom SDK, provide a class extending SdkType, leave saveAdditionalData() blank, and register it in the com.intellij.sdkType extension point.

To make SDK settings persistent, override setupSdkPaths() and save settings by modificator.commitChanges():

@Override public boolean setupSdkPaths(@NotNull Sdk sdk, @NotNull SdkModel sdkModel) { SdkModificator modificator = sdk.getSdkModificator(); modificator.setVersionString(getVersionString(sdk)); modificator.commitChanges(); // save return true; }

To let a user select an SDK, see ProjectJdksEditor.

However, it is not recommended to use "SDK" in non-IntelliJ IDEA IDEs. Although "SDK" is available in most JetBrains products, ProjectJdksEditor is specific to Java, making the operation around "SDK" difficult. The recommended way of managing "SDK" settings is to create a CustomStepProjectGenerator implementation and save settings in a PersistentStateComponent.

Assisting in Setting Up an SDK

Prompting the user with a notification to set up an SDK can help them get up-and-running with a plugin faster. Use com.intellij.projectSdkSetupValidator extension point to register an implementation of ProjectSdkSetupValidator to notify the user if they are missing an SDK.

The following is a simplified example that checks whether an instance of "DemoSdk" has been configured in the project when the user opens a "DemoFileType":

internal class DemoProjectSdkSetupValidator : ProjectSdkSetupValidator { override fun isApplicableFor(project: Project, file: VirtualFile): Boolean { return file.fileType == DemoFileType } override fun getErrorMessage(project: Project, file: VirtualFile): String? { if (ProjectJdkTable.getInstance().getSdksOfType(DemoSdkType.getInstance()).isEmpty()) { return "No DemoSdks are configured for this project!" } return null } override fun getFixHandler(project: Project, file: VirtualFile): EditorNotificationPanel.ActionHandler { return SdkPopupFactory.newBuilder() .withProject(project) .withSdkTypeFilter { it is DemoSdkType } .updateSdkForFile(file) .buildEditorNotificationPanelHandler() } }

Within DemoProjectSdkSetupValidator:

ProjectSdkSetupValidator will not work in IntelliJ Platform-based IDEs such as PyCharm. In such cases, you should register an implementation of EditorNotificationProvider via com.intellij.editorNotificationProvider extension point and override the createNotificationPanel() method with the conditionality and panel setup you want.

23 June 2025


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4