Compare commits
No commits in common. "master" and "Test" have entirely different histories.
|
@ -39,7 +39,7 @@ jobs:
|
|||
- name: Publish to GitHub Packages
|
||||
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
|
||||
with:
|
||||
arguments: publishAllPublicationsToGitHubPackagesRepository
|
||||
arguments: publish
|
||||
env:
|
||||
USERNAME: ${{ github.actor }}
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
|
@ -6,7 +6,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "dev.usbharu"
|
||||
version = "2.0.1"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
google()
|
||||
|
@ -24,9 +24,7 @@ kotlin {
|
|||
browser()
|
||||
nodejs()
|
||||
}
|
||||
android{
|
||||
publishLibraryVariants("release")
|
||||
}
|
||||
android()
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
sourceSets["commonMain"].kotlin.srcDir("build/generated/source/emoji/main/kotlin")
|
||||
|
@ -81,19 +79,4 @@ publishing{
|
|||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name = "Gitea"
|
||||
url = uri("https://git.usbharu.dev/api/packages/usbharu/maven")
|
||||
|
||||
credentials(HttpHeaderCredentials::class.java) {
|
||||
name = "Authorization"
|
||||
value = "token "+(project.findProperty("gpr.gitea") as String? ?: System.getenv("GITEA"))
|
||||
}
|
||||
|
||||
authentication {
|
||||
create<HttpHeaderAuthentication>("header")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,4 +9,12 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
compileOnly(gradleApi())
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
|
||||
implementation("io.ktor:ktor-client-core:2.2.3")
|
||||
implementation("io.ktor:ktor-client-cio:2.2.3")
|
||||
}
|
||||
|
||||
buildscript {
|
||||
|
||||
}
|
||||
ext["kotlin_version"] = "1.8.10"
|
||||
|
|
|
@ -1,34 +1,26 @@
|
|||
import io.ktor.client.*
|
||||
import io.ktor.client.engine.cio.*
|
||||
import io.ktor.client.plugins.cache.*
|
||||
import io.ktor.client.plugins.cache.storage.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.statement.*
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import java.net.URI
|
||||
import java.net.http.HttpClient
|
||||
import java.net.http.HttpRequest
|
||||
import java.net.http.HttpResponse
|
||||
import java.time.Duration
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
|
||||
class EmojiPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
project.task("generateEmoji")
|
||||
.doLast(Action {
|
||||
val httpClient = HttpClient.newBuilder()
|
||||
.version(HttpClient.Version.HTTP_1_1)
|
||||
.followRedirects(HttpClient.Redirect.NORMAL)
|
||||
.connectTimeout(Duration.ofSeconds(10))
|
||||
.build()
|
||||
|
||||
val req = HttpRequest
|
||||
.newBuilder(URI.create("https://unicode.org/Public/emoji/15.1/emoji-test.txt"))
|
||||
.GET()
|
||||
.setHeader(
|
||||
"User-Agent",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.3"
|
||||
)
|
||||
.build()
|
||||
|
||||
|
||||
val bodyAsText = httpClient.send(req, HttpResponse.BodyHandlers.ofString()).body()
|
||||
runBlocking {
|
||||
|
||||
val httpClient = HttpClient(CIO)
|
||||
val bodyAsText =
|
||||
httpClient.get("https://unicode.org/Public/emoji/15.0/emoji-test.txt")
|
||||
.bodyAsText()
|
||||
println(project.buildDir.path)
|
||||
// println(bodyAsText)
|
||||
|
||||
|
@ -43,19 +35,11 @@ class EmojiPlugin : Plugin<Project> {
|
|||
var group: String = ""
|
||||
var subgroup: String = ""
|
||||
|
||||
var emojiCount = 0
|
||||
var groupCount = 0
|
||||
|
||||
data class Emoji(val group: String, val value: String)
|
||||
|
||||
val enumList = mutableMapOf<String, Emoji>()
|
||||
//TODO グループ分けしたことで重複がなくなるはずなので修正
|
||||
for (s in split) {
|
||||
if (emojiCount >= 99) {
|
||||
emojiCount = 0
|
||||
groupCount++
|
||||
}
|
||||
|
||||
when {
|
||||
s.startsWith("# group:") -> {
|
||||
group = s.substringAfter(": ")
|
||||
|
@ -69,27 +53,16 @@ class EmojiPlugin : Plugin<Project> {
|
|||
s.startsWith("#") -> {}
|
||||
else -> {
|
||||
val description = s.substringAfterLast("E").substringAfter(" ")
|
||||
val status = s.substringAfter(";").substringBefore("#").trim()
|
||||
if (!description.contains("skin tone")) {
|
||||
|
||||
val code =
|
||||
s.substringBefore(";").replace(Regex(" +"), " ").trim()
|
||||
val char = s.substringAfter("# ").substringBefore(" ").trim()
|
||||
|
||||
val statusString = when (status) {
|
||||
"fully-qualified" -> "Status.FULLY_QUALIFIED"
|
||||
"unqualified" -> "Status.UNAUALIFIED"
|
||||
"minimally-qualified" -> "Status.MINIMALLY_QUALIFIED"
|
||||
|
||||
else -> {
|
||||
println(status)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
enumList.putIfAbsent(
|
||||
(description + "_" + status),
|
||||
val status = s.substringAfter(";").substringBefore("#").trim()
|
||||
enumList.put(
|
||||
description,
|
||||
Emoji(
|
||||
group + groupCount,
|
||||
group,
|
||||
"${
|
||||
(description + "_" + status).toUpperCase()
|
||||
.replace(" ", "_")
|
||||
|
@ -127,11 +100,10 @@ class EmojiPlugin : Plugin<Project> {
|
|||
.replace("Ô", "O")
|
||||
.replace("Ç", "C")
|
||||
.replace(Regex("_+"), "_")
|
||||
}(\"$group\",\"$subgroup\",\"$code\",\"$char\",\"$description\",$statusString)"
|
||||
}(\"$group\",\"$subgroup\",\"$code\",\"$char\",\"$description\")"
|
||||
)
|
||||
)
|
||||
|
||||
emojiCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +115,7 @@ class EmojiPlugin : Plugin<Project> {
|
|||
}
|
||||
|
||||
val map = emojis.map {
|
||||
"enum class ${it.key}(override val group:String,override val subgroup:String,override val code:String,override val char:String,override val description:String,val status:Status):UnicodeEmoji{\n" +
|
||||
"enum class ${it.key}(val group:String,val subGroup:String,val code:String,val char:String,val description:String){\n" +
|
||||
"${
|
||||
it.value.map { it.value }.joinToString(
|
||||
",\n"
|
||||
|
@ -155,30 +127,12 @@ class EmojiPlugin : Plugin<Project> {
|
|||
//language=kotlin
|
||||
val trimIndent =
|
||||
"""@Suppress("unused")
|
||||
interface UnicodeEmoji {
|
||||
val group: String
|
||||
val subgroup: String
|
||||
val code: String
|
||||
val char: String
|
||||
val description: String
|
||||
}
|
||||
|
||||
enum class Status{
|
||||
FULLY_QUALIFIED,
|
||||
UNAUALIFIED,
|
||||
MINIMALLY_QUALIFIED
|
||||
}
|
||||
|
||||
object Emojis {
|
||||
val allEmojis:MutableList<UnicodeEmoji> = mutableListOf<UnicodeEmoji>()
|
||||
init {
|
||||
${emojis.keys.map { "allEmojis.addAll($it.values())" }.joinToString("\n")}
|
||||
}
|
||||
class Emojis {
|
||||
${joinToString}
|
||||
}"""
|
||||
asFile.writeText(trimIndent)
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="dev.usbharu.emoji"/>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="dev.usbharu.library"/>
|
Loading…
Reference in New Issue