英文:
Where can I find the definition of projects.openaiClient?
问题
以下示例代码来自OpenAI API客户端Kotlin项目。
你可以在https://github.com/aallam/openai-kotlin/tree/main/sample/native 上看到它。
我在Android Studio中打开了示例代码,但我找不到作者在哪里定义implementation(projects.openaiClient)
,我已经搜索了整个项目,你能告诉我吗?
build.gradle.kts
plugins {
kotlin("multiplatform")
}
kotlin {
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
nativeTarget.apply {
binaries {
executable {
entryPoint = "main"
}
}
}
sourceSets {
val nativeMain by getting {
dependencies {
implementation(projects.openaiClient) // 这里是 projects.openaiClient
implementation(libs.ktor.client.curl) // 这里是 libs.ktor.client.curl
}
}
}
}
英文:
The following sample code comes from OpenAI API client for Kotlin project.
You can see it at https://github.com/aallam/openai-kotlin/tree/main/sample/native
I open the sample code with Android Studio, but I can't find where the author define the implementation(projects.openaiClient)
, I have searched the whole project, could you tell me ?
build.gradle.kts
plugins {
kotlin("multiplatform")
}
kotlin {
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
nativeTarget.apply {
binaries {
executable {
entryPoint = "main"
}
}
}
sourceSets {
val nativeMain by getting {
dependencies {
//implementation("com.aallam.openai:openai-client:<version>")
implementation(projects.openaiClient) // Where is projects.openaiClient
implementation(libs.ktor.client.curl) // Where is libs.ktor.client.curl
}
}
}
}
答案1
得分: 2
openai-client
子项目位于此处。include 已添加到settings.gradle.kts
中。
在示例代码中,作者使用了称为type-safe project accessor的内容:
> 以短横线式命名(some-lib)或蛇形命名(some_lib)的项目名称将在访问器中转换为驼峰式命名:projects.someLib。
这意味着可以使用projects.openaiClient
添加依赖项。
英文:
The openai-client
subproject is located here. The include was added in settings.gradle.kts
.
In the sample code the author then used something called type-safe project accessor:
> A project name with kebab case (some-lib) or snake case (some_lib)
> will be converted to camel case in accessors: projects.someLib.
This means that the dependency can be added using projects.openaiClient
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论