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

Support configuration caching #257

Merged
merged 37 commits into from
Aug 10, 2020

Conversation

ZacSweers
Copy link
Contributor

@ZacSweers ZacSweers commented Aug 9, 2020

Resolves #253

There is still more work to do though, namely UploadRequestClient needs to be rethought as its state-sharing nature is incompatible with configuration caching. This PR gets most of the way there though!

Fully implements support for configuration caching, and modernizes much of the internals along the way in a backward-compatible way!

Some highlights:

  • Configuration caching support
  • Uses a BuildService to share state for certain things, like UploadRequestClient and okhttpclient instances
  • Optimized I/O bits in certain places using Okio
  • Backported/backward-compatible patterns for tasks to use new Gradle features as needed

@ZacSweers ZacSweers changed the title Mostly support configuration caching Support configuration caching Aug 9, 2020
@ZacSweers
Copy link
Contributor Author

The test failure appears to be due to the tweaked hashcode calculation to exclude buildUuid like the doc mentioned. Reverted that for now in dcf8007 but probably worth a second look later

gradle/wrapper/gradle-wrapper.properties Show resolved Hide resolved
* will be returned. If no existing requests match, a new request will
* be enqueued and executed.
*
* Equality is measured by the [AndroidManifestInfo] (excluding buildUuid)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't actually exclude the buildUuid property. I tried to exclude it in f1c443b but that resulted in some failing tests that expected more results than would happen when it's excluded. Reverted and left for another time

Copy link
Contributor

@fractalwrench fractalwrench Aug 10, 2020

Choose a reason for hiding this comment

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

The docs are wrong on this - the buildUuid property should be part of the hashcode. There's been a bit of back and forth on the design behind this internally, but we've now settled on the following behaviour:

  • By default the plugin generates a build UUID, and it is recommended that the plugin should be disabled for any unnecessary variants to improve build performance
  • Advanced users can specify their own deterministic build UUID by adding a meta-data tag in the manifest

It's a bit of a tricky balance between the risk of overwriting existing mapping files with the same version information, versus improving performance by using cached task outputs. This approach is the best solution we've come up with so far.

In terms of actions, the comment just needs editing here to remove the erroneous information.

* will be returned. If no existing requests match, a new request will
* be enqueued and executed.
*
* Equality is measured by the [AndroidManifestInfo] (excluding buildUuid)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Equality is measured by the [AndroidManifestInfo] (excluding buildUuid)
* Equality is measured by the [AndroidManifestInfo]

import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.FutureTask

sealed class UploadRequestClient : AutoCloseable {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice use of a sealed class 👍

internal object GradleVersions {
val VERSION_5_3: VersionNumber = VersionNumber.parse("5.3")
val VERSION_6: VersionNumber = VersionNumber.parse("6.0")
val VERSION_6_1: VersionNumber = VersionNumber.parse("6.1")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: SYS_PROPERTIES_VERSION in BugsnagReleasesTask could use this constant instead

return when {
gradleVersion >= GradleVersions.VERSION_6 -> {
when {
gradleVersion >= GradleVersions.VERSION_6_6 -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

style nit: the indentation is off by two spaces for this when block

Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

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

LGTM pending a couple of small tweaks and resolving merge conflicts. Thanks for the contribution Zac!

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.

2 participants