1

我正在尝试将库发布到 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
                        }
                    }
                }
            }
        }
    }
}
4

2 回答 2

2

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

于 2019-10-30T23:05:49.463 回答
1

为了artifact bundleReleaseAar工作,bundleReleaseAar需要,如文档中所示:

  • 一种PublishArtifact
  • 一个AbstractArchiveTask
  • 任何可以解决的问题File
  • AMap带有特殊条目

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

于 2019-10-30T17:35:33.267 回答