Skip to content

Remove use of plugins.findPlugin(KotlinBaseApiPlugin::class.java) to detect built-in Kotlin #2772

@hungvietnguyen

Description

@hungvietnguyen

Context

To detect whether AGP's built-in Kotlin is enabled, KSP currently uses plugins.findPlugin(KotlinBaseApiPlugin::class.java).

As discussed in https://issuetracker.google.com/476936389, AGP's built-in Kotlin is going to apply an internal subclass of KotlinBaseApiPlugin instead of applying KotlinBaseApiPlugin directly.

That means plugins.findPlugin(KotlinBaseApiPlugin::class.java) will no longer work as it doesn't recognize the subclass of KotlinBaseApiPlugin.

Solution

Instead of

plugins.findPlugin(KotlinBaseApiPlugin::class.java)

please use

plugins.withType(KotlinBaseApiPlugin::class.java).firstOrNull()

(Small note: In theory, there could be multiple subclasses of KotlinBaseApiPlugin, so we use firstOrNull rather than singleOrNull.)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions