我正在尝试将库发布到Bintray,而尝试上载Aar时遇到问题。我想使用bundleReleaseAar
命令,但不幸的是它对我不起作用,我收到错误Could not get unknown property 'bundleReleaseAar'
。我已经研究了这个问题,并且在四月份左右看到了很多答案,说解决方案是将您的 call 包装在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
}
}
}
}
}
}
}
最佳答案
为了使artifact bundleReleaseAar
工作,必须按照in the documentation所示,将bundleReleaseAar
设置为:
PublishArtifact
AbstractArchiveTask
File
的任何内容Map
因此,您需要弄清楚
bundleReleaseAar
应该是什么,然后从那里获取它。假设这是一项任务,您可以尝试:
artifact tasks.bundleReleaseAar