Skip to content

Commit

Permalink
build.gradle.kts formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
felldo committed Jan 27, 2024
1 parent 2e38a10 commit df1f254
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,22 @@ buildscript {
// https://stackoverflow.com/questions/39490865/how-can-i-get-the-full-list-of-slack-emoji-through-api
// https://github.com/iamcal/emoji-data/
tasks.register("generateEmojisDescription") {
val objectMapper = ObjectMapper();
val objectMapper = ObjectMapper()
val client = OkHttpClient()
val repo = "unicode-org/cldr-json"

val httpBuilderAnnotationsDerivedDirectory: HttpUrl.Builder = "https://api.github.com/repos/${repo}/contents/cldr-json/cldr-annotations-derived-full/annotationsDerived".toHttpUrl().newBuilder()
val httpBuilderAnnotationsDerivedDirectory: HttpUrl.Builder =
"https://api.github.com/repos/${repo}/contents/cldr-json/cldr-annotations-derived-full/annotationsDerived".toHttpUrl()
.newBuilder()
val requestBuilder: Request.Builder = Request.Builder().addHeader("Accept", "application/vnd.github.raw+json")
requestBuilder.url(httpBuilderAnnotationsDerivedDirectory.build())
val descriptionDirectory: JsonNode = objectMapper.readTree(client.newCall(requestBuilder.build()).execute().body!!.string())
val descriptionDirectory: JsonNode =
objectMapper.readTree(client.newCall(requestBuilder.build()).execute().body!!.string())

val fileNameList = mutableListOf<String>()

for (directory in descriptionDirectory) {
val descriptionNodeOutput = JsonNodeFactory.instance.objectNode();
val descriptionNodeOutput = JsonNodeFactory.instance.objectNode()

requestCLDREmojiDescriptionTranslation(
"https://raw.githubusercontent.com/unicode-org/cldr-json/main/cldr-json/cldr-annotations-derived-full/annotationsDerived/${
Expand All @@ -355,11 +358,12 @@ tasks.register("generateEmojisDescription") {
directory.get(
"name"
).asText()
}/annotations.json", client, objectMapper, descriptionNodeOutput,directory.get("name").asText()
}/annotations.json", client, objectMapper, descriptionNodeOutput, directory.get("name").asText()
)


val descriptionFile = File("$projectDir/src/main/resources/emoji_sources/description/${directory.get("name").asText()}.json")
val descriptionFile =
File("$projectDir/src/main/resources/emoji_sources/description/${directory.get("name").asText()}.json")
descriptionFile.writeText(objectMapper.writeValueAsString(descriptionNodeOutput))
fileNameList.add(directory.get("name").asText())
}
Expand Down Expand Up @@ -393,7 +397,7 @@ fun requestCLDREmojiDescriptionTranslation(

annotationsNode.fields().forEach {
if (it.value.has("tts")) {
descriptionNodeOutput.put(it.key, it.value.get("tts").map { it.asText() }.joinToString(" "))
descriptionNodeOutput.put(it.key, it.value.get("tts").joinToString(" ") { it.asText() })
}
}
}
Expand All @@ -410,7 +414,7 @@ fun generateEmojiDescriptionLanguageEnum(languages: List<String>) {

val nodeList = NodeList<EnumConstantDeclaration>()
languages.forEach {
val constantName = emojiGroupToEnumName(it)
val constantName = emojiGroupToEnumName(it)
val enumConstantDeclaration = EnumConstantDeclaration(constantName).addArgument(StringLiteralExpr(it))
nodeList.add(enumConstantDeclaration)
}
Expand Down Expand Up @@ -602,7 +606,7 @@ data class EmojiTerraInfo(
val githubCode: String?,
val slackCode: String?,
val keywords: List<String>
);
)

fun fetchEmojiTerra(url: String): Connection.Response {
val emojiTerraBaseUrl = "https://emojiterra.com"
Expand Down Expand Up @@ -747,7 +751,7 @@ tasks.register("generateJavaSourceFiles") {
}

val emojisListField: FieldDeclaration = emojisInterface.addField("List<Emoji>", "EMOJI_LIST")
val emojisArrayCreationExpr: MethodCallExpr = MethodCallExpr(NameExpr("Arrays"), "asList")
val emojisArrayCreationExpr = MethodCallExpr(NameExpr("Arrays"), "asList")

val emojiClassType = JavaParser().parseClassOrInterfaceType("Emoji").result.get()
val emojiFileNameToConstants = mutableMapOf<String, List<FieldDeclaration>>()
Expand Down Expand Up @@ -815,7 +819,11 @@ tasks.register("generateJavaSourceFiles") {
} else {
emojiFileNameToConstants[emojiSubgroupFileName] = emojiSubGroupInterfaceConstantVariables
emojisInterface.addExtendedType(emojiSubgroupFileName)
createSubGroupEmojiInterface(jemojiPackagePath, emojiSubgroupFileName, emojiSubGroupInterfaceConstantVariables)
createSubGroupEmojiInterface(
jemojiPackagePath,
emojiSubgroupFileName,
emojiSubGroupInterfaceConstantVariables
)
}
}

Expand Down Expand Up @@ -869,7 +877,7 @@ fun createEmojiLoaderInterface(
)

val emojisListField: FieldDeclaration = emojiSubGroupInterfaceFile.addField("List<Emoji>", "EMOJI_LIST")
val emojisArrayCreationExpr: MethodCallExpr = MethodCallExpr(NameExpr("Arrays"), "asList")
val emojisArrayCreationExpr = MethodCallExpr(NameExpr("Arrays"), "asList")

emojiSubGroupInterfaceConstantVariables.forEach { pair ->
pair.second.forEach {
Expand Down

0 comments on commit df1f254

Please sign in to comment.