mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 03:32:38 +08:00
perf: catalogs
This commit is contained in:
parent
58830672d5
commit
25e10c01c5
|
@ -4,19 +4,19 @@ plugins {
|
|||
id("kotlin-parcelize")
|
||||
id("kotlin-kapt")
|
||||
id("org.jetbrains.kotlin.plugin.serialization")
|
||||
id("com.google.devtools.ksp") version "1.8.10-1.0.9"
|
||||
id("org.jetbrains.kotlin.android")
|
||||
}
|
||||
|
||||
//val composeVersion = "1.3.3"
|
||||
@Suppress("UnstableApiUsage")
|
||||
android {
|
||||
compileSdk = 33
|
||||
buildToolsVersion = "33.0.0"
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
buildToolsVersion = libs.versions.android.buildToolsVersion.get()
|
||||
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
||||
|
||||
applicationId = "li.songe.gkd"
|
||||
minSdk = 26
|
||||
targetSdk = 33
|
||||
versionCode = 1
|
||||
versionName = "1.0.0"
|
||||
|
||||
|
@ -74,24 +74,16 @@ android {
|
|||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
// isCoreLibraryDesugaringEnabled = true
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
|
||||
// 忽略 compose 对 kotlin 版本的限制
|
||||
// freeCompilerArgs = freeCompilerArgs + listOf(
|
||||
// "-P",
|
||||
// "plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true"
|
||||
// )
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
}
|
||||
composeOptions {
|
||||
// compose 编译器的版本, 需要注意它与 compose 的版本不一致
|
||||
// https://mvnrepository.com/artifact/androidx.compose.compiler/compiler
|
||||
kotlinCompilerExtensionVersion = "1.4.4"
|
||||
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
|
||||
}
|
||||
packagingOptions {
|
||||
resources {
|
||||
|
@ -111,96 +103,55 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
// normal
|
||||
implementation("androidx.appcompat:appcompat:1.6.1")
|
||||
implementation("com.google.android.material:material:1.8.0")
|
||||
|
||||
// ktx
|
||||
implementation("androidx.core:core-ktx:1.9.0")
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
|
||||
|
||||
// compose
|
||||
implementation("androidx.compose.ui:ui:1.4.0")
|
||||
implementation("androidx.compose.material:material:1.4.0")
|
||||
implementation("androidx.compose.ui:ui-tooling-preview:1.4.0")
|
||||
debugImplementation("androidx.compose.ui:ui-tooling:1.4.0")
|
||||
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.4.0")
|
||||
implementation("androidx.activity:activity-compose:1.7.0")
|
||||
|
||||
// test
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
|
||||
|
||||
// https://github.com/RikkaApps/Shizuku-API
|
||||
// val shizukuVersion = "12.1.0"
|
||||
implementation("dev.rikka.shizuku:api:12.1.0")
|
||||
implementation("dev.rikka.shizuku:provider:12.1.0")
|
||||
|
||||
// 工具集合类
|
||||
// https://github.com/Blankj/AndroidUtilCode/blob/master/lib/utilcode/README-CN.md
|
||||
implementation("com.blankj:utilcodex:1.31.0")
|
||||
|
||||
// https://developer.android.com/jetpack/compose/navigation
|
||||
// implementation("androidx.navigation:navigation-compose:2.4.2")
|
||||
// 2.4.0/2.4.1/2.4.2 在 红米k40 android 12 需要 向左滑动 才会渲染, 在 android studio 自带 preview 也不渲染
|
||||
// implementation("com.google.accompanist:accompanist-navigation-animation:0.23.1")
|
||||
|
||||
// https://bugly.qq.com/docs/user-guide/instruction-manual-android/
|
||||
implementation("com.tencent.bugly:crashreport:4.0.4")
|
||||
|
||||
// https://developer.android.google.cn/training/data-storage/room?hl=zh-cn
|
||||
// val roomVersion = "2.4.3"
|
||||
implementation("androidx.room:room-runtime:2.5.1")
|
||||
kapt("androidx.room:room-compiler:2.5.1")
|
||||
implementation("androidx.room:room-ktx:2.5.1")
|
||||
|
||||
// implementation("com.squareup.retrofit2:retrofit:2.9.0")
|
||||
// implementation ("com.google.code.gson:gson:2.8.9")
|
||||
|
||||
// https://github.com/Tencent/MMKV/blob/master/README_CN.md
|
||||
implementation("com.tencent:mmkv:1.2.13")
|
||||
|
||||
// ktor
|
||||
implementation("io.ktor:ktor-server-core:2.2.3")
|
||||
implementation("io.ktor:ktor-server-netty:2.2.3")
|
||||
// https://ktor.io/docs/cors.html#install_plugin
|
||||
implementation("io.ktor:ktor-server-cors:2.2.3")
|
||||
implementation("io.ktor:ktor-server-content-negotiation:2.2.3")
|
||||
|
||||
// 请注意,当 client 和 server 版本不一致时, 会报错 socket hang up
|
||||
implementation("io.ktor:ktor-client-core:2.2.3")
|
||||
implementation("io.ktor:ktor-client-cio:2.2.3")
|
||||
implementation("io.ktor:ktor-client-content-negotiation:2.2.3")
|
||||
implementation("io.ktor:ktor-serialization-kotlinx-json:2.2.3")
|
||||
|
||||
// https://github.com/Kotlin/kotlinx.serialization/blob/master/docs
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
|
||||
|
||||
// https://dylancaicoding.github.io/ActivityResultLauncher/#/
|
||||
implementation("com.github.DylanCaiCoding:ActivityResultLauncher:1.1.2")
|
||||
|
||||
// https://github.com/journeyapps/zxing-android-embedded
|
||||
implementation("com.journeyapps:zxing-android-embedded:4.3.0")
|
||||
|
||||
|
||||
// implementation("androidx.startup:startup-runtime:1.1.1")
|
||||
|
||||
implementation("com.google.accompanist:accompanist-drawablepainter:0.23.1")
|
||||
implementation("com.google.accompanist:accompanist-placeholder-material:0.23.1")
|
||||
|
||||
|
||||
ksp(project(":room_processor"))
|
||||
implementation(project(mapOf("path" to ":selector")))
|
||||
implementation(project(mapOf("path" to ":router")))
|
||||
|
||||
// https://github.com/falkreon/Jankson
|
||||
implementation("blue.endless:jankson:1.2.1")
|
||||
implementation(libs.androidx.appcompat)
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||
|
||||
// https://github.com/Kotlin/kotlinx.collections.immutable
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.5")
|
||||
implementation(libs.compose.ui)
|
||||
implementation(libs.compose.material)
|
||||
implementation(libs.compose.preview)
|
||||
debugImplementation(libs.compose.tooling)
|
||||
androidTestImplementation(libs.compose.junit4)
|
||||
implementation(libs.compose.activity)
|
||||
|
||||
implementation("io.github.torrydo:floating-bubble-view:0.5.2")
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
androidTestImplementation(libs.androidx.espresso)
|
||||
|
||||
implementation(libs.rikka.shizuku.api)
|
||||
implementation(libs.rikka.shizuku.provider)
|
||||
|
||||
implementation(libs.tencent.bugly)
|
||||
implementation(libs.tencent.mmkv)
|
||||
|
||||
implementation(libs.androidx.room.runtime)
|
||||
kapt(libs.androidx.room.compiler)
|
||||
implementation(libs.androidx.room.ktx)
|
||||
|
||||
implementation(libs.ktor.server.core)
|
||||
implementation(libs.ktor.server.netty)
|
||||
implementation(libs.ktor.server.core)
|
||||
implementation(libs.ktor.server.content.negotiation)
|
||||
|
||||
implementation(libs.ktor.client.core)
|
||||
implementation(libs.ktor.client.cio)
|
||||
implementation(libs.ktor.client.content.negotiation)
|
||||
implementation(libs.ktor.serialization.kotlinx.json)
|
||||
|
||||
implementation(libs.google.material)
|
||||
implementation(libs.google.accompanist.drawablepainter)
|
||||
implementation(libs.google.accompanist.placeholder.material)
|
||||
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
implementation(libs.kotlinx.collections.immutable)
|
||||
|
||||
implementation(libs.others.jankson)
|
||||
implementation(libs.others.utilcodex)
|
||||
implementation(libs.others.activityResultLauncher)
|
||||
implementation(libs.others.zxing.android.embedded)
|
||||
implementation(libs.others.floating.bubble.view)
|
||||
|
||||
}
|
|
@ -43,9 +43,6 @@ class MainActivity : CompositionActivity({
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package li.songe.gkd.db.util
|
||||
|
||||
import li.songe.room_annotation.RoomAnnotation
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
|
@ -12,11 +11,11 @@ object Operator {
|
|||
Expression(this, "OR", other, tableClass)
|
||||
|
||||
|
||||
// TODO 当同时设置 Property1 时, 代码失效
|
||||
// TODO 当同时设置 Property1 时, 代码失效
|
||||
// 还需要写 Int, Long, String, Boolean 等多种类型的重载, 这种重复性很高,工作量指数级增长的工作确实需要联合类型
|
||||
inline fun <reified T : Any, V, V2> KMutableProperty1<T, V>.baseOperator(
|
||||
value: V2,
|
||||
operator: String
|
||||
operator: String,
|
||||
) =
|
||||
Expression(
|
||||
RoomAnnotation.getColumnName(T::class.java.name, name),
|
||||
|
@ -54,7 +53,7 @@ object Operator {
|
|||
|
||||
inline fun <reified T : Any, V, V2> KProperty1<T, V>.baseOperator(
|
||||
value: V2,
|
||||
operator: String
|
||||
operator: String,
|
||||
) =
|
||||
Expression(
|
||||
RoomAnnotation.getColumnName(T::class.java.name, name),
|
||||
|
@ -63,31 +62,5 @@ object Operator {
|
|||
T::class
|
||||
)
|
||||
|
||||
// inline infix fun <reified T : Any, reified V> KProperty1<T, V>.eq(value: V): Expression<String, V, T> {
|
||||
// return baseOperator(value, "==")
|
||||
// }
|
||||
// inline infix fun <reified T : Any, reified V> KProperty1<T, V>.neq(value: V) =
|
||||
// baseOperator(value, "!=")
|
||||
//
|
||||
// inline infix fun <reified T : Any, reified V> KProperty1<T, V>.less(value: V) =
|
||||
// baseOperator(value, "<")
|
||||
//
|
||||
// inline infix fun <reified T : Any, reified V> KProperty1<T, V>.lessEq(value: V) =
|
||||
// baseOperator(value, "<=")
|
||||
//
|
||||
// inline infix fun <reified T : Any, reified V> KProperty1<T, V>.greater(value: V) =
|
||||
// baseOperator(value, ">")
|
||||
//
|
||||
// inline infix fun <reified T : Any, reified V> KProperty1<T, V>.greaterEq(value: V) =
|
||||
// baseOperator(value, ">=")
|
||||
//
|
||||
// inline infix fun <reified T : Any, reified V> KProperty1<T, V>.inList(value: List<V>) =
|
||||
// baseOperator(value, "IN")
|
||||
//
|
||||
// inline infix fun <reified T : Any, reified V> KProperty1<T, V>.glob(value: GlobString) =
|
||||
// baseOperator(value, "GLOB")
|
||||
//
|
||||
// inline infix fun <reified T : Any, reified V> KProperty1<T, V>.like(value: LikeString) =
|
||||
// baseOperator(value, "LIKE")
|
||||
|
||||
}
|
42
app/src/main/java/li/songe/gkd/db/util/RoomAnnotation.kt
Normal file
42
app/src/main/java/li/songe/gkd/db/util/RoomAnnotation.kt
Normal file
|
@ -0,0 +1,42 @@
|
|||
package li.songe.gkd.db.util
|
||||
|
||||
import java.lang.Exception
|
||||
|
||||
object RoomAnnotation {
|
||||
fun getTableName(className: String): String = when (className) {
|
||||
"li.songe.gkd.db.table.SubsConfig" -> "subs_config"
|
||||
"li.songe.gkd.db.table.SubsItem" -> "subs_item"
|
||||
"r-1682430013322" -> "avoid_compile_error"
|
||||
else -> throw Exception("""not found className : $className""")
|
||||
}
|
||||
|
||||
fun getColumnName(className: String, propertyName: String): String = when (className) {
|
||||
"li.songe.gkd.db.table.SubsConfig" -> when (propertyName) {
|
||||
"id" -> "id"
|
||||
"ctime" -> "ctime"
|
||||
"mtime" -> "mtime"
|
||||
"type" -> "type"
|
||||
"enable" -> "enable"
|
||||
"subsItemId" -> "subs_item_id"
|
||||
"appId" -> "app_id"
|
||||
"groupKey" -> "group_key"
|
||||
"ruleKey" -> "rule_key"
|
||||
"r-1682430013322" -> "avoid_compile_error"
|
||||
else -> throw Exception("""not found columnName : $className#$propertyName""")
|
||||
}
|
||||
"li.songe.gkd.db.table.SubsItem" -> when (propertyName) {
|
||||
"id" -> "id"
|
||||
"ctime" -> "ctime"
|
||||
"mtime" -> "mtime"
|
||||
"enable" -> "enable"
|
||||
"name" -> "name"
|
||||
"updateUrl" -> "update_url"
|
||||
"filePath" -> "file_path"
|
||||
"index" -> "index"
|
||||
"r-1682430013322" -> "avoid_compile_error"
|
||||
else -> throw Exception("""not found columnName : $className#$propertyName""")
|
||||
}
|
||||
"r-1682430013322" -> "avoid_compile_error"
|
||||
else -> throw Exception("""not found className : $className""")
|
||||
}
|
||||
}
|
|
@ -1,12 +1,10 @@
|
|||
package li.songe.gkd.db.util
|
||||
|
||||
import androidx.sqlite.db.SimpleSQLiteQuery
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import li.songe.gkd.db.AppDatabase.Companion.db
|
||||
import li.songe.gkd.db.BaseDao
|
||||
import li.songe.gkd.db.BaseTable
|
||||
import li.songe.gkd.db.table.*
|
||||
import li.songe.room_annotation.RoomAnnotation
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
|
||||
|
|
|
@ -4,23 +4,16 @@ buildscript {
|
|||
mavenLocal()
|
||||
mavenCentral()
|
||||
google()
|
||||
maven {
|
||||
url = uri("https://jitpack.io")
|
||||
}
|
||||
maven("https://jitpack.io")
|
||||
}
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle:7.3.1")
|
||||
|
||||
// 当前 android 项目 kotlin 的版本
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
|
||||
classpath("org.jetbrains.kotlin:kotlin-serialization:1.8.10")
|
||||
|
||||
classpath("dev.rikka.tools.refine:gradle-plugin:3.0.3")
|
||||
classpath(libs.android.gradle)
|
||||
classpath(libs.kotlin.gradle.plugin)
|
||||
classpath(libs.kotlin.serialization)
|
||||
classpath(libs.rikka.gradle)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
tasks.register<Delete>("clean").configure {
|
||||
delete(rootProject.buildDir)
|
||||
}
|
1
room_processor/.gitignore
vendored
1
room_processor/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
/build
|
|
@ -1,27 +0,0 @@
|
|||
plugins {
|
||||
id("kotlin")
|
||||
kotlin("jvm")
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
freeCompilerArgs = freeCompilerArgs + "-opt-in=com.squareup.kotlinpoet.ksp.KotlinPoetKspPreview"
|
||||
freeCompilerArgs = freeCompilerArgs + "-opt-in=com.google.devtools.ksp.KspExperimental"
|
||||
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
|
||||
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=enable"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies{
|
||||
//ksp依赖
|
||||
implementation("com.google.devtools.ksp:symbol-processing-api:1.8.10-1.0.9")
|
||||
//poet依赖
|
||||
implementation("com.squareup:kotlinpoet:1.12.0")
|
||||
implementation("com.squareup:kotlinpoet-ksp:1.12.0")
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
package li.songe.room_processor
|
||||
|
||||
import com.google.devtools.ksp.processing.Dependencies
|
||||
import com.google.devtools.ksp.processing.Resolver
|
||||
import com.google.devtools.ksp.processing.SymbolProcessor
|
||||
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
|
||||
import com.google.devtools.ksp.symbol.KSAnnotated
|
||||
import com.google.devtools.ksp.symbol.KSClassDeclaration
|
||||
import com.google.devtools.ksp.symbol.KSPropertyDeclaration
|
||||
import com.google.devtools.ksp.validate
|
||||
import com.squareup.kotlinpoet.FileSpec
|
||||
import com.squareup.kotlinpoet.FunSpec
|
||||
import com.squareup.kotlinpoet.TypeSpec
|
||||
//import com.squareup.kotlinpoet.ksp.KotlinPoetKspPreview
|
||||
import com.squareup.kotlinpoet.ksp.toAnnotationSpec
|
||||
import com.squareup.kotlinpoet.ksp.toClassName
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
|
||||
class RoomProcessor(private val environment: SymbolProcessorEnvironment) : SymbolProcessor {
|
||||
// private val logger = environment.logger
|
||||
|
||||
private val classAnnotationName = "androidx.room.Entity"
|
||||
private val propertyAnnotationName = "androidx.room.ColumnInfo"
|
||||
|
||||
|
||||
/**
|
||||
* return value see https://book.kotlincn.net/text/ksp-multi-round.html
|
||||
*/
|
||||
// @OptIn(KotlinPoetKspPreview::class)
|
||||
override fun process(resolver: Resolver): List<KSAnnotated> {
|
||||
val class2property2nameMap =
|
||||
mutableMapOf<String, Pair<String, MutableMap<String, String>>>()
|
||||
|
||||
val symbols = resolver
|
||||
.getSymbolsWithAnnotation(classAnnotationName)
|
||||
.filterIsInstance<KSClassDeclaration>()
|
||||
if (!symbols.iterator().hasNext()) {
|
||||
return emptyList()
|
||||
}
|
||||
symbols
|
||||
.forEach {
|
||||
val argument = (it as KSAnnotated)
|
||||
.annotations
|
||||
.first { ksAnnotation ->
|
||||
val ksName = ksAnnotation.toAnnotationSpec().typeName.toString()
|
||||
ksName == classAnnotationName
|
||||
}
|
||||
.arguments.firstOrNull { argument -> argument.name?.asString() == "tableName" }
|
||||
?: return@forEach
|
||||
val tableName = argument.value?.toString() ?: return@forEach
|
||||
val classCanonicalName = it.toClassName().canonicalName
|
||||
|
||||
val property2valueMap = mutableMapOf<String, String>()
|
||||
it.declarations.filterIsInstance<KSPropertyDeclaration>()
|
||||
.forEach ksPropertyForEach@{ ksPropertyDeclaration ->
|
||||
val propertyAnnotation =
|
||||
ksPropertyDeclaration.annotations.firstOrNull { ksAnnotation ->
|
||||
ksAnnotation.toAnnotationSpec().typeName.toString() == propertyAnnotationName
|
||||
} ?: return@ksPropertyForEach
|
||||
val propertyName = ksPropertyDeclaration.simpleName.asString()
|
||||
val valueName =
|
||||
propertyAnnotation.arguments.firstOrNull { argument -> argument.name?.asString() == "name" }?.value?.toString()
|
||||
?: return@ksPropertyForEach
|
||||
property2valueMap[propertyName] = valueName
|
||||
}
|
||||
class2property2nameMap[classCanonicalName] = Pair(tableName, property2valueMap)
|
||||
}
|
||||
|
||||
val typeSpec = TypeSpec
|
||||
.objectBuilder("RoomAnnotation")
|
||||
.addFunction(
|
||||
FunSpec.builder("getTableName")
|
||||
.addParameter("className", String::class)
|
||||
.returns(String::class)
|
||||
.addCode("return when (className) { \n")
|
||||
.apply {
|
||||
class2property2nameMap.forEach { (t, u) ->
|
||||
addCode(indent(1) + "%S -> %S \n", t, u.first)
|
||||
}
|
||||
}
|
||||
.addCode(
|
||||
indent(1) + "%S -> %S \n",
|
||||
"r-" + System.currentTimeMillis(),
|
||||
"avoid_compile_error"
|
||||
)
|
||||
.addCode(
|
||||
indent(1) + "else -> throw Exception(%P) \n",
|
||||
"not found className : \$className"
|
||||
)
|
||||
.addCode("}")
|
||||
.build()
|
||||
)
|
||||
.addFunction(
|
||||
FunSpec.builder("getColumnName")
|
||||
.addParameter("className", String::class)
|
||||
.addParameter("propertyName", String::class)
|
||||
.returns(String::class)
|
||||
.addCode("return when (className) { \n")
|
||||
.apply {
|
||||
class2property2nameMap.forEach { (className, u) ->
|
||||
addCode(indent(1) + "%S -> ", className)
|
||||
addCode("when (propertyName) { \n")
|
||||
u.second.forEach { (propertyName, columnName) ->
|
||||
addCode(indent(2) + "%S -> %S \n", propertyName, columnName)
|
||||
}
|
||||
addCode(
|
||||
indent(2) + "%S -> %S \n",
|
||||
"r-" + System.currentTimeMillis(),
|
||||
"avoid_compile_error"
|
||||
)
|
||||
addCode(
|
||||
indent(2) + "else -> throw Exception(%P) \n",
|
||||
"not found columnName : \$className#\$propertyName"
|
||||
)
|
||||
addCode(indent(1) + "}\n")
|
||||
}
|
||||
}
|
||||
.addCode(
|
||||
indent(1) + "%S -> %S \n",
|
||||
"r-" + System.currentTimeMillis(),
|
||||
"avoid_compile_error"
|
||||
)
|
||||
.addCode(
|
||||
indent(1) + "else -> throw Exception(%P) \n",
|
||||
"not found className : \$className"
|
||||
)
|
||||
.addCode("}")
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
|
||||
val kotlinFile = FileSpec
|
||||
.builder("li.songe.room_annotation", "RoomAnnotation")
|
||||
.addImport(Exception::class, "")
|
||||
.addType(typeSpec).build()
|
||||
|
||||
// thanks https://github.com/Morfly/ksp-sample
|
||||
val dependencies = Dependencies(false, *resolver.getAllFiles().toList().toTypedArray())
|
||||
thread {
|
||||
environment
|
||||
.codeGenerator
|
||||
.createNewFile(dependencies, "li.songe.room_annotation", "RoomAnnotation")
|
||||
.bufferedWriter().use { writer ->
|
||||
kotlinFile.writeTo(writer)
|
||||
}
|
||||
}
|
||||
return symbols.filterNot { it.validate() }.toList()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun indent(n: Int) = List(n * 2) { "\u0020" }.joinToString("")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
package li.songe.room_processor
|
||||
|
||||
import com.google.devtools.ksp.processing.SymbolProcessor
|
||||
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
|
||||
import com.google.devtools.ksp.processing.SymbolProcessorProvider
|
||||
|
||||
class RoomProcessorProvider : SymbolProcessorProvider {
|
||||
override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {
|
||||
return RoomProcessor(environment)
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
li.songe.room_processor.RoomProcessorProvider
|
|
@ -5,15 +5,12 @@ plugins {
|
|||
|
||||
android {
|
||||
namespace = "li.songe.router"
|
||||
compileSdk = 33
|
||||
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
buildToolsVersion = libs.versions.android.buildToolsVersion.get()
|
||||
defaultConfig {
|
||||
minSdk = 26
|
||||
targetSdk = 33
|
||||
|
||||
// testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
|
@ -30,15 +27,14 @@ android {
|
|||
compose = true
|
||||
}
|
||||
composeOptions {
|
||||
// compose 编译器的版本, 需要注意它与 compose 的版本不一致
|
||||
// https://mvnrepository.com/artifact/androidx.compose.compiler/compiler
|
||||
kotlinCompilerExtensionVersion = "1.4.4"
|
||||
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.blankj:utilcodex:1.31.0")
|
||||
implementation("androidx.compose.ui:ui:1.4.0")
|
||||
implementation("androidx.compose.material:material:1.4.0")
|
||||
implementation("androidx.activity:activity-compose:1.7.0")
|
||||
implementation(libs.others.utilcodex)
|
||||
implementation(libs.compose.ui)
|
||||
implementation(libs.compose.material)
|
||||
implementation(libs.compose.activity)
|
||||
implementation(libs.androidx.core.ktx)
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
package li.songe.router
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
|
||||
|
|
|
@ -1,27 +1,22 @@
|
|||
plugins {
|
||||
id("com.android.library")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("kotlin-android")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = 33
|
||||
buildToolsVersion = "33.0.0"
|
||||
namespace = "li.songe.selector"
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
buildToolsVersion = libs.versions.android.buildToolsVersion.get()
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 26
|
||||
targetSdk = 33
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
// consumerProguardFiles("consumer-rules.pro")
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// setProguardFiles(
|
||||
// listOf(
|
||||
// getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
// "proguard-rules.pro"
|
||||
// )
|
||||
// )
|
||||
isMinifyEnabled = false
|
||||
}
|
||||
}
|
||||
|
@ -38,9 +33,9 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
|
||||
testImplementation("org.json:json:20210307")
|
||||
implementation(libs.androidx.core.ktx)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
androidTestImplementation(libs.androidx.espresso)
|
||||
testImplementation(libs.org.json)
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package li.songe.selector.expression
|
||||
|
||||
sealed class ExpressionName
|
|
@ -1,24 +1,124 @@
|
|||
rootProject.name = "gkd"
|
||||
include(":app")
|
||||
include(":selector")
|
||||
include(":router")
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
google()
|
||||
maven {
|
||||
url = uri("https://jitpack.io" )
|
||||
maven("https://jitpack.io")
|
||||
}
|
||||
versionCatalogs {
|
||||
create("libs") {
|
||||
// 当前 android 项目 kotlin 的版本
|
||||
library("android.gradle", "com.android.tools.build:gradle:7.3.1")
|
||||
|
||||
version("android.compileSdk", "33")
|
||||
version("android.minSdk", "26")
|
||||
version("android.targetSdk", "33")
|
||||
version("android.buildToolsVersion", "33.0.0")
|
||||
|
||||
library("kotlin.gradle.plugin", "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
|
||||
library("kotlin.serialization", "org.jetbrains.kotlin:kotlin-serialization:1.8.10")
|
||||
|
||||
// compose 编译器的版本, 需要注意它与 compose 的版本没有关联
|
||||
// https://mvnrepository.com/artifact/androidx.compose.compiler/compiler
|
||||
version("compose.compiler", "1.4.4")
|
||||
library("compose.ui", "androidx.compose.ui:ui:1.4.0")
|
||||
library("compose.material", "androidx.compose.material:material:1.4.0")
|
||||
library("compose.preview", "androidx.compose.ui:ui-tooling-preview:1.4.0")
|
||||
library("compose.tooling", "androidx.compose.ui:ui-tooling:1.4.0")
|
||||
library("compose.junit4", "androidx.compose.ui:ui-test-junit4:1.4.0")
|
||||
library("compose.activity", "androidx.activity:activity-compose:1.7.0")
|
||||
|
||||
// https://github.com/Tencent/MMKV/blob/master/README_CN.md
|
||||
library("tencent.mmkv", "com.tencent:mmkv:1.2.13")
|
||||
// https://bugly.qq.com/docs/user-guide/instruction-manual-android/
|
||||
library("tencent.bugly", "com.tencent.bugly:crashreport:4.0.4")
|
||||
|
||||
library("rikka.gradle", "dev.rikka.tools.refine:gradle-plugin:3.0.3")
|
||||
library("rikka.shizuku.api", "dev.rikka.shizuku:api:12.1.0")
|
||||
library("rikka.shizuku.provider", "dev.rikka.shizuku:provider:12.1.0")
|
||||
|
||||
// 工具集合类
|
||||
// https://github.com/Blankj/AndroidUtilCode/blob/master/lib/utilcode/README-CN.md
|
||||
library("others.utilcodex", "com.blankj:utilcodex:1.31.0")
|
||||
// https://dylancaicoding.github.io/ActivityResultLauncher/#/
|
||||
library(
|
||||
"others.ActivityResultLauncher",
|
||||
"com.github.DylanCaiCoding:ActivityResultLauncher:1.1.2"
|
||||
)
|
||||
// https://github.com/falkreon/Jankson
|
||||
library("others.jankson", "blue.endless:jankson:1.2.1")
|
||||
// https://github.com/journeyapps/zxing-android-embedded
|
||||
library("others.zxing.android.embedded", "com.journeyapps:zxing-android-embedded:4.3.0")
|
||||
library("others.floating.bubble.view", "io.github.torrydo:floating-bubble-view:0.5.2")
|
||||
|
||||
library("androidx.appcompat", "androidx.appcompat:appcompat:1.6.1")
|
||||
library("androidx.core.ktx", "androidx.core:core-ktx:1.9.0")
|
||||
library(
|
||||
"androidx.lifecycle.runtime.ktx",
|
||||
"androidx.lifecycle:lifecycle-runtime-ktx:2.6.1"
|
||||
)
|
||||
library("androidx.junit", "androidx.test.ext:junit:1.1.5")
|
||||
library("androidx.espresso", "androidx.test.espresso:espresso-core:3.5.1")
|
||||
|
||||
// https://developer.android.google.cn/training/data-storage/room?hl=zh-cn
|
||||
library("androidx.room.runtime", "androidx.room:room-runtime:2.5.1")
|
||||
library("androidx.room.compiler", "androidx.room:room-compiler:2.5.1")
|
||||
library("androidx.room.ktx", "androidx.room:room-ktx:2.5.1")
|
||||
|
||||
library("google.material", "com.google.android.material:material:1.8.0")
|
||||
library(
|
||||
"google.accompanist.drawablepainter",
|
||||
"com.google.accompanist:accompanist-drawablepainter:0.23.1"
|
||||
)
|
||||
library(
|
||||
"google.accompanist.placeholder.material",
|
||||
"com.google.accompanist:accompanist-placeholder-material:0.23.1"
|
||||
)
|
||||
|
||||
library("junit", "junit:junit:4.13.2")
|
||||
|
||||
// 请注意,当 client 和 server 版本不一致时, 会报错 socket hang up
|
||||
library("ktor.server.core", "io.ktor:ktor-server-core:2.2.3")
|
||||
library("ktor.server.netty", "io.ktor:ktor-server-netty:2.2.3")
|
||||
library("ktor.server.cors", "io.ktor:ktor-server-cors:2.2.3")
|
||||
library(
|
||||
"ktor.server.content.negotiation",
|
||||
"io.ktor:ktor-server-content-negotiation:2.2.3"
|
||||
)
|
||||
library("ktor.client.core", "io.ktor:ktor-client-core:2.2.3")
|
||||
library("ktor.client.cio", "io.ktor:ktor-client-cio:2.2.3")
|
||||
library(
|
||||
"ktor.client.content.negotiation",
|
||||
"io.ktor:ktor-client-content-negotiation:2.2.3"
|
||||
)
|
||||
library(
|
||||
"ktor.serialization.kotlinx.json",
|
||||
"io.ktor:ktor-serialization-kotlinx-json:2.2.3"
|
||||
)
|
||||
|
||||
library(
|
||||
"kotlinx.serialization.json",
|
||||
"org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1"
|
||||
)
|
||||
// https://github.com/Kotlin/kotlinx.collections.immutable
|
||||
library(
|
||||
"kotlinx.collections.immutable",
|
||||
"org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.5"
|
||||
)
|
||||
|
||||
library("org.json", "org.json:json:20210307")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven("https://plugins.gradle.org/m2/")
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "gkd"
|
||||
|
||||
include(":app")
|
||||
include(":selector")
|
||||
include(":room_processor")
|
||||
include(":router")
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user