我正在尝试配置Android库项目以将多个工件部署到本地托管的Maven存储库.我已经足够远,以至于两个工件都生成了自己的POM,并且使用以下脚本将其正确部署到repo:
android {
// Publish both debug and release
publishNonDefault true
}
uploadArchives {
repositories.mavendeployer {
def majorVersion = 1
def minorVersion = 1
def buildVersion = project.properties.get('RELEASE', '0').toInteger()
addFilter('release') { artifact, file ->
file.name.contains('release')
}
addFilter('debug') { artifact, file ->
file.name.contains('debug')
}
activePomFilters.each { filter ->
pom(filter.name) {
groupId = 'com.redacted'
artifactId = 'redacted'
packaging = 'aar'
version = "${majorVersion}.${minorVersion}.${buildVersion}"
if (!project.hasProperty('RELEASE')) {
version += "-SNAPSHOT"
}
if (filter.name == 'debug') {
artifactId += '-debug'
}
}
}
}
}
预期交付是:
com/
redacted/
redacted/
1.1.0-SNAPSHOT/
redacted-debug/
1.1.0-SNAPSHOT/
这是按预期发生的,但它似乎发布了带有额外后缀的工件(它打破了依赖项发现),我无法弄清楚它来自何处或如何更改它.我看到的是:
com/redacted/redacted/1.1.0-SNAPSHOT/
redacted-1.1.0-20150717.213849-1-release.aar
redacted-1.1.0-20150717.213849-1-release.aar.md5
redacted-1.1.0-20150717.213849-1-release.aar.sha1
redacted-1.1.0-20150717.213849-1.pom
redacted-1.1.0-20150717.213849-1.pom.md5
redacted-1.1.0-20150717.213849-1.pom.sha1
出于某种原因,它将日期以及–release后缀附加到仅与AAR相关的文件,而不是POM文件.如果我手动重命名这些文件,一切都按预期工作.例如,这是我期望输出的内容:
com/redacted/redacted/1.1.0-SNAPSHOT/
redacted-1.1.0-20150717.213849-1.aar
redacted-1.1.0-20150717.213849-1.aar.md5
redacted-1.1.0-20150717.213849-1.aar.sha1
redacted-1.1.0-20150717.213849-1.pom
redacted-1.1.0-20150717.213849-1.pom.md5
redacted-1.1.0-20150717.213849-1.pom.sha1
如何更改这些文件的传送方式?
解决方法:
你遇到的是这个(强调我的):
Important: When enabling publishing of non default, the Maven publishing plugin will publish these additional variants as extra packages (with classifier). This means that this is not really compatible with publishing to a maven repository. You should either publish a single variant to a repository OR enable all config publishing for inter-project dependencies.
请参阅文档:http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication
您看到的后缀释放和调试是通过启用非默认工件的发布而引入的分类器. < artifact> build / ivy.xml中的元素(用作Maven配置的基础)包含这些分类器.
迭代配置中的工件并删除分类器不起作用.虽然允许设置分类器,但保留其原始值.
但是,包装原始工件的工作原理是什么.对于分类器,包装器将始终返回null.这确实导致发布和调试工件具有相同的完全限定ID(=名称分类器),这导致仅发布一个工件.这可以通过使用调试工件的不同名称来修复:
class UnclassifiedPublishArtifact implements PublishArtifact {
private PublishArtifact delegatee;
private boolean isDebugArtifact;
UnclassifiedPublishArtifact(PublishArtifact delegatee, isDebugArtifact) {
this.delegatee = delegatee
this.isDebugArtifact = isDebugArtifact
}
@Override
String getName() {
return delegatee.name + (isDebugArtifact ? '-debug' : '')
}
@Override
String getExtension() {
return delegatee.extension
}
@Override
String getType() {
return delegatee.type
}
@Override
String getClassifier() {
return null
}
@Override
File getFile() {
return delegatee.file
}
@Override
Date getDate() {
return delegatee.date
}
@Override
TaskDependency getBuildDependencies() {
return delegatee.buildDependencies
}
}
project.afterEvaluate {
configurations.each { configuration ->
def artifacts = configuration.artifacts
if (!artifacts.isEmpty()) {
def unclassifiedArtifacts = []
unclassifiedArtifacts.addAll(artifacts.collect { classifiedArtifact ->
new UnclassifiedPublishArtifact(classifiedArtifact, classifiedArtifact.classifier == 'debug')
})
artifacts.clear()
artifacts.addAll(unclassifiedArtifacts)
}
}
}
我无法从文档中了解项目依赖性的后果,因此您应该检查这些是否仍然有效.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。