From 63d52e751bcee7fe396df818776c388e759c55e0 Mon Sep 17 00:00:00 2001 From: Wagyourtail Date: Fri, 28 Jun 2024 17:47:33 -0500 Subject: [PATCH] fix module transformer --- .github/workflows/build.yml | 8 +++ .../site/maven/transform/ModuleTransformer.kt | 72 ++++++++++--------- 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6b41bdfc..600bf4b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,6 +46,14 @@ jobs: name: gradle path: gradle-plugin/build/libs + - name: Build Site + run: ./gradlew :site:build + + - uses: actions/upload-artifact@v2 + with: + name: site + path: site/build/libs + - name: Load Gradle Properties uses: christian-draeger/read-properties@1.1.1 id: gradle_properties diff --git a/site/src/main/kotlin/xyz/wagyourtail/jvmdg/site/maven/transform/ModuleTransformer.kt b/site/src/main/kotlin/xyz/wagyourtail/jvmdg/site/maven/transform/ModuleTransformer.kt index a8de72b0..348b4f9b 100644 --- a/site/src/main/kotlin/xyz/wagyourtail/jvmdg/site/maven/transform/ModuleTransformer.kt +++ b/site/src/main/kotlin/xyz/wagyourtail/jvmdg/site/maven/transform/ModuleTransformer.kt @@ -12,44 +12,48 @@ object ModuleTransformer { val content = Json.parseToJsonElement(module.readBytes().decodeToString()).jsonObject val json = buildJsonObject { for (entry in content) { - if (entry.key == "variant") { - put(entry.key, buildJsonArray { - for (variant in entry.value.jsonArray) { - add(buildJsonObject { - for (varkey in variant.jsonObject) { - if (varkey.key == "attributes") { - put(varkey.key, buildJsonObject { - for (attr in varkey.value.jsonObject) { - if (attr.key == "org.gradle.jvm.version") { - put(attr.key, version) - } else { - put(attr.key, attr.value) + when (entry.key) { + "variants" -> { + put(entry.key, buildJsonArray { + for (variant in entry.value.jsonArray) { + add(buildJsonObject { + for (varkey in variant.jsonObject) { + if (varkey.key == "attributes") { + put(varkey.key, buildJsonObject { + for (attr in varkey.value.jsonObject) { + if (attr.key == "org.gradle.jvm.version") { + put(attr.key, version) + } else { + put(attr.key, attr.value) + } } - } - }) - // TODO: dependency transforms? -// } else if (varkey.key == "dependencies") { - } else { - put(varkey.key, varkey.value) + }) + // TODO: dependency transforms? + // } else if (varkey.key == "dependencies") { + } else { + put(varkey.key, varkey.value) + } } + }) + } + }) + } + "component" -> { + put(entry.key, buildJsonObject { + for ((key, value) in entry.value.jsonObject) { + if (key == "group") { + put(key, "jvmdg-$version.${value.jsonPrimitive.content}") + } else if (key == "module" && entry.value.jsonObject["group"]?.jsonPrimitive?.content?.let { value.jsonPrimitive.content.startsWith(it) } == true) { + put(key, "jvmdg-$version.${value.jsonPrimitive.content}") + } else { + put(key, value) } - }) - } - }) - } else if (entry.key == "component") { - put(entry.key, buildJsonObject { - for ((key, value) in entry.value.jsonObject) { - if (key == "group") { - put(key, "jvmdg-$version.${value.jsonPrimitive.content}") - } else if (key == "module" && entry.value.jsonObject["group"]?.jsonPrimitive?.content?.let { value.jsonPrimitive.content.startsWith(it) } == true) { - put(key, "jvmdg-$version.${value.jsonPrimitive.content}") - } else { - put(key, value) } - } - }) - } else { - put(entry.key, entry.value) + }) + } + else -> { + put(entry.key, entry.value) + } } } }