Java 如何从命令行更新 Gradle 依赖项?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26773292/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to update Gradle dependencies from command line?
提问by Kshitiz Sharma
I have following build.gradle
file:
我有以下build.gradle
文件:
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.7
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
compile 'org.springframework:spring-core:4.1.1.RELEASE'
compile 'org.springframework:spring-context:4.1.1.RELEASE'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
I run following command:
我运行以下命令:
$ gradle --refresh-dependencies
But it does nothing. The dependencies do not get updated and do not reflect on classpath.The output from command is:
但它什么也不做。依赖项不会更新,也不会反映在类路径上。命令的输出是:
:help
Welcome to Gradle 2.1.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
BUILD SUCCESSFUL
Total time: 5.999 secs
Doing this via Eclipse gradle plugin is working though.
不过,通过 Eclipse gradle 插件执行此操作是可行的。
采纳答案by Jeff Mixon
gradle --refresh-dependencies <task>
回答by Edy Aguirre
You should first clean with gradle clean
and then gradle eclipse
finally go to project in eclipse and refresh the project, it works for my.
您应该首先清理,gradle clean
然后gradle eclipse
最后转到 eclipse 中的项目并刷新项目,它适用于我的。
回答by Sandeep Sarkar
I am using Gradle 2.9 and I use this for force refresh:
我使用的是 Gradle 2.9,我用它来强制刷新:
gradle build --refresh-dependencies
回答by Zozo
If you have multiple projects then and want to execute only on one project the clean-eclipse (without quotation marks)
如果您有多个项目并且只想在一个项目上执行 clean-eclipse(不带引号)
gradle 'project name':cleanEclipse 'project name':eclipse --refresh-dependencies
after you just refresh the project in your IDE.
在您的 IDE 中刷新项目后。