Skip to content

Apply configuration new variants API only when Plugins are present #414

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 3 commits into from
Jan 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ class ApplyAndroidVariants {
}

private static void applyToAllAndroidVariantsWithNewVariantApi(Project project, ConfigureVariants configureVariants) {
project.plugins.withId("com.android.application") {
configureNewVariants(project, configureVariants)
}

project.plugins.withId("com.android.library") {
Copy link

Choose a reason for hiding this comment

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

It's already merged, but shouldn't the plugin also apply to modules that use com.android.test plugin?

Choose a reason for hiding this comment

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

I think it should also apply to modules with com.android.dynamic-feature plugin.

Copy link
Member Author

Choose a reason for hiding this comment

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

@daio @eboudrant you're right.
Checking the hierarchy of the plugins:
Screen Shot 2023-01-15 at 10 38 40 AM
I'm wondering if checking by com.android.base would be enough. Next week will work on this

configureNewVariants(project, configureVariants)
}
}

private static configureNewVariants(Project project, ConfigureVariants configureVariants){
def androidComponents = project.extensions.findByName("androidComponents")
def selector = androidComponents.selector()
androidComponents.onVariants(selector.all(), configureVariants.newVariantConfiguration)
Expand Down