idea插件开发实战基础

插件代码

码云地址

新建项目

在这里插入图片描述

修改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>
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值