Custom SDK and JDK in the same project


Hi, I'm developing a custom language plugin for which I have created a custom SDK. I would like that my project is able to support besides my custom files also Java files.

My module builder extends from `com.intellij.ide.util.projectWizard.JavaModuleBuilder`, but when I open a .java file in my custom project, the project cannot resolve the java dependencies because the JDK is not configured as the project SDK.

Is it possible to configure the JDK as a project dependency or as a library? or do I need to include it somehow in my custom SDK? I have looked at the method `com.intellij.openapi.projectRoots.SdkTypeId.saveAdditionalData` but I'm not sure if this is the correct path.

Thanks in advanced, Carmen

Comment actions Permalink

SDK and Libraries are two distinct concepts. Could you please explain how your custom SDK replaces/augments the Java SDK? Did you consider using Facets for your custom setup instead eventually? (

Comment actions Permalink

The Java class library can be accessed from within the custom language, e.g., is possible to instantiate Java classes. Then my custom project needs to have JDK as external library as well. Otherwise java classes are not found.

At the moment I solved the problem adding java classes in my custom SDK with the following code. The developer selects the JDK when creating the project. This way when the project is created in the custom SDK I can have my custom files together with the java classes from the JDK.

I have not consider the facets in the setup yet. Do you think I should consider them over my current solution? Thank you.

for (VirtualFile file : javaSdk.getRootProvider().getFiles(OrderRootType.CLASSES)) {
sdkModificator.addRoot(file, OrderRootType.CLASSES);
Comment actions Permalink

If this solution works well for you, then it's fine. But SDK ofcourse offers more, e.g. link to sources/javadocs etc. you could possibly add.

Facets are more of a specialization/framework configuration for a Module.


Please sign in to leave a comment.