本文翻译自:How can I force gradle to redownload dependencies?

如何告诉gradle从存储库重新下载依赖项?


#1楼

参考:https://stackoom.com/question/uute/如何强制gradle重新下载依赖项


#2楼

Generally, you can refresh dependencies in your cache with the command line option --refresh-dependencies . 通常,您可以使用命令行选项--refresh-dependencies刷新缓存中的依赖项 。 You can also delete the cached files under ~/.gradle/caches . 您还可以删除~/.gradle/caches下的缓存文件。 With the next build Gradle would attempt to download them again. 使用下一个版本,Gradle将尝试再次下载它们。

What is your specific use case? 你的具体用例是什么? Do you use dynamic dependency versions or SNAPSHOT versions? 您使用动态依赖版本还是SNAPSHOT版本?


On Unix systems, you can delete all the existing artifacts (artifacts and metadata) Gradle has downloaded using: 在Unix系统上,您可以删除Gradle使用以下命令下载的所有现有工件(工件和元数据):

rm -rf $HOME/.gradle/caches/

#3楼

You can tell Gradle to re-download some dependencies in the build script by flagging the dependency as 'changing'. 您可以通过将依赖关系标记为“更改”来告诉Gradle重新下载构建脚本中的某些依赖项。 Gradle will then check for updates every 24 hours, but this can be configured using the resolutionStrategy DSL. Gradle将每24小时检查一次更新,但可以使用resolutionStrategy DSL进行配置。 I find it useful to use this for for SNAPSHOT or NIGHTLY builds. 我发现将它用于SNAPSHOT或NIGHTLY构建很有用。

configurations.all {// Check for updates every buildresolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

Expanded: 扩展:

dependencies {implementation group: "group", name: "projectA", version: "1.1-SNAPSHOT", changing: true
}

Condensed: 凝结:

implementation('group:projectA:1.1-SNAPSHOT') { changing = true }

I found this solution at this forum thread . 我在这个论坛帖子中找到了这个解决方案


#4楼

If you are using a recent version of Gradle, you can use --refresh-dependencies option. 如果您使用的是最新版本的Gradle,则可以使用--refresh-dependencies选项。

./gradlew build --refresh-dependencies

you can refer to the Gradle manual . 你可以参考Gradle手册 。

The --refresh-dependencies option tells Gradle to ignore all cached entries for resolved modules and artifacts. --refresh-dependencies选项告诉Gradle忽略已解析模块和工件的所有缓存条目。 A fresh resolve will be performed against all configured repositories, with dynamic versions recalculated, modules refreshed, and artifacts downloaded. 将对所有已配置的存储库执行全新解析,重新计算动态版本,刷新模块并下载工件。


#5楼

For Windows ...in order to make gradle re-download specific dependencies: 对于Windows ...为了使gradle重新下载特定的依赖项:

  1. delete the dependencies you want to re-download from the directory below: 从以下目录中删除要重新下载的依赖项:

     C:\\Users\\[username]\\.gradle\\caches\\modules-2\\files-2.1 
  2. delete all metadata directories at the path: 删除路径中的所有元数据目录:

     C:\\Users\\[username]\\.gradle\\caches\\modules-2\\metadata-* 
  3. run gradle build (or gradlew build if using gradle wrapper) in the project's root directory. 在项目的根目录中运行gradle build (或者如果使用gradle包装器,则使用gradlew build )。

note: the numbers in the file paths above might be different for you. 注意:上面文件路径中的数字可能与您有所不同。


#6楼

I think gradle 2.14.1 fixes the issue. 我认为gradle 2.14.1解决了这个问题。 The accepted answer is correct, but there is a bug in gradle with –refresh-dependencies. 接受的答案是正确的,但gradle中存在一个带有-refresh-dependencies的错误。 2.14.1 fixes that. 2.14.1解决了这个问题。

See https://discuss.gradle.org/t/refresh-dependencies-should-use-cachechangingmodulesfor-0s/556 请参阅https://discuss.gradle.org/t/refresh-dependencies-should-use-cachechangingmodulesfor-0s/556

如何强制gradle重新下载依赖项?相关推荐

  1. npm install下载依赖项时报错 fatal: unable to access ‘https://github.com/nhn/raphael.git/‘: Failed to connect

    解决方案: 1:查看一下自己的node版本,一般高版本下载会出问题,建议使用 12.17.0版本 2:网络延迟的问题,删除package.lock.json和node_modules文件夹,重新ins ...

  2. 将JAR依赖项添加到Eclipse插件Maven Tycho构建

    开发OPP项目时,一直困扰着我的是使用硬编码Java库依赖项. 我手动下载了所用库的jar ,将其复制到需要它们的插件中的目录中,然后将其添加到MANIFEST.MF文件中. 您可能会问我为什么要这样 ...

  3. Gradle入门:依赖管理

    即使不是没有可能,创建没有任何外部依赖关系的现实应用程序也是一项挑战. 这就是为什么依赖性管理是每个软件项目中至关重要的部分的原因. 这篇博客文章描述了我们如何使用Gradle管理项目的依赖关系. 我 ...

  4. gradle工程之间依赖

    一个gradle项目可能包含多个子项目,项目间的依赖是常见的情况.如何配置gradle,使其在构建过程中包括依赖项(子项目)? 有两种情况: 1.项目是一个根项目,依赖项位于其根目录下 当依赖的项目位 ...

  5. 代理设置。 安卓工作室配置用http代理。gradle可能需要这些http代理设置去访问互联网。例如下载依赖。 你想要复制ide的代理配置到这个项目的gradle属性文件吗?...

    代理设置. 安卓工作室配置用http代理.gradle可能需要这些http代理设置去访问互联网.例如下载依赖. 你想要复制ide的代理配置到这个项目的gradle属性文件吗? 查看更多细节,请参阅开发 ...

  6. Gradle 下载依赖失败解决方法

    修改单独项目 在项目的build.gradle文件中,修改repositories配置  由: repositories {mavenCentral()maven { url 'https://rep ...

  7. Gradle 依赖项管理

    2019独角兽企业重金招聘Python工程师标准>>> defaultTasks "hello"configurations {starling//不进行依赖传递 ...

  8. gradle排除依赖_如何从Gradle中的所有依赖项中排除库

    gradle排除依赖 我正在使用Spring Boot. 默认情况下,Spring Boot带有Logback. 我想使用log4j(出于任何原因..) 为了做到这一点,我不得不排除logback并添 ...

  9. Gradle技巧–显示buildscript依赖项

    在Gradle中如何显示和分析buildscript依赖项(例如插件)的简单方法 介绍 这是我的Gradle技巧迷你系列的第三部分,该系列与可视化和依赖性分析有关. 在第一篇文章中,我介绍了一种如何显 ...

最新文章

  1. 简单介绍Go语言错误处理异常捕获+异常抛出
  2. c语言 生成大素数,C语言实现寻找大素数
  3. 八十三、经典排序算法之堆排序
  4. Linux内核参数的介绍
  5. oracle mssql 实例,oracle,mysql,SqlServer三种数据库的分页查询的实例
  6. vue 后台翻译_vue实现在线翻译功能
  7. ISO光盘镜像导入到U盘的方法
  8. 小虎整合:电商浏览器插件工具常用的有哪些?在哪里可以找到?
  9. 【NDVI:注意力机制:遥感图像】
  10. 软件测试方法进行调优,一种大型软件测试方法
  11. 网页番茄钟(Pomodoro timer)
  12. System.Net.Sockets空间
  13. CM1-确定字符互异-【字符串】
  14. SVG - 在Android中使用矢量图全攻略
  15. 开源规则引擎比较_开源物联网平台ThingsBoard
  16. SOHO 企业网吧 路由器 智能QoS 3G MIFI
  17. php 大量数导出表格 打包成zip
  18. 互联网 Java 工程师进阶知识完全扫盲
  19. 大一项目实训—学生成绩管理系统
  20. android是否支持 ipv6,判断你的网络是否支持IPv6

热门文章

  1. 《CCNA学习指南:数据中心(640-911)》——2.2 网络互联模型
  2. Mysql间隔取数据,实现sqlserver的row_number()函数
  3. mysql主从简明配置
  4. 实施云计算之后如何保证安全
  5. rabbitmq队列中消息过期配置
  6. AS3 BitmapData中获取非透明区域对应矩阵
  7. MySQL 5.6 主从报错一例
  8. Failed to start Zabbix Agent.
  9. windows中的凭据管理
  10. 压缩文件后,每次的HASH值(MD5)都不相同的原因