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

Add a version skipping mechanism for the AGP patch #111

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

dellisd
Copy link
Collaborator

@dellisd dellisd commented Jan 23, 2024

Usage: BDF targets 8.2.1 and you want to upgrade to 8.2.2 which you know is safe

betterDynamicFeaturesPatch {
  suppressVersionCheck("8.2.2")
}

// Do a strict version check to ensure that our monkey-patching will work correctly.
check(Version.ANDROID_GRADLE_PLUGIN_VERSION == TARGET_AGP_VERSION) {
"This version of the Android Gradle Plugin (${Version.ANDROID_GRADLE_PLUGIN_VERSION}) is not supported by the better-dynamic-features plugin. Only version $TARGET_AGP_VERSION is supported."
target.afterEvaluate {
Copy link
Contributor

Choose a reason for hiding this comment

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

any chance this might not be needed, given that this callback should be called only when modules apply the application plugin? i'm always reluctant to add more afterEvaluate blocks 😓

Copy link
Contributor

Choose a reason for hiding this comment

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

or maybe push it out of here into its own global check, if it'd be a good idea to ensure an Android plugin is always applied for a module applying this plugin:

https://github.com/cashapp/paparazzi/blob/6eb59e36b756476fe212e38b9dd3df507f56b5f4/paparazzi-gradle-plugin/src/main/java/app/cash/paparazzi/gradle/PaparazziPlugin.kt#L56

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In our use case, the agp-patch plugin is only applied to our main application module so that this version check runs.
The actual work of applying the "patch" is done by just including the plugin on the build classpath.

technically this block will also only run if the com.android.application plugin is applied in the first place! (there's a plugins.withId() block)

Copy link
Collaborator

@eric-labelle eric-labelle left a comment

Choose a reason for hiding this comment

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

Thanks

@dellisd dellisd merged commit 9b3cabb into main Jan 24, 2024
2 checks passed
@dellisd dellisd deleted the derekellis/2024-01-23/agp-patch-skip branch January 24, 2024 14:20
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.

4 participants