Intellij Re-import Gradle Project

Mike Rylander picture Mike Rylander · Oct 25, 2013 · Viewed 53.9k times · Source

I just added a new test source directory to my Gradle project and want IntelliJ to recognize it. I can close the project and reopen the build.gradle file and chose "Delete Existing Project and Import"; is there a way to update the module sources without deleting the existing project?

idea {
    module {
        // just added these two lines        
        testSourceDirs += file('src/integration-test/java')
        testSourceDirs += file('src/integration-test/resources')
    }
}

I don't want to just manually add the sources, instead I want IntelliJ to re-import the Gradle project structure from the 'build.gradle' file.

Details: Gradle v1.7, IntelliJ v12

Answer

Mike Rylander picture Mike Rylander · Jul 17, 2014

IntelliJ 13 supports "refreshing" the Gradle project. When the project is refreshed any dependency changes are picked up as well as any changes to the project structure.

In order to do so go to View -> Tool Windows and open the Gradle Tool Window you find the refresh button in the upper bar.