在我的模块构建脚本 (build.gradle) 中,我可以设置依赖项:
dependencies {
compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
}
我还可以在构建脚本中使用 buildscript()
方法并设置依赖项:
If your build script needs to use external libraries, you can add them to the script's classpath in the build script itself. You do this using the buildscript() method, passing in a closure which declares the build script classpath.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'commons-codec', name: 'commons-codec', version: '1.2'
}
}
我的问题是,这些是一样的吗?这两种设置构建脚本依赖的方式有什么区别吗?
最佳答案
区别很大。前者声明(编译)你的代码的依赖关系;后者声明构建脚本本身的依赖项(即它允许在构建脚本中使用 commons-codec)。
关于Gradle:build.gradle 内部与 buildScript() 内部的依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25026903/