Gradle 重命名 maven 依赖包(HttpComponents,Android) [英] Gradle rename maven dependency package (HttpComponents, Android)

查看:34
本文介绍了Gradle 重命名 maven 依赖包(HttpComponents,Android)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android 上使用和选择发出 HTTP(S) 请求的方式是一个长期的痛苦.

Using and Choosing way to make HTTP(S) requests on Android is a long-time pain.

虽然 Google 希望我们使用 HttpURLConnection,但也有人更喜欢使用 HttpClient.

Although Google wants us to use HttpURLConnection, there are those who prefer to use HttpClient instead.

有这个库,https://code.google.com/p/httpclientandroidlib/ 带有打包脚本.

There is this library, https://code.google.com/p/httpclientandroidlib/ with packaging script.

我宁愿使用与 Android 构建环境更加集成的东西.

I'd rather use something more integrated with Android build environment.

是否有可能使用 Gradle 以与 httpclientandroidlib 相同的方式重新打包 Maven 依赖项(整个树,包括 httpclient、httpcomponents、httpmime 等)?

Is there possibility to use Gradle to repackage Maven dependency (whole tree, including httpclient, httpcomponents, httpmime, ...) in the same way httpclientandroidlib does?

最好的方案是以同样透明的方式下载、重新打包和链接这些库.

The best scenario would be to have gradle download,repackage and link those libraries in the same transparent way.

毕业:

dependencies {
    compile 'org.apache.httpcomponents:httpclient:4.2.3'
    compile 'org.apache.httpcomponents:httpmime:4.2.3'
}

推荐答案

从 org.apache.http 到其他命名空间的简单重新打包有一个缺点,即呈现 HttpClient 与针对库存 API 编译的第 3 方库不兼容.有计划创建 HttpClient 4.3 的重新版本,专门用于与 4.0 BETA1 API 完全兼容的 Android,并将 4.3 的大部分功能向后移植.令人遗憾的是,减轻 Android 的 HttpClient 分支的损害的方法似乎是通过创建另一个分支.感谢谷歌.

Simple repackaging from org.apache.http to some other namespace has a drawback of rendering HttpClient incompatible with 3rd party libraries compiled against the stock APIs. There are plans to create a re-spin of HttpClient 4.3 specifically for Android fully compatible with 4.0 BETA1 APIs and with most of 4.3 features back-ported to it. It is a shame really that the way of mitigating the damage of Android's fork of HttpClient appears to be by creating yet another fork. Thank you Google.

新信息
Apache HttpComponents 只为 Android 创建了 HttpClient 库,可在此处获得:https://hc.apache.org/httpcomponents-client-4.3.x/android-port.html

这篇关于Gradle 重命名 maven 依赖包(HttpComponents,Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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