From bc1289810628b013e8054b9a95412f74d0985f5a Mon Sep 17 00:00:00 2001 From: THEROER Date: Mon, 6 Jul 2026 20:00:12 +0300 Subject: [PATCH] fix(build-logic): bind the java component to publications in afterEvaluate The shadow plugin registers its shadowRuntimeElements variant on the java component from an afterEvaluate hook. Calling publication.from(component) at apply time left publish computing componentArtifacts before that hook ran under CI's injected plugins, failing every library publish with "Variant for configuration 'shadowRuntimeElements' does not exist in component 'java'". Bind the component in afterEvaluate so the variant is registered first; shaded modules still publish their :all variant. --- .../build/publish/MagicUtilsPublishingPlugin.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/build-logic/src/main/kotlin/dev/ua/theroer/magicutils/build/publish/MagicUtilsPublishingPlugin.kt b/build-logic/src/main/kotlin/dev/ua/theroer/magicutils/build/publish/MagicUtilsPublishingPlugin.kt index 988587b7..a89b8cf2 100644 --- a/build-logic/src/main/kotlin/dev/ua/theroer/magicutils/build/publish/MagicUtilsPublishingPlugin.kt +++ b/build-logic/src/main/kotlin/dev/ua/theroer/magicutils/build/publish/MagicUtilsPublishingPlugin.kt @@ -38,7 +38,18 @@ class MagicUtilsPublishingPlugin : Plugin { // unless skipped above, the shadow jar under the `all` classifier — // one module, variants by classifier, mirroring the Fabric bundle's // `dev`. No separate `-all` artifactId. - publication.from(project.components.getByName("java")) + // + // Bind the component in afterEvaluate: the shadow plugin registers + // its shadowRuntimeElements variant on the component from its own + // afterEvaluate hook. Reading the component at apply time (or having + // publish compute componentArtifacts before that hook runs, as CI's + // injected plugins reorder it to) throws "Variant for configuration + // 'shadowRuntimeElements' does not exist in component 'java'". + // afterEvaluate runs after shadow's registration, so the component + // is complete. + project.afterEvaluate { + publication.from(project.components.getByName("java")) + } } }