无法获得SoftwareComponentInternal的未知属性“release”-Maven发布插件项目gradle

我有一个包含多个模块的 Android 项目,我想将它们发布到自托管的 maven 存储库。我早些时候将发布代码存在于各个模块中,并且一切正常。我现在正在尝试将发布代码移动到项目中,build.gradle以便我可以重用代码。我的各个模块中的代码是:

afterEvaluate {
        // To avoid publishing the applications inside the project...
        if (!plugins.hasPlugin("android")) {
            publishing {
                publications {
                    mavenAar(MavenPublication) {
                        artifactId "$project.name"
                        from components.release
                    }
                }
                repositories {
                    .... My repo details and credentials .......
                }
            }
        }
    }

一切都很好。当我将代码移至项目时build.gradle,如下所示:

subprojects {
    apply plugin: 'maven-publish'

    afterEvaluate {
        // To avoid publishing of the applications inside the project ..
        if (!plugins.hasPlugin("android")) {
            publishing {
                publications {
                    mavenAar(MavenPublication) {
                        artifactId "$project.name"
                        from components.release
                    }
                }
                repositories {
                    .... My reop details and creddentials  .....
                }
            }
        }
    }
}

运行publish任务时,我开始收到以下错误:

A problem occurred configuring project ':mymodule'.
> Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

有人可以指出这里的问题吗?

以上是无法获得SoftwareComponentInternal的未知属性“release”-Maven发布插件项目gradle的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>