Skip to content

Gradle multi-project build dependencies of subprojects cannot be resolved #11594

@aemaem

Description

@aemaem

Summary

When building a Gradle multi-project with Spring Boot 2.0.0.M7 the project cannot resolve the dependency of another project in the same root project.

Sample

https://github.com/aemaem/spring-boot-gradle-multi-project
Branches:

  • master --> Spring Boot 2.0.0.M7
  • boot-1.5.9 --> Spring Boot 1.5.9.RELEASE

Background

When running ./gradlew clean build in the sample project the dependency of the demo-api project cannot be resolved. If the same configuration is configured with Spring Boot 1.5.9.REALEASE then the build works as expected.

Gradle Output

> Task :demo-app:compileJava
/home/mmair/Downloads/demo/demo-app/src/main/java/com/example/demo/DemoApplication.java:3: error: package com.example.demo.api does not exist
import com.example.demo.api.FooApi;
                           ^
/home/mmair/Downloads/demo/demo-app/src/main/java/com/example/demo/DemoApplication.java:13: error: cannot find symbol
        private FooApi foo;
                ^
  symbol:   class FooApi
  location: class DemoApplication
/home/mmair/Downloads/demo/demo-app/src/main/java/com/example/demo/FooService.java:3: error: package com.example.demo.api does not exist
import com.example.demo.api.FooApi;
                           ^
/home/mmair/Downloads/demo/demo-app/src/main/java/com/example/demo/FooService.java:7: error: cannot find symbol
public class FooService implements FooApi {
                                   ^
  symbol: class FooApi
/home/mmair/Downloads/demo/demo-app/src/main/java/com/example/demo/FooService.java:9: error: method does not override or implement a method from a supertype
    @Override
    ^
5 errors

FAILURE: Build failed with an exception.

Project structure is as follows:

demo
├── build.gradle
├── demo-api
│   ├── build.gradle
│   └── src
│       └── main
│           └── java
│               └── com
│                   └── example
│                       └── demo
│                           └── api
│                               └── FooApi.java
├── demo-app
│   ├── build.gradle
│   └── src
│       └── main
│           ├── java
│           │   └── com
│           │       └── example
│           │           └── demo
│           │               ├── DemoApplication.java
│           │               └── FooService.java
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions