Upgrading my plugins to 2021.*/Gradle java.lang.NoClassDefFoundError: com/intellij/openapi/compiler/CompileTask


Hi All


After ugrading all my plugins to 2021.* and using gradle, I have this problem:

This code

import com.intellij.openapi.compiler.CompileTask;

is compiled successfully, but on runtime I get

java.lang.NoClassDefFoundError: com/intellij/openapi/compiler/CompileTask

So I added


And it solves the problem, But I did it without understand why, what is the principle ? 

com.intellij.openapi.compiler.CompileTask is part of the openapi, How can I guess that com.intellij.java is needed ? How do I know for other used classes what plugin is needed ?






Hi, Boaz!

This class belongs to the Java module – you can easily verify it by looking at the intellij-community sources:

Note, the leading /java/compiler/openapi

So, to make your plugin working, you have to set the dependency to Java module both in the Gradle configuration, as well as plugin.xml.

For more information, please check the Modules Specific to Functionality docs page.