当前位置:   article > 正文

IntelliJ IDEA 2022.2 (Ultimate Edition) plugin插件开发_cannot resolve the latest gradle intellij plugin v

cannot resolve the latest gradle intellij plugin version

1. 创建IDE Plugin工程

在这里插入图片描述

2.修改工程iml文件

这里默认创建的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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

3.修改build.gradle.kts文件

替换为aliyun镜像加快构建速度

repositories {
    maven("https://maven.aliyun.com/nexus/content/groups/public/")
}
  • 1
  • 2
  • 3

升级org.jetbrains.intellij 版本到最新1.9.0版本,避免采坑

plugins {
    id("java")
    id("org.jetbrains.intellij") version "1.9.0"
}
  • 1
  • 2
  • 3
  • 4

4. build项目

可能因为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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

这里为了节省时间,也可以在第一次build成功后,为了避免后面github请求等待超时时间过长,可以设置为离线模式进行build
在这里插入图片描述

5. run起来

不用添加plugin configution 配置,直接点击gradle run plugin脚本即可
在这里插入图片描述

启动成功!
在这里插入图片描述

6. 写个demo

右键直接使用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");
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

点击Run Plugin ,启动完成后Tools工具栏对应出现新增MyAction按钮
在这里插入图片描述
点击后,弹出PsiElement非空,说明跑通了
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/313205?site
推荐阅读
相关标签
  

闽ICP备14008679号