-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Dependency exclusions declared in spring-boot-dependencies have no effect when using Gradle 6 #21350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report. In the Quartz case, the excludes are defined in @melix is it possible to specify exclusions in the constraints described by Gradle's module metadata? I looked at the documentation and didn't spot any information about exclusions. Specifically, we'd like to include exclusions in the module metadata for our this.dependencyHandler.getConstraints().add(JavaPlatformPlugin.API_CONFIGURATION_NAME,
createDependencyNotation(group.getId(), module.getName(), library.getVersion()));
We'd like to publish module metadata for our platform that results in the same behaviour as you'd get from a Maven bom that contains something like the following: <dependencyManagement>
<dependencies>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>${quartz.version}</version>
<exclusions>
<exclusion>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
</exclusion>
<exclusion>
<groupId>com.zaxxer</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependencies>
</dependencyManagement> |
I'm afraid that it's not possible: gradle/gradle#12214. I asked this question, because I had the same issue with our custom platform module. This platform is based on the spring boot platform and I wanted to add additional libraries with exclusions, so that subprojects (and we have quite a few of them) don't have to exclude everything again. Since it was not possible to define the exclusions, I added constraints to out platform module, so that subprojects at least recognize that they may have to exclude some libraries. This constraints also help if you add or update dependencies. Because the build will fail if a excluded dependency is accidentally leaks into the classpath. But I am not happy with this solution, because it feels like it should be able to define this via Gradle platform. My biggest concern currently is, that this Gradle dependency management is getting to complex for "normal" users (like me). I really spent weeks just to get the dependency management right and I still have issues and am not sure if I am doing it right. Just to get an idea, this is a short extract from our constraints, which we mainly maintain, because we cannot rely on Gradle/Spring exclusion of transitive dependencies:
|
Looking at the second case, this is standard behaviour for Gradle. While we have some exclusions declared on |
Thinking about this issue got me wondering if we could provide some dependency substitutions out of the box. I've opened #21359 to explore that idea. |
We currently have 22 exclusions declared in |
Regarding the second case: I would appreciate if Gradle would offer an additional simpler solution, but yes, currently there is no other option then to add the exclusions to all the starter poms. But it will also have downsides:
Since Gradle Module Metadata is still young, and not yet widely used, maybe it would be good to talk to them about this topics? Last but not least: @wilkinsona Thank you for your answer and your great work. :) |
Hey there, Just to confirm that Gradle does not support defining exclusions on dependency constraints. The support for excludes defined in Maven What happens in the Spring Boot build is that the excludes are added on the generated POM file, which indicates this is not a supported thing from the Gradle's perspective and thus indeed is not replicated in the produced Gradle Module Metadata file. However the discussion on this issue and the suggested workaround with |
Thanks very much, @ljacomet. We'll disable publication of Gradle module metadata for |
A recent change has broken some of the integration tests in start.spring.io. Given the timing of the failures starting to occur, our best guess is that it is this change that has caused them, although we do not really understand why. There is a usage of |
c35ed91 fixed it. |
Disclaimer: I am not sure wether this issues belongs to Gradle or Spring Boot.
Two different issues, but in both cases Springs dependency excludes are ignored.
Case 1
Given the following Gradle build script:
With Gradle 5.2.1 you will end with following quartz dependencies on the classpath:
With Gradle 6.4 you will end with following quartz dependencies on the classpath:
I assume that this change of behavior occurs because Gradle 6.4 uses Gradle Module Metadata and Gradle 5 uses Maven BOMs.
Case 2
Given the following dependency declaration:
The following transitive hibernate-core dependencies will be added to the classpath.
Interestingly, exclusions work for spring-boot-starter-data-jpa but not for spring-boot-starter-quartz.
If I add hibernate-jcache, which also depends on hibernate-core, the result is that the dependency excludes defined via Spring Boot are "ignored".
The following transitive hibernate libraries will also be added tom the classpath, as long as I don't exclude them manually.
The text was updated successfully, but these errors were encountered: