Why is my syntax highlighting not working in my build.gradle file in intellij

Viewed 1803

When I create a build.gradle file and open it with IntelliJ, it does not recognize the build.gradle file and a lightbulb appears suggesting that I correct my gradle syntax. See the picture on top. I can still run the gradle file successfully in intellij.

However, when I create a Gradle Project using the New Project option in IntelliJ, I get proper syntax highlighting.

What should I do to get syntax highlighting for my build.gradle file?

build.gradle syntax highlighting not working in intellij

1 Answers

For an IDE to recognize build.gradle files as a Gradle build script instead of simple plain Groovy file it needs to be opened(imported) as a Gradel build file. You can do it from the file's context menu:

enter image description here

Related