GitHub Packages:无效的发布“release”:具有相同扩展名和分类器的多个工件(“aar”、“null”)

问题描述 投票:0回答:1

我一直在尝试通过 GitHub Packages 发布该库,为此我正在关注这篇 Medium 帖子:将 Android 库发布到 GitHub Packages

这是我的

build.gradle
文件:

import java.util.Properties

plugins {
    id("com.android.library")
    id("org.jetbrains.kotlin.android")
    id("maven-publish")
}
val getVersionName = "1.0.0"
val getArtifactId = "dynamic-map"
val githubProperties = Properties()
githubProperties.load(
    rootProject.file("github.properties").inputStream()
) // Load GitHub credentials from github.properties file

android {
    ...
}

dependencies {
    ...
}

afterEvaluate {
    val gitUsername = githubProperties.getProperty("gpr.usr")
    val gitPassword = githubProperties.getProperty("gpr.key")

    println("GitHub Username: $gitUsername")
    println("GitHub Token: $gitPassword")

    publishing {
        publications {
            create<MavenPublication>("release") {
                from(components["release"])
                groupId = "com.gaurav.kumar"
                artifactId = getArtifactId
                version = getVersionName
                artifact("$buildDir/outputs/aar/${getArtifactId}-release.aar")
            }
        }
        repositories {
            maven {
                name = "DynamicMapRepo"
                url = uri("https://maven.pkg.github.com/Cypher103360/DynamicMap")

                credentials {
                    username = gitUsername
                    password = gitPassword
                }
            }
        }
    }
}

当我尝试通过此命令发布它时:

./gradlew publish
,我得到:

gaurav@gaurav-ThinkPad-E15-Gen-4:~/AndroidStudioProjects/DynamicMap$ ./gradlew publish

> Configure project :dynamic-map
GitHub Username: Cypher103360
GitHub Token: *****

> Task :dynamic-map:publishReleasePublicationToDynamicMapRepoRepository FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dynamic-map:publishReleasePublicationToDynamicMapRepoRepository'.
> Failed to publish publication 'release' to repository 'DynamicMapRepo'
   > Invalid publication 'release': multiple artifacts with the identical extension and classifier ('aar', 'null').

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 1s
25 actionable tasks: 21 executed, 4 up-to-date

有人可以帮助我吗?

android kotlin github-packages
1个回答
0
投票

工件已成功发布,无需显式指定工件文件。在 Maven 发布中,插件可以根据您在发布中包含的组件自动确定要发布的工件。

通过排除显式工件线:

//artifact("$buildDir/outputs/aar/${getArtifactId}-release.aar")

此方法依赖于 Maven 发布插件的默认行为,并且在我的情况下似乎运行良好。

© www.soinside.com 2019 - 2024. All rights reserved.