插件代码
新建项目
修改build.gradle
原始文件如下内容,需要进行改造,否则编译不通过
改造后文件内容(,如下,要加上=
build.gradle拓展
- 指定plugins的环境版本及源码编译版本
plugins {
id 'java'
// id 'org.jetbrains.intellij' version '1.3.0'
id 'org.jetbrains.intellij' version '1.1'
}
group 'com.code.template'
version '1.0'
// 高版本默认使用java11,为了避免不兼容的问题
sourceCompatibility = 1.8
- 指定导出的插件支持的IDE最小版本
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
// 这里指定支持的IDE最小版本
version = '2019.1'
// 配合这个参数,屏蔽插件安装时报的错:Plugin is not compatible with the current version of the IDE
// updateSinceUntilBuild也可以在plugin.xml配置 <idea-version since-build="191.0"/>
// 其中191.0表示2019.1月发布的版本,0表示无限大的版本
updateSinceUntilBuild = false
}
plugin.xml
<idea-plugin>
<!-- 插件唯一标识,用于在插件市场中唯一确定身份的标识,在不同版本中,必须保持一致,建议设置值为:包名 + 插件名称 -->
<id>应用市场唯一标识</id>
<!-- 插件的名称,显示在IDEA已安装插件列表中 -->
<name>IDEA已安装插件列表中的插件名称</name>
<!-- -->
<vendor email=""></vendor>
<!-- 指定导出的插件支持的IDE最小版本,在build.gradle中有提到。其中191.0表示2019.1月发布的版本,0表示无限大的版本 -->
<!-- <idea-version since-build="191.0"/>-->
<!-- 插件的描述,会在插件列表中显示这块的内容 -->
<description>
<![CDATA[
<h2>标题</h2>
<ul>
<li>xxx</li>
<li>xxx</li>
<li>xxx</li>
</ul>
支持的idea版本:2019.1及以上版本。
]]>
</description>
<!-- please see https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html
on how to target different products -->
<depends>com.intellij.modules.platform</depends>
<!-- 可以配置侧边的工具栏,例如maven所在的侧边栏 -->
<extensions defaultExtensionNs="com.intellij">
<!-- 配置侧边工具栏,当且仅当第一次点击时,会初始化窗口类,anchor指定工具栏的位置 -->
<toolWindow id="Code2Template" factoryClass="com.idea.plugin.window.WindowFactory" secondary="true"
anchor="right">
</toolWindow>
</extensions>
<!-- 配置动作(事件),每次点击都会重新初始化 -->
<actions>
<!-- 配置动作触发类,触发这个类时,在构造器里新建一个javax.swing.JPanel窗口,这样就完成一次idea和窗口的交互 -->
<action id="Code2TemplateAction" class="com.idea.plugin.action.InitAction"
text="Code2Template" description="Code to Template">
<!-- 配置菜单类别,ProjectViewPopupMenu:鼠标右键点击项目任意文件,触发窗口弹出 -->
<add-to-group group-id="ProjectViewPopupMenu" anchor="last"/>
</action>
<action id="Code2TemplatePopupAction" class="com.idea.plugin.action.PopupAction" text="Code2Template"
description="Code to Template">
<!-- 配置菜单类别,EditorPopupMenu:鼠标右键点击任意文件内容,触发窗口弹出 -->
<add-to-group group-id="EditorPopupMenu" anchor="last"/>
</action>
</actions>
</idea-plugin>