spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

SpringBoot 2.0.0.BUILD-SNAPSHOT gradle plugin is breaking multi-project dependencies

Open yuvalbo opened this issue 9 years ago • 5 comments

We encountered an issue about two weeks ago while using SpringBoot 2.0.0 Snapshot. Seems recent changes break multi project dependencies. The line compile project(':somemodule') seems to be validated for project existence but not for setting the classpath. Meaning, if I change somemodule to any text that does not relate to a mobule in my multi module project, it will complain. But nevertheless it does not find the classes that were successfully compiled on the exiting related module.

To make sure it is not related to our specific build I have taken https://github.com/spring-guides/gs-multi-module And converted it to use 2.0.0.BUILD-SNAPSHOT

I am getting the same errors:

:library:compileJava UP-TO-DATE
:library:processResources NO-SOURCE
:library:classes UP-TO-DATE
:library:jar SKIPPED
/Users/yuval/dev/gs-multi-module/complete/application/src/main/java/hello/app/DemoApplication.java:10: error: package hello.service does not exist
import hello.service.Service;
                    ^
/Users/yuval/dev/gs-multi-module/complete/application/src/main/java/hello/app/DemoApplication.java:11: error: package hello.service does not exist
import hello.service.ServiceConfiguration;
                    ^
/Users/yuval/dev/gs-multi-module/complete/application/src/main/java/hello/app/DemoApplication.java:18: error: cannot find symbol
    private final Service service;
                  ^
  symbol:   class Service
  location: class DemoApplication
/Users/yuval/dev/gs-multi-module/complete/application/src/main/java/hello/app/DemoApplication.java:21: error: cannot find symbol
    public DemoApplication(Service service) {
                           ^
  symbol:   class Service
  location: class DemoApplication
/Users/yuval/dev/gs-multi-module/complete/application/src/main/java/hello/app/DemoApplication.java:14: error: cannot find symbol
@Import(ServiceConfiguration.class)
        ^
  symbol: class ServiceConfiguration
5 errors
:application:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':application:compileJava'.
> Compilation failed; see the compiler error output for details.

yuvalbo avatar May 15 '17 21:05 yuvalbo

It looks like you introduced a bug during the conversion. The library project appears to have the Spring Boot plugin applied to it. By default that disables the jar task in favour of the bootJar task. I would recommend that you only apply the Spring Boot plugin to the project that contains your application. As shown in the guide to which you have linked, other modules should just be configured with dependency management.

In the future, please raise this sort of question on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.

wilkinsona avatar May 16 '17 06:05 wilkinsona

The same error occured to me.Can I ask how you sloved this problem? @yuvalbo

xzhuz avatar Nov 19 '17 08:11 xzhuz

@mrmeisen in your lib project's build.gradle disable bootJar and re-enable the jar tasks via

bootJar { enabled = false }
jar {enabled = true}

hebra avatar Mar 05 '18 01:03 hebra

still a question: is it a right solution to enable jar task manually for every included sub-project?

radistao avatar Aug 27 '18 12:08 radistao

@radistao please review the comment from Andy above and the guidelines for contributing.

snicoll avatar Aug 27 '18 12:08 snicoll