Compose for desktop如何导入三方库

281 阅读1分钟

每日小技巧

在日常开发中会需要各种三方库(okhttp,retrofit2等),这时候就需要引入库了

方法:
导包和Android很像
android 是在module中的build.gradle.kts
Compose for desktop是在 ://项目目录/build.gradle.kts

dependencies {
    // Note, if you develop a library, you should use compose.desktop.common.
    // compose.desktop.currentOs should be used in launcher-sourceSet
    // (in a separate module for demo project and in testMain).
    // With compose.desktop.common you will also lose @Preview functionality
    implementation(compose.desktop.currentOs)
    implementation("org.jmdns:jmdns:3.5.8")
    implementation("com.squareup.okhttp3:okhttp:4.11.0")
    implementation("com.squareup.okhttp3:mockwebserver:4.11.0")
}

当然要记得点击grale的同步按钮才能下载生效

用于帮助新入坑的同学