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.

0

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 by org.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_DEPENDENCY and com.intellij.openapi.externalSystem.model.ProjectKeys#LIBRARY_DEPENDENCY

3. use com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListenerAdapter#onEnd and filter resolve task by id id.getType() == ExternalSystemTaskType.RESOLVE_PROJECT

0

Thank 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!

 

 

0

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 :)

0

Thank you! Will try this idea :)

0

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?

0

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.

0

请先登录再写评论。