Search code examples
gradleintellij-ideabuild.gradleintellij-2020

IDEA - How can I place braces on the next line for .gradle files?


In the Code Style settings of IntelliJ IDEA, there aren't any subcategories for .gradle files (e.g., build.gradle), and under Other File Types, there isn't any option to modify brace placements. I did not find solutions on to set brace placement for .gradle files.

What I'm trying to do: Make the braces look like this by default and after reformatting:

repositories
{
    mavenCentral()
}

Instead of this:

repositories {
    mavenCentral()
}

Is this change possible using the current version of IntelliJ IDEA? (2020.1.1)

Changing the code style settings for Groovy does not have an effect for some reason.

Enter image description here

Braces for a Groovy class is placed correctly as in the settings. (This is tested in a .gradle file.)

Enter image description here


Solution

  • It looks like the Settings (Preferences on macOS) → EditorCode StyleGroovyWrapping and BracesBraces placement → *Other option does not work as expected.

    Please vote for the issue IDEA-241366.