警告有关Android项目库的gradle依赖 [英] Warning about an Android Library project gradle dependencies

查看:150
本文介绍了警告有关Android项目库的gradle依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立使用Android Studio中的Andr​​oid库项目。该类型的模块是的com.android.library的中的 gradle.build 的文件。该模块有一些依赖关系:

  {相关性
    编译com.squareup.retrofit:改造:1.9.0
    编译com.squareup.okhttp:okhttp:2.3.0
}

的模块建立结果在一个.aar文件。我想.aar文件的用户被通知/警告.aar依赖所以他的计划没有成功,直到建立这些依赖关系都设置自己的项目中。有没有办法做到这一点?


解决方案

  

我想.aar文件的用户被通知/警告.aar依赖所以他的计划没有成功,直到建立这些依赖关系都设置自己的项目中。


好了,在一定程度上,这将自动发生,因为他们的编译会失败。

如果您分发本AAR作为一个存储库中的神器,存储库的元数据(例如,对于一个Maven回购POM文件)可以包含有关这些依赖关系的信息。当开发人员使用的神器许多构建系统(摇篮,Maven的,等等)将使用自动下载这些依赖需要。

如果您选择分发此AAR通过其他方式(例如,一个QR code小山上的大小),你需要告诉开发者,他们需要通过某种形式的文档,包括这些依赖关系。

预见的后续问题...


  

我应该能够发布.aar通过一个Maven回购闭源神器?


当然。虽然Maven的中央和JCenter量身定制的开放源码,你当然可以有自己的回购协议。这只是一个与某些内容目录。例如,我有我自己的回购我的开源库,虽然我的图书馆是开源的,没有任何关于将要求的存储库来保存开源$ C ​​$ C回购。

I am building an Android Library project using Android Studio. The type of the module is 'com.android.library' in gradle.build file. This module has a number of dependencies:

dependencies {    
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp:2.3.0'
}

The module builds result in a .aar file. I want the user of the .aar file to be notified/warned about .aar dependencies so his project doesn't successfully builds till these dependencies are set inside his project. Is there a way to do this?

解决方案

I want the user of the .aar file to be notified/warned about .aar dependencies so his project doesn't successfully builds till these dependencies are set inside his project.

Well, to some extent, that would happen automatically, as their compile would fail.

If you distribute this AAR as an artifact in a repository, the repository metadata (e.g., POM file for a Maven repo) can contain information about these dependencies. Many build systems (Gradle, Maven, etc.) will use that to automatically download those dependencies as needed when the developer uses your artifact.

If you elect to distribute this AAR by other means (e.g., a QR code the size of a small mountain), you will need to tell developers that they need to include these dependencies through documentation of some sort.

Anticipating a follow-up question...

I should be able to publish a .aar closed source artifact through a Maven repo ?

Sure. While Maven Central and JCenter are tailored for open source, you can certainly have your own repo. It's just a directory with certain contents. For example, I have my own repo for my open source libraries, and while my libraries are open source, there is nothing about the repo that would require the repositories to hold open source code.

这篇关于警告有关Android项目库的gradle依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆