Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
testDemo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangyh
testDemo
Commits
1ef5c132
Commit
1ef5c132
authored
Dec 23, 2025
by
jiangyh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增5个lib
parent
f343f8c3
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
187 additions
and
1 deletion
+187
-1
build.gradle.kts
composeApp/build.gradle.kts
+5
-0
App.kt
composeApp/src/commonMain/kotlin/com/example/testdemo/App.kt
+15
-0
Platform.ohos.kt
...src/ohosMain/kotlin/com/example/testdemo/Platform.ohos.kt
+7
-0
libs.versions.toml
gradle/libs.versions.toml
+2
-0
build.gradle.kts
lib-api/build.gradle.kts
+26
-0
Api.kt
...src/commonMain/kotlin/com/example/testdemo/lib/api/Api.kt
+3
-0
build.gradle.kts
lib-cinterop/build.gradle.kts
+27
-0
InteropPlaceholder.kt
...n/com/example/testdemo/lib/cinterop/InteropPlaceholder.kt
+4
-0
build.gradle.kts
lib-core/build.gradle.kts
+27
-0
CoreApi.kt
...ommonMain/kotlin/com/example/testdemo/lib/core/CoreApi.kt
+3
-0
build.gradle.kts
lib-coroutines/build.gradle.kts
+30
-0
CoroutinesApi.kt
...tlin/com/example/testdemo/lib/coroutines/CoroutinesApi.kt
+6
-0
build.gradle.kts
lib-utils/build.gradle.kts
+26
-0
Utils.kt
...commonMain/kotlin/com/example/testdemo/lib/utils/Utils.kt
+3
-0
settings.gradle.kts
settings.gradle.kts
+3
-1
No files found.
composeApp/build.gradle.kts
View file @
1ef5c132
...
...
@@ -39,6 +39,11 @@ kotlin {
implementation
(
compose
.
components
.
uiToolingPreview
)
implementation
(
libs
.
androidx
.
lifecycle
.
viewmodelCompose
)
implementation
(
libs
.
androidx
.
lifecycle
.
runtimeCompose
)
implementation
(
project
(
":lib-core"
))
implementation
(
project
(
":lib-utils"
))
implementation
(
project
(
":lib-coroutines"
))
implementation
(
project
(
":lib-cinterop"
))
implementation
(
project
(
":lib-api"
))
}
commonTest
.
dependencies
{
implementation
(
libs
.
kotlin
.
test
)
...
...
composeApp/src/commonMain/kotlin/com/example/testdemo/App.kt
View file @
1ef5c132
...
...
@@ -36,12 +36,27 @@ fun App() {
}
AnimatedVisibility
(
showContent
)
{
val
greeting
=
remember
{
Greeting
().
greet
()
}
// 引入库方法
val
coreMsg
=
remember
{
com
.
example
.
testdemo
.
lib
.
core
.
coreHello
()
}
val
joined
=
remember
{
com
.
example
.
testdemo
.
lib
.
utils
.
join
(
listOf
(
"a"
,
"b"
,
"c"
))
}
val
interopOk
=
remember
{
com
.
example
.
testdemo
.
lib
.
cinterop
.
interopReady
()
}
val
apiVer
=
remember
{
com
.
example
.
testdemo
.
lib
.
api
.
apiVersion
()
}
val
sum
by
produceState
(
initialValue
=
0
)
{
value
=
com
.
example
.
testdemo
.
lib
.
coroutines
.
computeSum
(
listOf
(
1
,
2
,
3
))
}
Column
(
modifier
=
Modifier
.
fillMaxWidth
(),
horizontalAlignment
=
Alignment
.
CenterHorizontally
,
)
{
Image
(
painterResource
(
Res
.
drawable
.
compose_multiplatform
),
null
)
Text
(
"Compose: $greeting"
)
// 库调用结果展示
Text
(
"lib-core: $coreMsg"
)
Text
(
"lib-utils.join: $joined"
)
Text
(
"lib-cinterop.ready: $interopOk"
)
Text
(
"lib-api.version: $apiVer"
)
Text
(
"lib-coroutines.sum: $sum"
)
}
}
}
...
...
composeApp/src/ohosMain/kotlin/com/example/testdemo/Platform.ohos.kt
0 → 100644
View file @
1ef5c132
package
com.example.testdemo
class
OhosPlatform
:
Platform
{
override
val
name
:
String
=
"OpenHarmony"
}
actual
fun
getPlatform
():
Platform
=
OhosPlatform
()
gradle/libs.versions.toml
View file @
1ef5c132
...
...
@@ -12,6 +12,7 @@ androidx-testExt = "1.3.0"
composeMultiplatform
=
"1.9.2"
junit
=
"4.13.2"
kotlin
=
"2.2.21"
kotlinx-coroutines
=
"1.9.0"
[libraries]
kotlin-test
=
{
module
=
"org.jetbrains.kotlin:kotlin-test"
,
version.ref
=
"kotlin"
}
...
...
@@ -24,6 +25,7 @@ androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "a
androidx-activity-compose
=
{
module
=
"androidx.activity:activity-compose"
,
version.ref
=
"androidx-activity"
}
androidx-lifecycle-viewmodelCompose
=
{
module
=
"org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose"
,
version.ref
=
"androidx-lifecycle"
}
androidx-lifecycle-runtimeCompose
=
{
module
=
"org.jetbrains.androidx.lifecycle:lifecycle-runtime-compose"
,
version.ref
=
"androidx-lifecycle"
}
kotlinx-coroutines-core
=
{
module
=
"org.jetbrains.kotlinx:kotlinx-coroutines-core"
,
version.ref
=
"kotlinx-coroutines"
}
[plugins]
androidApplication
=
{
id
=
"com.android.application"
,
version.ref
=
"agp"
}
...
...
lib-api/build.gradle.kts
0 → 100644
View file @
1ef5c132
plugins
{
alias
(
libs
.
plugins
.
kotlinMultiplatform
)
alias
(
libs
.
plugins
.
androidLibrary
)
}
kotlin
{
androidTarget
()
listOf
(
iosArm64
(),
iosSimulatorArm64
())
sourceSets
{
val
commonMain
by
getting
val
commonTest
by
getting
val
iosMain
by
creating
{
dependsOn
(
commonMain
)
}
val
iosArm64Main
by
getting
{
dependsOn
(
iosMain
)
}
val
iosSimulatorArm64Main
by
getting
{
dependsOn
(
iosMain
)
}
}
}
android
{
namespace
=
"com.example.testdemo.lib.api"
compileSdk
=
libs
.
versions
.
android
.
compileSdk
.
get
().
toInt
()
defaultConfig
{
minSdk
=
libs
.
versions
.
android
.
minSdk
.
get
().
toInt
()
}
}
\ No newline at end of file
lib-api/src/commonMain/kotlin/com/example/testdemo/lib/api/Api.kt
0 → 100644
View file @
1ef5c132
package
com.example.testdemo.lib.api
fun
apiVersion
():
String
=
"1.0"
\ No newline at end of file
lib-cinterop/build.gradle.kts
0 → 100644
View file @
1ef5c132
plugins
{
alias
(
libs
.
plugins
.
kotlinMultiplatform
)
alias
(
libs
.
plugins
.
androidLibrary
)
}
kotlin
{
androidTarget
()
listOf
(
iosArm64
(),
iosSimulatorArm64
())
// 后续如需配置 cinterop,可在此添加 Kotlin/Native 的 cinterop 设置
sourceSets
{
val
commonMain
by
getting
val
commonTest
by
getting
val
iosMain
by
creating
{
dependsOn
(
commonMain
)
}
val
iosArm64Main
by
getting
{
dependsOn
(
iosMain
)
}
val
iosSimulatorArm64Main
by
getting
{
dependsOn
(
iosMain
)
}
}
}
android
{
namespace
=
"com.example.testdemo.lib.cinterop"
compileSdk
=
libs
.
versions
.
android
.
compileSdk
.
get
().
toInt
()
defaultConfig
{
minSdk
=
libs
.
versions
.
android
.
minSdk
.
get
().
toInt
()
}
}
\ No newline at end of file
lib-cinterop/src/commonMain/kotlin/com/example/testdemo/lib/cinterop/InteropPlaceholder.kt
0 → 100644
View file @
1ef5c132
package
com.example.testdemo.lib.cinterop
// 后续将使用 cinterop 封装 .so,这里是占位示例
fun
interopReady
():
Boolean
=
true
\ No newline at end of file
lib-core/build.gradle.kts
0 → 100644
View file @
1ef5c132
plugins
{
alias
(
libs
.
plugins
.
kotlinMultiplatform
)
alias
(
libs
.
plugins
.
androidLibrary
)
}
kotlin
{
androidTarget
()
listOf
(
iosArm64
(),
iosSimulatorArm64
())
sourceSets
{
val
commonMain
by
getting
val
commonTest
by
getting
// 统一 iOS 源集桥接
val
iosMain
by
creating
{
dependsOn
(
commonMain
)
}
val
iosArm64Main
by
getting
{
dependsOn
(
iosMain
)
}
val
iosSimulatorArm64Main
by
getting
{
dependsOn
(
iosMain
)
}
}
}
android
{
namespace
=
"com.example.testdemo.lib.core"
compileSdk
=
libs
.
versions
.
android
.
compileSdk
.
get
().
toInt
()
defaultConfig
{
minSdk
=
libs
.
versions
.
android
.
minSdk
.
get
().
toInt
()
}
}
\ No newline at end of file
lib-core/src/commonMain/kotlin/com/example/testdemo/lib/core/CoreApi.kt
0 → 100644
View file @
1ef5c132
package
com.example.testdemo.lib.core
fun
coreHello
():
String
=
"core"
\ No newline at end of file
lib-coroutines/build.gradle.kts
0 → 100644
View file @
1ef5c132
plugins
{
alias
(
libs
.
plugins
.
kotlinMultiplatform
)
alias
(
libs
.
plugins
.
androidLibrary
)
}
kotlin
{
androidTarget
()
listOf
(
iosArm64
(),
iosSimulatorArm64
())
sourceSets
{
val
commonMain
by
getting
{
dependencies
{
implementation
(
libs
.
kotlinx
.
coroutines
.
core
)
}
}
val
commonTest
by
getting
val
iosMain
by
creating
{
dependsOn
(
commonMain
)
}
val
iosArm64Main
by
getting
{
dependsOn
(
iosMain
)
}
val
iosSimulatorArm64Main
by
getting
{
dependsOn
(
iosMain
)
}
}
}
android
{
namespace
=
"com.example.testdemo.lib.coroutines"
compileSdk
=
libs
.
versions
.
android
.
compileSdk
.
get
().
toInt
()
defaultConfig
{
minSdk
=
libs
.
versions
.
android
.
minSdk
.
get
().
toInt
()
}
}
\ No newline at end of file
lib-coroutines/src/commonMain/kotlin/com/example/testdemo/lib/coroutines/CoroutinesApi.kt
0 → 100644
View file @
1ef5c132
package
com.example.testdemo.lib.coroutines
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.withContext
suspend
fun
computeSum
(
xs
:
List
<
Int
>):
Int
=
withContext
(
Dispatchers
.
Default
)
{
xs
.
sum
()
}
\ No newline at end of file
lib-utils/build.gradle.kts
0 → 100644
View file @
1ef5c132
plugins
{
alias
(
libs
.
plugins
.
kotlinMultiplatform
)
alias
(
libs
.
plugins
.
androidLibrary
)
}
kotlin
{
androidTarget
()
listOf
(
iosArm64
(),
iosSimulatorArm64
())
sourceSets
{
val
commonMain
by
getting
val
commonTest
by
getting
val
iosMain
by
creating
{
dependsOn
(
commonMain
)
}
val
iosArm64Main
by
getting
{
dependsOn
(
iosMain
)
}
val
iosSimulatorArm64Main
by
getting
{
dependsOn
(
iosMain
)
}
}
}
android
{
namespace
=
"com.example.testdemo.lib.utils"
compileSdk
=
libs
.
versions
.
android
.
compileSdk
.
get
().
toInt
()
defaultConfig
{
minSdk
=
libs
.
versions
.
android
.
minSdk
.
get
().
toInt
()
}
}
\ No newline at end of file
lib-utils/src/commonMain/kotlin/com/example/testdemo/lib/utils/Utils.kt
0 → 100644
View file @
1ef5c132
package
com.example.testdemo.lib.utils
fun
join
(
items
:
List
<
String
>,
sep
:
String
=
","
)
=
items
.
joinToString
(
sep
)
\ No newline at end of file
settings.gradle.kts
View file @
1ef5c132
...
...
@@ -28,4 +28,6 @@ dependencyResolutionManagement {
}
}
include
(
":composeApp"
)
\ No newline at end of file
include
(
":composeApp"
)
// 新增 5 个 library 模块
include
(
":lib-core"
,
":lib-utils"
,
":lib-coroutines"
,
":lib-cinterop"
,
":lib-api"
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment