赞
踩
这里默认创建的iml文件module type有问题,需要修改为PLUGIN_MODULE
<?xml version="1.0" encoding="UTF-8"?>
<module type="PLUGIN_MODULE" version="4">
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/resources/META-INF/plugin.xml" />
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
</content>
<orderEntry type="jdk" jdkName="IntelliJ IDEA IU-222.3345.118" jdkType="IDEA JDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
替换为aliyun镜像加快构建速度
repositories {
maven("https://maven.aliyun.com/nexus/content/groups/public/")
}
升级org.jetbrains.intellij 版本到最新1.9.0版本,避免采坑
plugins {
id("java")
id("org.jetbrains.intellij") version "1.9.0"
}
可能因为github请求超时导致如下报错,忽略即可
> Configure project : [gradle-intellij-plugin :MyPlugin] Cannot resolve the latest Gradle IntelliJ Plugin version org.gradle.api.GradleException: Cannot resolve the latest Gradle IntelliJ Plugin version at org.jetbrains.intellij.utils.LatestVersionResolver$Companion.fromGitHub(LatestVersionResolver.kt:31) at org.jetbrains.intellij.IntelliJPlugin.checkPluginVersion(IntelliJPlugin.kt:135) at org.jetbrains.intellij.IntelliJPlugin.apply(IntelliJPlugin.kt:80) at org.jetbrains.intellij.IntelliJPlugin.apply(IntelliJPlugin.kt:68) at ...... > Task :prepareKotlinBuildScriptModel UP-TO-DATE Could not resolve: org.jetbrains:annotations:23.0.0 Could not resolve: org.jetbrains:annotations:23.0.0 BUILD SUCCESSFUL in 1m 15s
这里为了节省时间,也可以在第一次build成功后,为了避免后面github请求等待超时时间过长,可以设置为离线模式进行build
不用添加plugin configution 配置,直接点击gradle run plugin脚本即可
启动成功!
右键直接使用Plugin DevKit插件 new一个Action
生成的action支持直接跳转到对应plugin.xml中配置的地方(对应已经生成好了)
补充action代码,测试验证下PsiElement对象获取
public class MyAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
// TODO: insert action logic here
Project project = e.getProject();
PsiElement element = (PsiElement)e.getData(CommonDataKeys.PSI_ELEMENT);
Messages.showInfoMessage(element.toString(), "Caret Parameters Inside The Editor");
}
}
点击Run Plugin ,启动完成后Tools工具栏对应出现新增MyAction按钮
点击后,弹出PsiElement非空,说明跑通了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。