6

I am facing the following problem. I need to build the multi-project, but when I try to add the dependency I got the following error.

Root Project's settings.gradle:

include 'DbServices','HelloWeb'

Root Project's build.gradle:

apply plugin: 'java'
project(':HelloWeb') {
   dependencies {
      compile (':DbServices')   
   }
}

DbServices's build.gradle:

apply plugin: 'java'

HelloWeb's build.gradle:

apply plugin: 'java'

However, then I am getting the following error when synchronize with the gradle tasks on Root Project:

Executing command: "tasks"

FAILURE: Build failed with an exception.

  • Where: Build file 'D:\MyDeployment\RootProject\build.gradle' line: 21

  • What went wrong: A problem occurred evaluating root project 'RootProject'.

    Could not find method compile() for arguments [:DbServices] on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@3b3e3b3e.

  • Try: Run with --info or --debug option to get more log output.

  • Exception is: org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'RootProject'.

2 Answers 2

11

The documentation uses the following syntax:

dependencies {
    compile project(':DbServices')
}
Sign up to request clarification or add additional context in comments.

Comments

2

The notion of compile dependencies is introduced by the java plugin. Therefore, this plugin has to be applied (to the HelloWeb project) before declaring dependencies. The easiest way to fix this is to move the dependencies block into HelloWeb's build.gradle. Additionally, the project dependency syntax needs to be fixed according to JB Nizet's answer.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.