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?

Comment actions Permalink

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:

Comment actions Permalink

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

Comment actions Permalink

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


Please sign in to leave a comment.