如何配置插件以依赖特定版本的gradle?

时间:2014-07-11 14:39:51

标签: gradle

我正在编写一组Gradle插件,但我想控制使用的groovy和gradle的特定版本。

我不希望插件依赖于安装的任何Gradle / Groovy版本,如下所示:

dependencies {
  compile localGroovy()
  compile gradleApi()
}

我不想使用本地方法的另一个原因 - 当您使用正确的依赖项规范时,Gradle会知道这些库的源代码,IDE插件可以自动连接源代码。

以下是我的构建脚本的相关部分:

allprojects { Project iProject ->
  apply plugin: 'idea'
  apply plugin: 'maven'

  repositories {
    jcenter()
  }
}

subprojects { Project iProject ->
  apply plugin: 'groovy'

  dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.3.2'
  }

}

project(':eclipsei2g') {
  group = 'eclipsei2g'
  version = '0.0.1-SNAPSHOT'

  dependencies {
    compile 'org.gradle:gradle-core:2.0'
  }
}

project(':g2idea13') {
  group = 'g2idea13'
  version = '0.0.1-SNAPSHOT'

  dependencies {
    compile 'org.gradle:gradle-core:2.0'
    compile 'org.gradle-plugins:gradle-ide:2.0'
  }
}

当我运行它时,我得到一个解决gradle-ide依赖的错误:

Could not resolve all dependencies for configuration ':g2idea13:compile'.
  > Could not find org.gradle:gradle-ide:2.0.
  Searched in the following locations:
  http://jcenter.bintray.com/org/gradle/gradle-ide/2.0/gradle-ide-2.0.pom
http://jcenter.bintray.com/org/gradle/gradle-ide/2.0/gradle-ide-2.0.jar
Required by:
g2idea13:g2idea13:0.0.1-SNAPSHOT

jcenter资源库似乎没有任何内容,因为插件的内容为0.9。 我也试过'org.gradle:gradle-ide:2.0'。

这甚至是我应该这样做的吗?还有另一种方法来指定特定的gradle版本吗?我只是使用错误的存储库?我甚至无法在mavenCentral()上解决gradle-core问题。是否有我应该使用的官方Gradle存储库?

1 个答案:

答案 0 :(得分:2)

gradleApi()是要走的路。目前还没有Gradle插件的公共依赖列表。

相关问题