Jeff Lockhart
05/22/2023, 5:32 AMAdhocComponentWithVariants.addVariantsFromConfiguration()components["java"] as AdhocComponentWithVariantsorg.jetbrains.kotlin.gradle.plugin.mpp.AbstractKotlinTarget$buildAdhocComponentsFromKotlinVariants$1$2AdhocComponentWithVariants by adhocVariantVampire
05/22/2023, 6:56 AMTo utilise these methods, you must make sure that the SoftwareComponent you work with is itself an AdhocComponentWithVariants, which is the case for the components created by the Java plugins (Java, Java Library, Java Platform).
So yeah, it seems AGP is not compatible to this anymore. You would need to ask the AGP developers whether they could support it again or not. And in the meantime I guess you just need to declare an own component like described lower on that page.
Jeff Lockhart
05/22/2023, 2:26 PMVampire
05/22/2023, 2:33 PMVampire
05/22/2023, 2:34 PMJeff Lockhart
05/22/2023, 2:41 PMtapchicoma
05/22/2023, 4:14 PMJeff Lockhart
05/22/2023, 4:23 PMJeff Lockhart
05/22/2023, 4:50 PMAdhocComponentWithVariantsdef adhocField = components.release.class.getDeclaredFields()
        .find { it.getType() == AdhocComponentWithVariants }
adhocField.setAccessible(true)
AdhocComponentWithVariants adhocComponent = adhocField.get(components.release)
adhocComponent.addVariantsFromConfiguration(...) {
    ...Jeff Lockhart
05/22/2023, 8:18 PMhfhbd
05/23/2023, 6:17 AMafterEvaluatetapchicoma
05/23/2023, 6:52 AMafterEvaluate