I was using com.android.builder.core.DefaultManifestParser to get versionName in build.gradle earlier.
Then I updated my android gradle plugin to 7.0.1 and with this update DefaultManifestParser is deprecated. Moreover, it doesn't have a method to get versionName anymore.
Here's the commit https://android.googlesource.com/platform/tools/base/+/7b2eb3d92dfa29f8cb01cec47f48e18d5b2eb70b that removes getVersionName and getVersionCode method. A later commit deprecates the DefaultManifestParser.
The commit message mentions that
With the new variant Api, we need all the values that can come fro the manifest to be using Provider<> for their lazy mechanism
This change introduces a parallel manifest parser that uses Provider to create a Provider which then can be mixed with the DSL values.
But I couldn't find the new way to get the versionName.
I did see that there's a new interface VariantDslInfo that has versionName whose class doc states
Use [VariantDslInfoBuilder] to instantiate.
I checked the VariantDslInfoBuilder whose class doc states:
Use [getBuilder] as an entry point.
But the getBuilder method expects a lot of arguments which I have no idea of, so I'm not sure how to use VariantDslInfo to get the versionName.
Furthermore, I'm not even sure if VariantDslInfo is supposed to be a replacement for DefaultManifestParser for providing the versionName.
So, to sum it all up, since DefaultManifestParser no longer works in AGP 7, what's the new way to get version name from AndroidManifest in build.gradle?