1.需要安装gradle
2.插件开发
3.项目目录
4.plugin.xml
<idea-plugin> <!--插件id--> <id>com.xiaokai.test.demo</id> <!--插件名称--> <name>Demo</name> <!--开发者信息--> <!--插件说明--> <!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html on how to target different products --> <!-- uncomment to enable plugin in all products <depends>com.intellij.modules.lang</depends> --> <!--依赖的其他插件能力--> <extensions defaultExtensionNs="com.intellij"> <!-- Add your extensions here --> </extensions> <!--插件动作--> <actions> <group id="HelloWorld" text="_HelloWorld"> <add-to-group group-id="MainMenu" anchor="last"/> </group> <action class="com.vince.test.HelloWorldAction" id="menuAction" text="menu action"> <add-to-group group-id="HelloWorld" anchor="first"/> </action> </actions> </idea-plugin>
5.代码
package com.vince.test; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.ui.Messages; public class HelloWorldAction extends AnAction { @Override public void actionPerformed(AnActionEvent e) { Messages.showInfoMessage("Hello World!", "First Plugin"); } }
6.运行结果
代码地址:
zhugezifang/idea-test-plugin: idea plugin hello world (github.com)
参考:
IntelliJ-IDEA-Tutorial/plugins-develop.md at master · judasn/IntelliJ-IDEA-Tutorial (github.com)
IDEA 插件开发入门教程 - Sharehub (xiaohansong.com)