How to use classes of pythonPlugin? always compile failed, say can't find package
Answered
I create a gradle plugin project, by the document way(https://plugins.jetbrains.com/docs/intellij/gradle-guide.html)。Then I add the python's depend:
<depends>com.intellij.modules.python</depends>
But it report an error:
Cannot resolve plugin 'com.intellij.modules.python' in dependencies (Reference: Plugin Dependencies)
I find a way to resolve it: https://intellij-support.jetbrains.com/hc/en-us/community/posts/4416336449554-The-lack-of-python-jar-python-ce-jar-in-IntelliJ-Platform-Plugin-SDK-cause-a-error-of-resovle-plugin-depends-com-intellij-modules-python-
But when I build the project (use intellj.buildPlugin), it reported an error:
错误: 程序包com.jetbrains.python.psi不存在 (Error: Package com.jetbrains.python.psi does not exist)
import com.jetbrains.python.psi.PyFunction;
^
How can I fix the error ? I want to use the Python PSI in my Plugin.
Thanks for your answer !
Please sign in to leave a comment.
You must set/add Python dependencies as described here first: https://plugins.jetbrains.com/docs/intellij/pycharm.html
Hi Yann Cebron,
Thanks for your help. I have followed the steps to set it up, but still fail. This is my "build.gradle" and "plugin.xml":
Is there anything wrong?
build.gradle
plugins {
id 'org.jetbrains.intellij' version '1.4.0'
id 'java'
}
group 'com.sannmizu.example'
version '1.0-SNAPSHOT'
sourceCompatibility = 11
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version = '2021.3.2'
type = 'PC'
downloadSources = false
sandboxDir = 'D:\\Project\\Sandbox'
}
patchPluginXml {
changeNotes = """
Add change notes here.<br>
<em>most HTML tags may be used</em>"""
}
test {
useJUnitPlatform()
}
plugin.xml
I find that add the dependency to the "PythonCore" can resovle it:
https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html#3-dependency-declaration-in-pluginxml
Dose this complict with the description "No specific declaration is needed to use
PYorPCAPIs." ?