I have an IntelliJ plugin, which was created from the github-template, that cannot resolve the class com.intellij.psi.PsiJavaFile.
Has anyone else run into this and figured out what needs to be configured?
I'm new to IntelliJ plugin development. I followed the instructions detailed at https://plugins.jetbrains.com/docs/intellij/github-template.html to create a plugin.
I imported the generated plugin into IntelliJ and everything seems OK. No compile warnings, etc..., but when I try to use the class com.intellij.psi.PsiJavaFile, IntelliJ says it cannot resolve the class.
I imagine I'm missing a configuration somewhere that tells IntelliJ which libraries to import, but I'm not finding it in the documentation.
You're probably missing the dependency on the Java intellij plugin, which is not enabled by default as you won't need it for every custom plugin.
Add com.intellij.java to the platformPlugins section of the gradle.properties file:
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = com.intellij.java
To address that the IDE cannot resolve PsiJavaClass specifically, I don't think it exists. Are you looking for PsiJavaFile or PsiClass?
Related
I am writing a small plugin for PhpStorm. During development, I run it in IDEA and everything works fine there. However, after I try to enable it in PhpStorm I get the following error:
Plugin 'name' is compatible with IntelliJ IDEA only because it doesn't define any explicit module dependencies
How can this problem be solved?
The documentation plugin compatibility says that if your plugin does not have module dependencies (built-in plugins that are non-removable parts of the IDE), then it is considered legacy and will load only in IDEA, as reported by the error message.
In order to fix this error, you need to explicitly add a dependency to one of the modules. For example, com.intellij.modules.platform:
Add the following line to plugin.xml:
<depends>com.intellij.modules.platform</depends>
And the plugin should load successfully in PhpStorm.
I have a plugin defined in my build.gradle like this:
plugins {
id "org.jetbrains.intellij" version "0.2.9"
}
And I want to be able to resolve the sources for the plugin.
Obviously it would be nice if it could happen automatically, but attaching the sources manually is fine at this point. The problem is that there is no reference to the JAR for this plugin anywhere in any setting I could find.
I am developing an idea plugin, and it is an intellij idea project.
I want to use gradle to manage the dependency.
How to config?
There is now a Gradle plugin for building IntelliJ Platform Plugins. In order to use it, you will need to add the following snippet to your build.gradle file.
plugins {
id "org.jetbrains.intellij" version "0.0.31"
}
apply plugin: 'org.jetbrains.intellij'
For more information, please see this guide to help you get started.
Ok, there are multiple ways to create an IntelliJ project, "templates" if you like, and unfortunately you can only pick one of them (IntelliJ plugin or gradle).
Thankfully, it's easy to configure a project for gradle in IntelliJ.
First, create a new project from the IntelliJ Platform Plugin template. You don't need to choose any Additional Libraries and Frameworks. This will give you a project structure including META-INF/plugin.xml and the Project SDK should be something like IDEA IU-129.451.
From here, simply create a new file named build.gradle at the top level of your project, including for example this line:
apply plugin: 'java'
Now, close the project. You can now use File -> Import Project..., choose the build.gradle file that you just created, and import the project. Accept the defaults for importing and hit OK.
The project is now opened with both gradle and intellij plugin enabled!
Notice that the source root src has disappeared and you will need to right click on src in the Project pane and select Mark Directory As -> Source Root.
To prepare the plugin for deployment, there is still the menu option in the Build menu for that - if you want to automate that part via gradle, good luck and please let us know how it's done ;)
I have created a project from maven using mvn idea:idea. I recreate the project whenever there is a significant change to the pom files.
Sometimes after recreating, when I open IntelliJ it tells me that the modules have an unknown type so they will be treated as Unknown Modules.
How do I changes these modules to be the proper type?
Can anyone direct me to documentation about how to specify the module type so that idea:idea will generate the modules properly?
Thanks :)
mvn idea:idea generated projects are not supported, please use the built-in IDEA Maven support instead, it works much better and you have an option to import changed Maven projects automatically or manually.
I have a RCP project where I cannot fix a NoClassDefFoundError: One plugin depends on another plugin. The plugin-dependencies are set in the manifest, packages exported, and there is no error at compile time. Both plugins are in the product dependencies and visible in the installation details of the product.
But when I run the application I get a java.lang.NoClassDefFoundError when the one plugin wants to use a class from the other plugin.
Any hints how to find the reason for this are greatly appreciated.
Thanks,
Michael
I found the problem: I created the plugin which could not be loaded from an existing Java project. And somehow I deleted the "." in the entry Bundle-classpath in the plugin manifest (the plugin has some jars which -> so lib/xyz.jar was in the Bundle-classpath entry but not the ".").
For the class-loader of the bundle the "." means to search for classes from the root path of the bundle (or something like that), so it could not find the classes. However, there were no errors in the IDE so it was hard to find.
Is the configuration for running the application correct i.e. all dependencies are also put in the running configuration?