Skip to content
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

Dependency excludes defined in a beforeResolve hook should be respected #2480

Closed
ewirch opened this issue Jul 15, 2017 · 2 comments
Closed

Comments

@ewirch
Copy link

ewirch commented Jul 15, 2017

See attached project. Assemble with Gradle 4 (the included Gradle wrapper is 4). The WAR will contain WEB-INF/lib/XmlSchema-1.1.jar (and a duplicate file error), even though this dependency is excluded and not print by gradle dependencies.

Build the same project using Gradle 3 and the WAR contents will be correct.

I created this issue with Spring dependency plugin project first, Since the sample project uses the plugin. But the contributors pointed out, that the same error also occurs when not using the plugin. See comment on the linked issue.

bigdaz added a commit that referenced this issue Jul 18, 2017
The introduction of the 'root component metadata' cache
(68c0bb3) causes the
excludes added in a `beforeResolve` hook to be ignored.
@bigdaz
Copy link
Member

bigdaz commented Jul 18, 2017

Thanks for the report: I've confirmed that this is a problem introduced in Gradle 4.0.

The underlying problem is that dependency excludes declared in a beforeResolve hook can be ignored due to some newly introduced caching. I've added a test that demonstrates the issue: b28d8ee

bigdaz added a commit that referenced this issue Jul 18, 2017
By executing any `beforeResolve` action at the time the root component
metadata is built, we ensure that the cached metadata is correct.
However, this is likely to result in `beforeResolve` actions being
triggered too early, before the Configuration has been fully configured.
bigdaz added a commit that referenced this issue Jul 18, 2017
This reverts commit ba61f02.
bigdaz added a commit that referenced this issue Jul 18, 2017
Since we don't track/validate changes to the properties of each
Dependency of a configuration, this change assumes that any call
to `configuration.incoming.dependencies` implies a mutation.
@bigdaz
Copy link
Member

bigdaz commented Jul 18, 2017

I've added some ideas on how this could be fixed here: https://github.com/gradle/gradle/tree/dd/issue/2480. However, neither of the attempted fixes are particularly satisfactory.

melix pushed a commit that referenced this issue Jul 18, 2017
The introduction of the 'root component metadata' cache
(68c0bb3) causes the
excludes added in a `beforeResolve` hook to be ignored.
@bigdaz bigdaz added this to the 4.1 RC1 milestone Jul 19, 2017
@bigdaz bigdaz changed the title Exclude does not work for transitive dependencies using Gradle 4 Dependency excludes defined in a beforeResolve hook should be respected Jul 19, 2017
@wolfs wolfs closed this as completed in 0864790 Jul 19, 2017
@bigdaz bigdaz modified the milestones: 4.0.2, 4.1 RC1 Jul 19, 2017
@jjohannes jjohannes modified the milestones: 4.0.2, 4.1 RC1 Jul 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants