Intellij - how to make a plugin that can perform IDE actions via a CLI or web service?

隐身守侯 提交于 2021-01-01 04:10:46

问题


I need some help getting started making a specific IntelliJ plugin.

I want to make an IntelliJ plugin that makes it so you can launch intelliJ actions from CLI (or from a web service if it's easier).

For example, I'm done building my project with a gradle script... but i want to get it ready in intelliJ too. Right now I have to do this manually with a point-and-clicks.

Instead I want to have this the ability to externally trigger some IntelliJ commands. In my example I would want to fire off these requests from my gradle script:

  • run-intellij-command {project-path} --action refresh-gradle
  • run-intellij-command {project-path} --action build-project
  • run-intellij-command {project-path} --action start-debugging --configurationName={configuration-name}

Does anyone have an example of how I can get started with this?

Really hoping there is an intellij plugin project that already does something similar like reacting to cli commands or hosts a web service that can be called?

Thanks!

Also created this https://youtrack.jetbrains.com/issue/IDEA-184885 hoping to see this feature become a reality some day


回答1:


You can use the ApplicationStarterEx interface to implement that. Provide a class implementing the interface, and register it in your plugin.xml as the <appStarter> extension point.

To execute your code, use Tools | Create Command-line Launcher, and then run idea <startername> <arguments> from the command line, where startername is what you return from ApplicationStarter.getCommandName().

I'm not aware of any existing open-source plugins that implement similar functionality.



来源:https://stackoverflow.com/questions/48817421/intellij-how-to-make-a-plugin-that-can-perform-ide-actions-via-a-cli-or-web-se

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!