Skip to content

Commit eb72abb

Browse files
committed
Make bundled content import more robust
1 parent 8eb0be8 commit eb72abb

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

build-logic/src/main/kotlin/org/cru/godtools/gradle/bundledcontent/BundledContentConfiguration.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ private fun LibraryVariant.registerDownloadBundledToolsJsonTask(
7676
// attributes
7777
"manifest", "onesky-project-id", "total-views",
7878
// relationships
79-
"system", "translations", "latest-drafts-translations", "pages", "custom-manifests", "tips"
79+
"system", "translations", "latest-drafts-translations", "pages", "custom-manifests", "tips",
80+
"resource-scores"
8081
)
8182
removeAttributesFor["attachment"] = listOf("file", "is-zipped")
8283
removeAttributesFor["language"] = listOf("direction")

build-logic/src/main/kotlin/org/cru/godtools/gradle/bundledcontent/PruneJsonApiResponseTask.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ abstract class PruneJsonApiResponseTask : DefaultTask() {
6363
private fun JSONArray.sortJsonApiObjects() {
6464
val sorted = filterIsInstance<JSONObject>()
6565
.onEach { if (sortRelationships) it.sortJsonApiRelationships() }
66-
.sortedBy { it.optInt("id") }.sortedBy { it.getString("type") }
66+
.sortedWith(compareBy({ it.optString("type") }, { it.optInt("id") }))
6767
clear()
6868
putAll(sorted)
6969
}

build-logic/src/main/kotlin/org/cru/godtools/gradle/bundledcontent/Utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal fun File.loadJson() = inputStream().use { JSONObject(JSONTokener(it)) }
88
internal fun JSONObject.writeJson(file: File) = file.writer().use { write(it) }
99

1010
internal fun JSONObject.optJSONArrayOrJSONObject(key: String) =
11-
(optJSONArray(key)?.filterIsInstance<JSONObject>() ?: listOfNotNull(optJSONObject("data")))
11+
(optJSONArray(key)?.filterIsInstance<JSONObject>() ?: listOfNotNull(optJSONObject(key)))
1212
internal val JSONObject.jsonApiType get() = optString("type", null)
1313
internal val JSONObject.jsonApiId get() = optString("id", null)?.toIntOrNull()
1414
internal val JSONObject.attributes get() = optJSONObject("attributes")

0 commit comments

Comments
 (0)