我的项目依赖于远程定位的.aar
文件。
Android Studio
会在./gradle/caches
目录
当我清理并重新构建项目时,文件不会刷新。
如何强制Android Studio
从远程位置重新加载存档?
或者是否可以禁用特定文件的gradle
缓存?
编辑:我想强制刷新特定文件,而不是刷新整个缓存=>此问题与How to clear gradle cache?
不重复答案 0 :(得分:3)
您可以在~/.gradle/gradle.properties
中禁用缓存:
org.gradle.caching=false
您也可以定义一项任务:
task('clearDomainCache', type: Delete, group: 'Utilities',
description: "Deletes any cached artifacts with the domain of com.myCompany in the Gradle or Maven2 cache directories.") doLast {
def props = project.properties
def userHome = System.getProperty('user.home')
def domain = props['domain'] ?: 'com.myCompany'
def slashyDomain = domain.replaceAll(/\./, '/')
file("${userHome}/.gradle/cache").eachFile { cacheFile ->
if (cacheFile.name =~ "^$domain|^resolved-$domain") delete cacheFile.path
if (cacheFile.name =~ "^*.aar") delete cacheFile.path
}
delete "${userHome}/.m2/repository/$slashyDomain"
}