I'm a relatively new IntelliJ IDEA user, and struggling a bit with setting up a version controlled project that also uses library dependencies. We've got a project that we've set up that integrates with gradle for building a releasable app, but we also use IntelliJ's normal build strategy for project work. The challenge is how to manage library dependencies. I can put 'em in Project Settings, and then if we version-control the appropriate XML files, all users see those config settings. But those settings get overwritten if someone clicks the "refresh" button in the Gradle tools screen. Alternatively, I've tried putting our library dependencies in our build.gradle file. That requires that we always synchronize them back to Project Settings via the Gradle refresh button, which doesn't always seem to work reliably. (Perhaps it does work and I need to put all my effort there and learn how to do it right. The feedback is certainly limited.) Most confusing to me is that when I refresh a gradle project, a matching library which has been previously added to the Project Settings window is grayed out. I have two general (categories of) questions which I've been unable to find good answers for:
1. How does gradle refresh work, precisely, with regards to IDEA project settings? What the heck is going on when a library is getting grayed out in the Project Settings window? What's going on in the dot files and in the directory structure? Understanding that would help me a lot in determining how to best organize version control.
2. What are best practices for including library dependencies in a version-controlled project? Is Gradle just a bad idea in this case? Or is it exactly where I should be focused? Would Maven work better? Said differently, if you were starting a brand new version-controlled project with library dependencies and a desire to use IDEA's excellent development tools but also to build applications, how would you structure it?
Thanks for your help, much appreciated.