Adding sub project dependency in gradle works weirdly, IntelliJ

Answered

I have a gradle multi project.
'root' has 2 sub projects which named 'domain' and 'web'. 'web' needs to use classes which are declared in 'domain' project.

However whenever I add `compile project(':domain')` into dependencies of 'web'.

Intellij says 'root_main', 'root_test', 'web_main', 'web_test' are not imported from Gradle anymore, which I don't want to.

Could you tell me how I can add dependency 'domain' into 'web'?

The structure is below :

root
├── build.gradle
├── domain
│ ├── build.gradle
│ └── src
│ └── main
│ └── test

├── web
│ ├── build.gradle
│ └── src
│ └── main
│ └── test
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle

'build.gradle' in root

version '1.0-SNAPSHOT'

allprojects {
group = 'com.sample.projects.multi'

apply plugin: 'java'
apply plugin: 'eclipse'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
}

'build.gradle' in domain

version '1.0-SNAPSHOT'

dependencies {
}

'build.gradle' in web

version '1.0-SNAPSHOT'

dependencies {
compile project(':domain')
}

Please sign in to leave a comment.