Gradle sync produces runtime instead of compile dependency
We have a complex multi-module Gradle project with the following (very abbreviated) structure:
root/settings.gradle
root/externalModules/modules/C
root/remoteapi/D
root/server/.idea
root/server/modules/A
root/server/modules/B
...
C depends on A; A depends on D.
After doing a sync in the Gradle window, if I open the Project Structure for A, I find that some of its dependencies on third-party libraries, which are declared as compile dependencies in its build.gradle file, are listed as Runtime dependencies within IntelliJ. Similarly, for project C, its dependency on A is marked as a runtime instead of compile dependency. This causes problems with source code navigation for these projects, and building and hot swapping from within IntelliJ do not work. If I move externalModules/modules/C and remoteapi/D under the server directory and sync again, the dependencies appear as compile dependencies as expected.
I notice that all projects that are in directories outside of the server directory (the IntelliJ PROJECT_ROOT) have corresponding directories in the .idea/modules directories that are just numbers (sometimes negative) instead of the named directories used for everything under the server directory, which makes me think this is either uncommon, not supported, or just buggy.
Should the project structure described here work for IntelliJ and Gradle (it works just fine on the command line)? If so, does anyone have a suggestion of how to fix the problem with the Runtime vs Compile dependency discrepancy?
IntelliJ Version 2016.3.2.
Thanks!
Susan
Please sign in to leave a comment.
https://youtrack.jetbrains.com/issue/IDEA-163180 may be related.
Thanks Serge Baranov. I saw that issue, but I don't believe it applies in our case since we are not changing the root project directory within Gradle, unless it looks the same to IntelliJ since we have our IntelliJ root in a different directory than the gradle root (where the settings.gradle file is). Would that be the case?
Yes, it could be the case. You are welcome to file a new bug at https://youtrack.jetbrains.com/issues/IDEA with the sample to reproduce. It will speed up the resolution.
I have filed the following bug with a sample that reproduces the problem: https://youtrack.jetbrains.com/issue/IDEA-168045