Get Gradle project information in plugin
已回答
Hello,
Maybe someone can help with the next questions:
1. In my plugin, I need to check is a project is a Gradle project.
2. If it's Gradle project plugin need to get all Gradle dependencies.
3. Handle events if Gradle dependencies changed.
If you can suggest something, please write.
Thank you!
Best regards,
Alexander.
请先登录再写评论。
Gradle plugin is based on External System: http://www.jetbrains.org/intellij/sdk/docs/reference_guide/frameworks_and_external_apis/external_system_integration.html
1. GradleSettings.getInstance(project).getLinkedProjectsSettings().isEmpty()
2. Find gradle
DataNode<ModuleData>, for example byorg.jetbrains.plugins.gradle.util.GradleUtil#findGradleModuleData(com.intellij.openapi.module.Module)And under this node, Find children data nodes with keys
com.intellij.openapi.externalSystem.model.ProjectKeys#MODULE_DEPENDENCYandcom.intellij.openapi.externalSystem.model.ProjectKeys#LIBRARY_DEPENDENCY3. use
com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListenerAdapter#onEndand filter resolve task by idid.getType() == ExternalSystemTaskType.RESOLVE_PROJECTThank you for your help and time!
I tried org.jetbrains.plugins.gradle.util.GradleUtil#findGradleModuleData(com.intellij.openapi.module.Module)
But in my project, it does not see this method in GradleUtil. I found this method in intellij-community and it has @ApiStatus.Experimental annotation. Maybe you know how can I fix this and use this method? Or some other solution?
Thank you!
This method was added on 21.August 2019, so it depends on target platform version you're choosing. Simply copy/paste it to your plugin would work as well :)
Thank you! Will try this idea :)
Are the `GradleSettings` and `GradleUtil` located in the gradle plugin jar for intellij? When building an intellij plugin via gradle-intellij-plugin, how do I include this dependency in my classpath?
mystarrocks See http://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_dependencies.html on how to include additional plugins as dependency. In this case, use syntax for bundled plugin.