How do I add Gradle to an existing project?

I'm wondering how I can add gradle to a project?

I added the relevant files (gradlew.bat, wrapper files, build.gradle, ...). But how do I link that gradle build to IDEA? Documentation only says "When a project is created by importing from Gradle model, this link is established automatically." But this is not my case: I already got an IDEA project and now would just like to switch over to Gradle. Reading on, it suggests that I could create the link through the Gradle tool window which is disabled because the project is not linked to a Gradle project.

I find those explanations extremely confusing. So, what's the way to go?


This is another reason why I don't think that the Gradle Tool Window should be hidden by default.


I was wondering the same thing. Closing the project and opening it back again allowed Intellij to notice the gradle config and allowed me to import it. It's not ideal but it works


Micha you can reload an already opened project as a Gradle project by right clicking the build.gradle file and selecting Import Gradle project action:


I don't have that menu option "Import Gradle Project", do I need to enable some plug-in? I have IntelliJ 2020.1.


If you have the existing build.gradle file, use Open/Import action from the Welcome Screen and select this file.


Please sign in to leave a comment.