【问题标题】:Could not get unknown property 'bundleReleaseAar' Maven Publish无法获取未知属性 'bundleReleaseAar' Maven 发布
【发布时间】:2019-10-29 19:11:05
【问题描述】:

我正在尝试将库发布到 Bintray,但在尝试上传 Aar 时遇到问题。我想使用命令bundleReleaseAar,但不幸的是它对我不起作用,我收到错误Could not get unknown property 'bundleReleaseAar'。我已经研究过这个问题,我从四月左右看到了很多答案,说解决方案是将您的电话转入project.afterEvaluate,但这对我不起作用。 这是我的代码的样子:

bintray {
    user = 'dev'
    key = 'asdf'
    publications = ['MyPublication']

    override = true
    publish = true

    pkg {
        repo = 'name of repo'
        name = 'name of package'
        userOrg = 'org'
        licenses = ['Apache-2.0']
        vcsUrl = 'https//:git.url'
        version {
            name = '0.0.1'
            released = new Date()
            vcsTag = '0.0.1'
        }
    }
}

def pomConfig = {
    licenses {
        license {
            name "The Apache Software License, Version 2.0"
            url "http://www.apache.org/licenses/LICENSE-2.0.txt"
            distribution "repo"
        }
    }
    developers {
        developer {
            id "dev"
            name "dev"
        }
    }

    scm {
        url 'https//:git.url'
    }
}

/***************************************/
/*** THIS IS THE RELEVANT CODE BLOCK ***/
/***************************************/
project.afterEvaluate {
    publishing {
        publications {
            MyPublication(MavenPublication) {
                artifactId 'Artificat Id'
                groupId 'com.group'
                version '0.0.1'

                /****************************/
                /*** WHY DOES THIS CRASH? ***/
                /****************************/
                artifact bundleReleaseAar

                pom.withXml {
                    def dependenciesNode = asNode().getAt('dependencies')[0] ?: asNode().appendNode('dependencies')

                    configurations.implementation.allDependencies.each {

                        if (it.name != 'unspecified') {
                            def dependencyNode = dependenciesNode.appendNode('dependency')
                            dependencyNode.appendNode('groupId', it.group)
                            dependencyNode.appendNode('artifactId', it.name)
                            dependencyNode.appendNode('version', it.version)
                            dependencyNode.children().last() + pomConfig
                        }
                    }
                }
            }
        }
    }
}

【问题讨论】:

    标签: android maven gradle bintray maven-publish


    【解决方案1】:

    我想通了。我在项目级别 build.gradle 中有这段代码,而它应该在库模块 build.gradle 中。将脚本移至此处有效。我不知道为什么这不幸地解决了这个问题。我只能猜测bundleReleaseAar 依赖于 'com.android.library' 插件。

    【讨论】:

      【解决方案2】:

      为了使artifact bundleReleaseAar 工作,bundleReleaseAar 需要,如 in the documentation 所示:

      • PublishArtifact
      • AbstractArchiveTask
      • 任何可以解析为File
      • 带有特殊条目的Map

      所以你需要弄清楚bundleReleaseAar 应该是什么并从那里得到它。 假设这是一项任务,您可以尝试:artifact tasks.bundleReleaseAar

      【讨论】:

        猜你喜欢
        • 2021-07-19
        • 2018-07-10
        • 2021-01-30
        • 2020-08-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多