Search code examples
intellij-plugin

Build Intellij plugin in IDEA 2019.1 & 2020.3


Building for IDEA 2019.1 works like a charm! I thought that building for 2020.3 would be just a matter of pointing to 2020.3 installation folder and that's it, but it is not being even close to it.

That's my 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'
}

It is important to mention that since I'm working behind a restricted company proxy I can't just set the Intellij version in order to get the necessary distribution files to the build (Intellij.localPath)

Building it on IDEA 2019.1, JDK 1.8 works fine. In order to build the same code for a IDEA 2020.3 I just replaced the Intellij distribution path:

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

Trying to build it now immediately throws it:

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.

What I understand form it is that AnAction class was built using Java 11. So, I replaced the project JDK to use also JDK11 and from that moment I started facing compilation errors, like com.intellij.psi.PsiJavaFile cannot be found.

I might be missing some conceptual point here.


Solution

  • it turns out there was a missing plugin dependency.

    this line was not being effective to resolve such dependency. In order to fix that I had to remove apply plugin: 'java' and set intellij.plugin

    intellij {    
        localPath 'C:/Dev/apps/ideaIU-2020.3'
        plugin = ['com.intellij.java']
    }