How child project can have root project as dependency?

I have a simple multiproject configuration. I have a root project and a child project called “test”. In settings.gradle i have
include “test”
The goal is to have access to code of the root project in child`s code. So i added dependency to the root project from the child like this: compile rootProject. Also i tried compile project(":"). The problem is that in child project i have to the transitive dependencies from the parent project but not tho the code of the root project. Is this a bug ? i am using gradle version 4.1 with groovy version 2.4.11 Here is the screenshot of the structure of my project. Also it should be noted that Intelij IDEA recognizes classes from root project and i can also perform build. For reference:
root build.gradle file content

group ‘test’
version ‘1.0-SNAPSHOT’

apply plugin: ‘java’

sourceCompatibility = 1.8

repositories {

dependencies {
testCompile group: ‘junit’, name: ‘junit’, version: ‘4.12’
settings.gradle content = ‘test’
include ‘:test’

child build.gradle content
apply plugin: ‘java’
dependencies {
testCompile rootProject

The syntax for referencing the root project is project(":"), but it is not a typical thing to do… could yo elaborate why do you need to do this?

Looks like compile project(":") and compile rootProject in dependencies do the same. In my case - root project is the application itself - child project is performance test project. In child project i would like to mesure performance of the application implemented in the root project. Also, i would like to do performance testing only ocassinaly, so in settings.gradle i will have if statement that includes child project only when env vaiable is presented.

I would probably have an outer root project with no code, and the former ‘root’ and ‘performace’ Projects both be sub projects under the root.

Thank you. I think this is one possible solution. But this is more like a workaround solution.
The fact that the code from the root project is not accessible from the child is confusing. Should this be considered as bug ?

The code is accessible as dependency through the syntac I mentioned. Do you have an example illustrating your actual problem? I mean something I can run and see an error.

For others who will encounter this problem.
It seems that the IDEA has some auto-generate bug in projects organized in this way.
First, open the “workspace.xml” file in yout project’s “.idea” folder and search with “<module name =” to get your root project’s module name. Let’s assume its name is “base”.
Then go to your child module’s folder, open your child module’s iml file. Add the following entry as module -> component’s child node.

<orderEntry type=“module” module-name=“base” />

And you switch back to IDEA you should see all the dependency is well worked now.