javagradlegradle-multi-project-build

Why Gradle 5 (5.6.3) made an unexpected decision during component resolution?


I have a very large multi-project java build. After the update to the Gradle 5(4.10.3->5.6.3), one of the most terrifying things is unexpected failures during dependency resolution:

...
dependencies {
// I know about the deprecation of 'compile', with 'implementation' I have the same problems
    compile project(":Monitor")
    compile project(":WFPlugins-Server")
    compile project(":web-spring")
    compile project(":Security")
    compile project(":Client")
}
...

For me it's clear as the day, it's should be a project dependency. But I receive:

FAILURE: Build failed with an exception.



* What went wrong:

Execution failed for task ':SpringWFS:compileJava'.

> Could not resolve all files for configuration ':SpringWFS:compileClasspath'.
   > Could not find com.company:WFPlugins-Server:1.12.

     Required by:
         project :SpringWFS

So the gradle is trying to resolve this as an ExternalModuleDependency [in terms of the gradle] instead of DefaultProjectDependency and build is failing as expected

Is someone solves this problem?

remarks:

  1. Please don't propose composite builds (it isn't possible at this moment of time but I'm working on it)
  2. Change the build system (We have a really large project) :)

Solution

  • The only reasons Gradle would replace a project dependency with a module dependency are:

    In the last case, you can tweak the resolution strategy to prefer project over modules.