Best way to add Gradle support to IntelliJ Project Best way to add Gradle support to IntelliJ Project git git

Best way to add Gradle support to IntelliJ Project


Add:

build.gradle 

in your root project folder, and use plugin for example:

apply plugin: 'idea'//and standard oneapply plugin: 'java'

and with this fire from command line:

gradle cleanIdea 

and after that:

gradle idea

After that everything should work


There is no need to remove any .iml files. Follow this:

  • close the project
  • File -> Open... and choose your newly created build.gradle
  • IntelliJ will ask you whether you want:
    • Open Existing Project
    • Delete Existing Project and Import
  • Choose the second option and you are done


Another way, simpler.

Add your

build.gradle

file to the root of your project. Close the project. Manually remove "*.iml" file and/or ".idea" directory. Then choose "Import Project...", navigate to your project directory, select the build.gradle file and click OK.