"Cannot find declaration" in gradle multi-project build
In the JetBrains documentation https://www.jetbrains.com/help/idea/work-with-gradle-projects.html#navigate_inside_build_script it is shown that it is possible to navigate between gradle.build files. However, In my project I get an "cannot find declaration to go to error". I've included the respective subprojects in the settings.gradle and the gradle build is running fine.

I get the same error when trying to jump to sources from other subprojects:

When importing the gradle project, I get the following message:

Under "ProjectStructure", I can see that for the single subprojects no content root is defined.

The whole source-code can be seen here: https://bitbucket.org/johnmacmiller/nand2tetrisgradle/src/master/
Do you have any advise how to solve the issues?
Please sign in to leave a comment.
As far as I understood, Idea removes source folders from the project structure if they equal the project roots. I found no other solution than to modify the project structure (which I tried to avoid since it is not my own project), moving source-files in a respective sub-folder in each subproject. However, this only solve the issue with jumping between source files.
The first issue of not beeing able to jump between build.gradle files has not been soled by this modification.
I just cloned the project and it works like a charm. See https://media.giphy.com/media/Yq87DSr1Ozo1g9vgB3/source.gif
Try re-import the project via "New | Project from Version Control"
Thank you Konstantin for sharing. It still does not work in my IDE. The more important thing is, however, that the gradle configuration seems to be fine, because the project was mostly about learning gradle (and not about handling quirks of the IDE).
May you show a screencast demonstrating the issue? Starting from the moment of "New | Project from version control".
Here is the requested screencast:
https://media.giphy.com/media/LSuEOZ6fUAZT3RdzjW/source.gif
>As far as I understood, Idea removes source folders from the project structure if they equal the project roots. I found no other solution than to modify the project structure (which I tried to avoid since it is not my own project), moving source-files in a respective sub-folder in each subproject. However, this only solve the issue with jumping between source files.
IDE removes content root from the module if this content root is already present in another module. IDE can not use one content root for more than one module, see related issue: https://youtrack.jetbrains.com/issue/IDEA-210311
>I get the same error when trying to jump to sources from other subprojects:
Please make sure to use latest IDE version https://www.jetbrains.com/idea/download A feature for navigation between Gradle projects in build.gradle scripts has been added just recently.
>IDE removes content root from the module if this content root is already present in another module. IDE can not use one content root for more than one module, see related issue: https://youtrack.jetbrains.com/issue/IDEA-210311
I (hopefully) did not assign the same content root to more than one project. However, I assigned the src-folder of each subproject to the root of the respective subproject.
>Please make sure to use latest IDE version https://www.jetbrains.com/idea/download A feature for navigation between Gradle projects in build.gradle scripts has been added just recently.
This did the trick for this problem. Thank you!