8000 Remove afterEvaluate wrapper v2 by 3flex · Pull Request #4271 · detekt/detekt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Remove afterEvaluate wrapper v2 #4271

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

Merged
merged 4 commits into from
Nov 16, 2021
Merged

Conversation

3flex
Copy link
Member
@3flex 3flex commented Nov 15, 2021

v2 of #4159

The reason this didn't work on the first attempt is that bootClasspath on the Android Gradle Plugin's BaseExtension is a List<File> and was being called during the configuration phase when it was empty. By wrapping in a provider {} call the parameter becomes live so the value will be queried at task execution instead, when it's been populated. cc @BraisGabin in case you want to confirm (I have successfully tested on a local Android project).

I've also reversed the test behaviour change introduced in #4262 as the test no longer fails.

I still need to add a functional test for Android. I will do this once #4074 is merged.

Original PR description follows:


Removes usage of afterEvaluate in the Gradle plugin.

This causes race conditions (evidenced by the double use of afterEvaluate in DetektMultiplatform class) and makes it more difficult for users to customise individual tasks created by the plugin.

Generally afterEvaluate shouldn't be required when Gradle's lazy configuration and task configuration avoidance APIs are used. The only tests that failed when I removed it is the multiplatform Android tests, but switching to reactive DomainObjectContainer#all instead of DomainObjectContainer#forEach fixes that.

If there are other use cases that require using afterEvaluate I'll investigate, and if the test coverage didn't pick up issues that removal will now cause, please let me know so I can address it.

Would fix root issue raised in #3428

@3flex 3flex added gradle-plugin notable changes Marker for notable changes in the changelog labels Nov 15, 2021
@codecov
Copy link
codecov bot commented Nov 15, 2021

Codecov Report

Merging #4271 (5ae0155) into main (61166d9) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##               main    #4271   +/-   ##
=========================================
  Coverage     84.24%   84.24%           
  Complexity     3258     3258           
=========================================
  Files           472      472           
  Lines         10293    10293           
  Branches       1813     1813           
=========================================
  Hits           8671     8671           
  Misses          666      666           
  Partials        956      956           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 61166d9...5ae0155. Read the comment docs.

@cortinico cortinico added this to the 1.19.0 milestone Nov 15, 2021
@cortinico
Copy link
Member

Great stuff 🚀 Do we want this inside 1.19.0-RC2?

@3flex
Copy link
Member Author
3flex commented Nov 15, 2021

Do we want this inside 1.19.0-RC2?

My preference is to include it if possible, though there's no test coverage yet...

DomainObjectContainer#all is reactive and applies configuration not just to
objects currently in the collection, but any objects subsequently added to
the collection. `forEach` only applies to objects currently in the
collection, but not any new items subsequently added.
@3flex 3flex marked this pull request as ready for review November 15, 2021 23:25
@BraisGabin BraisGabin merged commit 3e195d6 into detekt:main Nov 16, 2021
@3flex 3flex deleted the afterevaluate2 branch November 16, 2021 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gradle-plugin notable changes Marker for notable changes in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0