首页 > 解决方案 > 无法将 Kotlin 库发布到 Jitpack

问题描述

我创建了一个使用 Apollo 作为其 GraphQL 客户端的 Kotlin 库。我正在尝试将其发布到 Jitpack。我运行 ./gradlew install 命令但构建失败:

Could not publish configuration 'archives'
Cannot publish artifact 'metadata.json' (.../sample/build/generated/metadata/apollo/debugAndroidTest/service/metadata.json)) as it does not exist.

如果需要更多信息,请告诉我。谢谢!

标签: androidkotlingradleapollojitpack

解决方案


希望这可以帮助其他开发人员。

Jitpack 文档未更新。确保您没有使用:

plugins {
    id 'com.android.library'
    id 'kotlin-android'
    id 'com.apollographql.apollo'
    id 'kotlinx-serialization'
    id 'com.github.dcendents.android-maven' <------
}

替换com.github.dcendents.android-mavenmaven-publishcom.github.dcendents.android-maven被标记为已弃用。然后你可以在你的库构建 gradle 中将你的配置添加到 public 到 maven。

    afterEvaluate {
        publishing {
            publications {
                // Creates a Maven publication called "release".
                release(MavenPublication) {
                    // Applies the component for the release build variant.
                    from components.release
    
                    // You can then customize attributes of the publication as shown below.
                    groupId = 'com.test.sdk.library'
                    artifactId = 'test'
                    version = 0.0.1 //(whatever version you want)
                }
            }
        }
    }

推荐阅读