Skip to content

Fix error when KSP plugin applied before AGP#2183

Merged
ting-yuan merged 1 commit into
google:mainfrom
scott-pollom:gradle_fix
Nov 1, 2024
Merged

Fix error when KSP plugin applied before AGP#2183
ting-yuan merged 1 commit into
google:mainfrom
scott-pollom:gradle_fix

Conversation

@scott-pollom

Copy link
Copy Markdown
Contributor

Previously, when the KSP plugin was applied before AGP and AGP's built-in Kotlin support for test fixtures or screenshot tests was enabled, there would be an error when building.

The underlying cause for this error is
gradle/gradle#31092, which caused the KSP plugin to try to access the android extension before AGP's apply method had completed.

This change fixes the problem by using the "com.android.base" plugin as the indicator that a module is an Android module. The "com.android.base" plugin is applied after the android extension has been added, so it works around the Gradle bug.

Bug: #2174
Test: GradleCompilationTest

@ting-yuan ting-yuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you so much for the patch! Would you mind to fix the lint error?

Previously, when the KSP plugin was applied before AGP and AGP's
built-in Kotlin support for test fixtures or screenshot tests was
enabled, there would be an error when building.

The underlying cause for this error is
gradle/gradle#31092, which caused the KSP
plugin to try to access the android extension before AGP's apply method
had completed.

This change fixes the problem by using the "com.android.base" plugin as
the indicator that a module is an Android module. The "com.android.base"
plugin is applied after the android extension has been added, so it
works around the Gradle bug.

Bug: google#2174
Test: GradleCompilationTest
@ting-yuan ting-yuan linked an issue Nov 1, 2024 that may be closed by this pull request
@ting-yuan ting-yuan merged commit 5b1cd4a into google:main Nov 1, 2024
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.

Fail to apply ksp before android

2 participants