Skip to content

Commit

Permalink
fix module transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Jun 28, 2024
1 parent fff99a1 commit 63d52e7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 34 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
id: gradle_properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Expand Down

0 comments on commit 63d52e7

Please sign in to comment.