1

为 IDEA 2019.1 构建工作就像一个魅力!我认为为 2020.3 构建只是指向 2020.3 安装文件夹的问题,仅此而已,但它甚至没有接近它。

那是我的gradle.build

group 'com.test.plugin'
version '1.0-SNAPSHOT'

buildscript {
    repositories {        
        maven {
            url "https://mydomain/repository/public-maven/"
        }
    }

    dependencies {
        classpath group: 'org.jetbrains.intellij.plugins', name: 'gradle-intellij-plugin', version: '0.6.5'
    }
}

apply plugin: 'java'
apply plugin: 'org.jetbrains.intellij'

intellij {
    localPath 'C:/Program Files/JetBrains/IntelliJ IDEA 2019.1.3'
}

sourceCompatibility = 1.8

repositories {
    maven {
        url "https://mydomain/repository/public-maven/"
    }
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    runtime group: 'com.google.guava', name: 'guava', version: '23.0'
    runtime group: 'org.apache.commons', name: 'commons-lang3', version: '3.11'
}

值得一提的是,由于我在受限制的公司代理后面工作,我不能只设置 Intellij 版本来获取构建所需的分发文件(Intellij.localPath)

在 IDEA 2019.1 上构建它,JDK 1.8 运行良好。为了为 IDEA 2020.3 构建相同的代码,我刚刚替换了 Intellij 分发路径:

intellij {
    //localPath 'C:/Program Files/JetBrains/IntelliJ IDEA 2019.1.3'
    localPath 'C:/Dev/apps/ideaIU-2020.3'
}

现在尝试构建它会立即抛出它:

error: cannot access AnAction
bad class file: C:\Dev\apps\ideaIU-2020.3\lib\platform-api.jar(com/intellij/openapi/actionSystem/AnAction.class)
class file has wrong version 55.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.

我的理解是 AnAction 类是使用 Java 11 构建的。因此,我将项目 JDK 替换为也使用 JDK11,从那一刻起,我开始面临编译错误,例如找不到 com.intellij.psi.PsiJavaFile

我可能在这里遗漏了一些概念点。

4

1 回答 1

0

事实证明缺少插件依赖项。

这条线对解决这种依赖没有效果。为了解决这个问题,我必须删除apply plugin: 'java'并设置 intellij.plugin

intellij {    
    localPath 'C:/Dev/apps/ideaIU-2020.3'
    plugin = ['com.intellij.java']
}
于 2020-12-19T18:00:34.360 回答