Publish in android without hardcoded variants (android-gradle-plugin 8.2.0-rc02)

47 views Asked by At

All my projects have flavors like:

xxxPreprodDebug
xxxProdDebug
xxxPreprodRelease
xxxProdRelease

where xxx is features name. For example "demo", "full", "companyA". They are different in different projects.

I moved the publication into a separate common file and used it in all my projects.

In android-gradle-plugin 7.4.1 all was good. It worked perfectly. But when I started using android-gradle-plugin 8.2.0-rc02, a problem arose that it was necessary to hardcode the full variants name in the new publishing section.

For example project 1:

android {
   publishing {
        singleVariant("demoPreprodRelease")
        singleVariant("demoProdRelease")
        singleVariant("fullPreprodRelease")
        singleVariant("fullProdRelease")
        //don't add Debug variants
   }

   ...
}

project 2:

android {
   publishing {
        singleVariant("company1PreprodRelease")
        singleVariant("company1ProdRelease")
        singleVariant("company2PreprodRelease")
        singleVariant("company2ProdRelease")
        singleVariant("company3PreprodRelease")
        singleVariant("company3ProdRelease")
        //don't add Debug variants
   }

   ...
}

Without this android section, publishing with maven-publish simply does not happen.

Such hardcode is possible if there is only one project. What if there are many projects? I tried using multipleVariants publication from https://developer.android.com/build/publish-library/configure-pub-variants#multiple-pub-vars, but that ONLY works for the library, not for the application. According to the https://developer.android.com/reference/tools/gradle-api/8.2/com/android/build/api/dsl/ApplicationPublishing, there is only a singleVariant for the ApplicationPublishing unlike more options in LibraryPublishing https://developer.android.com/reference/tools/gradle-api/8.2/com/android/build/api/dsl/LibraryPublishing.

How can I configure the publication in such a way that each project in its android publication section sets their own necessary variants?

0

There are 0 answers