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

Issue: 17964: Run exclude before and after dependencySubstitution to exclude rewritten dependencies #18131

Merged

Conversation

attix-zhang
Copy link
Contributor

@attix-zhang attix-zhang commented Aug 26, 2021

Apply the exclude spec before and after dependency substitution to
ensure that redirected dependency will be excluded correctly.

Signed-off-by: Attix Zhang attix.zhang.cs@gmail.com

Fixes #17964

Context

Contributor Checklist

  • Review Contribution Guidelines
  • Make sure that all commits are signed off to indicate that you agree to the terms of Developer Certificate of Origin.
  • Make sure all contributed code can be distributed under the terms of the Apache License 2.0, e.g. the code was written by yourself or the original code is licensed under a license compatible to Apache License 2.0.
  • Check "Allow edit from maintainers" option in pull request so that additional changes can be pushed by Gradle team
  • Provide integration tests (under <subproject>/src/integTest) to verify changes from a user perspective
  • Provide unit tests (under <subproject>/src/test) to verify logic
  • Update User Guide, DSL Reference, and Javadoc for public-facing changes
  • Ensure that tests pass sanity check: ./gradlew sanityCheck
  • Ensure that tests pass locally: ./gradlew <changed-subproject>:quickTest

Gradle Core Team Checklist

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation
  • Recognize contributor in release notes

Apply the exclude spec before and after dependency substitution to
ensure that redirected dependency will be excluded correctly.

Signed-off-by: Attix Zhang <attix.zhang.cs@gmail.com>
@attix-zhang
Copy link
Contributor Author

attix-zhang commented Aug 26, 2021

image
Why I don't see the Allow edit from maintainers check box?

@attix-zhang
Copy link
Contributor Author

Based on my research, the ResolveState::dependencySubstitutionApplicator won't be changed during the Resolution, so it should be fine to cache the dependency states after the dependency substitution.

@ljacomet ljacomet self-assigned this Aug 30, 2021
@ljacomet
Copy link
Member

@attix-zhang Thanks for the contribution!

I do not know why you did not see that checkbox. But it should not be a problem in this case.

I agree that we can cache the substitution result, so all good there.

I have started builds to verify the change has no unexpected consequence.

@attix-zhang
Copy link
Contributor Author

attix-zhang commented Aug 30, 2021

Thank you @ljacomet ! Looks to me, all tests passed! (8 tests passed with re-try, not sure why)

@ljacomet ljacomet added this to the 7.3 RC1 milestone Aug 31, 2021
@gradle gradle deleted a comment from ljacomet Aug 31, 2021
@ljacomet
Copy link
Member

Indeed, all tests passed, sending it for merge.

Thanks again for the contribution!

@gradle gradle deleted a comment from ljacomet Aug 31, 2021
@gradle gradle deleted a comment from ljacomet Aug 31, 2021
@gradle gradle deleted a comment from blindpirate Aug 31, 2021
@gradle gradle deleted a comment from blindpirate Aug 31, 2021
@bot-gradle
Copy link
Collaborator

OK, I've already triggered a build for you.

@bot-gradle
Copy link
Collaborator

Pre-tested commit build failed.

@blindpirate
Copy link
Collaborator

@bot-gradle test and merge

@gradle gradle deleted a comment from blindpirate Aug 31, 2021
@bot-gradle
Copy link
Collaborator

OK, I've already triggered a build for you.

@bot-gradle bot-gradle merged commit 2c05921 into gradle:master Aug 31, 2021
@attix-zhang
Copy link
Contributor Author

Is there any chance that we can backport it to the previous version such as Gradle 6.x? Or the recommended way is to upgrade the Gradle to 7.3+?

@ljacomet
Copy link
Member

The change is simple enough that we might consider a backport to 6.9.x.
It is however not critical enough to be the sole motivation for 6.9.2. Let me create an issue to track it though.

@tresat tresat self-requested a review August 31, 2021 14:06
@tresat tresat self-assigned this Aug 31, 2021
@tresat tresat removed their request for review August 31, 2021 14:10
@tresat tresat removed their assignment Aug 31, 2021
@attix-zhang
Copy link
Contributor Author

Oh yeah. Thank you! @ljacomet

@@ -434,7 +434,6 @@ private void visitDependencies(ExcludeSpec resolutionFilter, Collection<EdgeStat
try {
collectAncestorsStrictVersions(incomingEdges);
for (DependencyState dependencyState : dependencies(resolutionFilter)) {
dependencyState = maybeSubstitute(dependencyState, resolveState.getDependencySubstitutionApplicator());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there side-effects now that the below methods (pending edge resolution, constraint activation) are operating on the un-substituted module instead of the substituted one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dependencies(resolutionFilter) now performs the substitution. So the below method still apply to the substituted dependency.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh, for some reason I had it in my mind that cacheFilteredDependencyStates was only called later on. Thanks for clarification 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The exclude won't be able to exclude rewritten dependency
6 participants