Programmatically get language level setting



I am trying to determine the selected language level for a Java project.


Existing topics in searches show up very old resources (e.g. 2004 references to `PsiManager.getEffectiveLanguageLevel()`), or refer to classes/interfaces that do not resolve (e.g. `LanguageLevelProjectExtension`).


It does seem to be possible to get the selected SDK, but this does not necessarily match up with the language level (e.g. installation of JDK 16 while developing to the Java 8 language level).





Some older resources found:




EDIT: Yann posted this answer on slack, and I include it here for the benefit of anybody coming across this via search results.

language level is specific to Java functionality, so you must declare a dependency on it


Two changes were needed:

  • one change within `plugin.xml` to insert `<depends></depends>` (2019.2 onwards)
  • one within `` to set `platformPlugins = (noting that I'm using the plugin template, where `build.gradle.kts` parses and sets this config -- if not using the template, insert it directly into gradle build file)
1 comment
Comment actions Permalink

answered in Slack


Post is closed for comments.