Search code examples
javaintellij-ideagradlebuild.gradle

Getting Gradle dependencies in IntelliJ IDEA using Gradle build


Grade build, even from inside IntelliJ IDEA does not put the dependencies into the "External Libraries" folder, so these classes don't show up as suggestions in the editor and when I manually add them as an import there is a compile error.

How can I get IntelliJ to automatically incorporate the dependencies in my build.gradle file, for instance:

compile 'com.google.code.gson:gson:1.7.2


Solution

  • You either need to import the project as a Gradle project from within Idea. When you add a dependency you need to open the Gradle window and perform a refresh.

    Alternatively generate the project files from gradle with this:

    build.gradle:

    apply plugin: 'idea'
    

    And then run:

    $ gradle idea
    

    If you modify the dependencies you will need to rerun the above again.