Unresolved reference when running gradle:runIde
Hello friends,
I'm attempting to create an IDE plugin to no avail. The documentation was of no help, and googling IntelliJ plugin development issues brings up results from 2004.
- I've created the git repository from your template (https://github.com/JetBrains/intellij-platform-plugin-template)
- in Project Structure, I've set the project SDK to IntelliJ IDEA Community Edition IC-232.10227.8
- my main module is also set up to use the same SDK (please see attached screenshots)
- i have commented out everything except for the java, kotlin, and gradle intellij plugin in my build.gradle.kts thinking that there may be an issue with it
When I run the "Run Plugin" gradle task, which should be :runIde, I get an error -> "Unresolved reference: PsiJavaFile". There's nothing red in the editor, the file was imported just fine. Autocomplete worked on it, but it just won't compile.
What am I missing?
Logs Upload ID: https://uploads.jetbrains.com/browse#2023_11_22_JYnhcsFXKa6nVB4GmiFspB
请先登录再写评论。
Hi,
Please share full Gradle build script and plugin.xml files.
Hello, Karol.
Arina made the post for me since I posted in the wrong section, my bad.
Here's the build.grade.kts
And here's the plugin.xml, it's pretty scarce.
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
<idea-plugin>
<id>com.github.mijamarko.apiforge</id>
<name>API Forge</name>
<vendor>mijamarko</vendor>
<depends>com.intellij.modules.platform</depends>
<!-- Description of the plugin displayed on the Plugin Page and IDE Plugin Manager.
Simple HTML elements (text formatting, paragraphs, and lists) can be added inside of <![CDATA[ ]]> tag.
Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-description -->
<description> Fast API development and data mocking for your Spring Boot applications. Make requests right from IntelliJ Idea </description>
<extensions defaultExtensionNs="com.intellij">
<toolWindow factoryClass="com.github.mijamarko.apiforge.window.MainWindowFactory" id="API Forge"/>
<postStartupActivity implementation="com.github.mijamarko.apiforge.activities.ProjectOpenedActivity"/>
</extensions>
</idea-plugin>
Please let me know if you need anything else.
Thanks!
Hi Marko,
What plugins do you depend on? I mean platformPlugins - please share gradle.properties file too.
Hello again,
This is what it looks like. No platform plugins specified, basically a barebones gradle.properties file.
Now that I read the comments in the file it looks like I'm supposed to specify exactly which plugins I need, correct? So, in my case, that would be something like com.intellij.psi? Any way to automate adding plugins to the platformPlugins property at compile time?
Thanks
PsiJavaFile
is a part of the Java plugin, so you should add a dependency on it. I don't know why it was not reported as an error in the editor, but the compilation error is correct. Maybe there was an editor glitch. You can try invalidating caches by triggering the File | Invalidate Caches… action.In gradle.properties, you should define:
platformPlugins = com.intellij.java
.In plugin.xml add
<depends>com.intellij.java</depends>
.For more information about adding a plugin dependency, see: https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
Yep, just added it myself a minute ago and now I'm feeling very stupid.
I've also added the <depends>com.intellij.java</depends> to my plugin.xml → is that overkill?
Sorry for the trouble, first time using gradle after maven.
No, it is required so that your plugin sees Java plugin classes at runtime.
You are welcome to ask questions. Consider using our community Slack in the beginning. The link is on this page: https://plugins.jetbrains.com/docs/intellij/getting-help.html
Thank you very much, Karol.
All the best,
Marko Mijajlović