Gradle并添加github项目作为依赖项,一些澄清

时间:2015-10-21 07:52:27

标签: java android github gradle netbeans-8

我对Gradle很新,我接受了一些教程并阅读了wiki和指南,但我仍然有一些问题我无法找到答案。

我想要的是关于Gradle和一般github项目依赖关系的一些说明。

阅读this question,他提到了以下例子:

dependencies {  
    mavenCentral()
    compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
}

我得到com.github.chrisbanes.actionbarpulltorefresh,它基本上是com.github.username.repository,但究竟代表extra-abc+的是什么?

在gradle irc上,他们说第一个是神器,他们给了我this,在那里说:Dependency configurations are also used to publish files ..但我仍然没有...哪些文件和哪个文件你想做那个purpouse吗?我猜工件应该引用罐子,但为什么给它命名(extra-abc)?

+取代版本通常所在的位置,所以我认为应该指出最新版本,不应该吗?

此外,我粘贴的示例对github上托管的gradle和plain(netbeans)项目是否有效,还是我们必须区分?

我正在使用带有gradle插件的Netbeans 8.02。

对于愚蠢的问题感到抱歉,但我真的想清除我的怀疑。

1 个答案:

答案 0 :(得分:0)

首先,this library 不再维持。您应该使用支持库。

  

我得到com.github.chrisbanes.actionbarpulltorefresh,它基本上是com.github.username.repository,

这是不正确的 该库在Maven Central上发布。

com.github.chrisbanes.actionbarpulltorefresh是您可以在Maven上找到的工件的 groupId

  

但是究竟代表extra-abc

extra-abc是Maven上工件的名称(图书馆名称......)。

您可以在这里找到the full list

|GroupId                                     |ArtifactId|   Latest Version|
|--------------------------------------------|----------|-----------------|
|com.github.chrisbanes.actionbarpulltorefresh|library   |            0.9.9|
|com.github.chrisbanes.actionbarpulltorefresh|extra-abs |            0.9.9|
|com.github.chrisbanes.actionbarpulltorefresh|extra-abc |            0.9.9|
  

和+

表示要使用最后一个版本。 在您的情况下,您可以使用以下其中一种:

compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:0.+'
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:0.9.+'
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:0.9.9'

请注意,使用+通常不是一个好主意,因为您无法知道您使用的是什么版本。
在这种情况下,由于库已被弃用,因此不存在问题。

修改
如果问题是我怎么能添加maven repo上没有的github项目作为我的项目的参考呢?

请参阅this answer