Setting per module language level in intellij

Intellij supports per module language levels and SDKs.

Gradle exposes a simple mechanism for setting the project language level & sdk and the module sdk, it does not seem to expose the per module language level. Am I missing something or do I need to fiddle this myself via iml munging?

Not sure why it isn’t supported, but it should be fairly easy to roll it on your own. See examples in IdeaModule.

I think what should really happen is that language level defaults to project.sourceCompatibility.

Thanks. I implemented it as follows (in case anyone hits upon this later)

project.extensions.idea.module.iml {
    withXml {
        it.asNode().component.find { it.@name == 'NewModuleRootManager' }.@LANGUAGE_LEVEL = target.level

where target is an IdeaLanguageLevel instance

We plan to expose language level per module and there’s already a jira ticket for that.


Szczepan Faber, is GRADLE-2198 the ticket you were talking about? Is this still planned?

It’s very annoying that every time I refresh my gradle build on IDEA, it loses the language level…