[英]How to set dependency of android gradle project to different versions of library?
I have small log library and it is published to jcenter. 我有一个小的日志库,它已发布到jcenter。 I need to have two versions of the library - debug and release.
我需要具有该库的两个版本-调试和发布。 To do this I found flag
publishNonDefault true
and pushed new version of library. 为此,我发现
publishNonDefault true
标志publishNonDefault true
并推送了新版本的库。
Structure of files in repository before flag was set: 设置标志之前存储库中文件的结构:
Structure of files in repository after flag was set:
设置标志后存储库中文件的结构:
And now 现在
dependencies { compile 'me.shikhov:wlog:1.3.1' }
gives me error 给我错误
Error:A problem occurred configuring project ':Project'.
Could not find wlog.jar (me.shikhov:wlog:1.3.1).
Searched in the following locations:
https://jcenter.bintray.com/me/shikhov/wlog/1.3.1/wlog-1.3.1.jar
I have found syntax for local dependency, for example: 我发现了本地依赖的语法,例如:
debugCompile project(path: ':myLocalLibrary', configuration: 'debug')
releaseCompile project(path: ':myLocalLibrary', configuration: 'debug')
How to set remote library dependency? 如何设置远程库依赖关系?
The extra string after the version in the artifact name is the classifier. 工件名称中版本之后的额外字符串是分类器。
The classifier allows to distinguish artifacts that were built from the same POM but differ in their content.
分类器允许区分从相同POM构建但内容不同的工件。 It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number.
它是一些可选的任意字符串,如果存在,则在版本号之后附加到工件名称。 As a motivation for this element, consider for example a project that offers an artifact targeting JRE 1.5 but at the same time also an artifact that still supports JRE 1.4.
作为对此元素的激励,例如考虑一个提供针对JRE 1.5的工件的项目,同时提供仍然支持JRE 1.4的工件。 The first artifact could be equipped with the classifier jdk15 and the second one with jdk14 such that clients can choose which one to use.
第一个工件可以配备分类器jdk15,第二个工件可以配备jdk14,以便客户可以选择使用哪个分类器。
Another common use case for classifiers is the need to attach secondary artifacts to the project's main artifact.
分类器的另一个常见用例是需要将辅助工件附加到项目的主要工件。 If you browse the Maven central repository, you will notice that the classifiers sources and javadoc are used to deploy the project source code and API docs along with the packaged class files.
如果浏览Maven中央存储库,则会注意到分类器源代码和javadoc用于与打包的类文件一起部署项目源代码和API文档。
Gradle dependency declaration takes the form: Gradle依赖项声明采用以下形式:
[organisation]:[module]:[revision]:[classifier]@[ext]
so you should be consuming the dependency as: 所以您应该将依赖项作为以下方式使用:
compile 'me.shikhov:wlog:1.3.1:release@aar'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.