Force refresh of archive

Force refresh of archive



My project has a dependency on an .aar file located remotely.


.aar



Android Studio keeps a copy of this file in my ./gradle/caches directory


Android Studio


./gradle/caches



When I clean and re-build the project, the file is not refreshed.



How can I force Android Studio to reload the archive from the remote location ?


Android Studio



Or is it possible to disable the gradle cache for a specific file ?


gradle



EDIT: I'd like to force a refresh of a specific file, not of the whole cache => This question is not a duplicate of How to clear gradle cache?





Possible duplicate of How to clear gradle cache?
– Arash Hatami
Jan 2 '18 at 10:38





I read that already, it takes too long to clear and rebuild the whole cache, hence my question
– matdev
Jan 2 '18 at 11:32




1 Answer
1



You can disable caching in ~/.gradle/gradle.properties :


~/.gradle/gradle.properties


org.gradle.caching=false



Also you can define a task to do that :


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 ^resolved-$domain") delete cacheFile.path
if (cacheFile.name =~ "^*.aar") delete cacheFile.path

delete "$userHome/.m2/repository/$slashyDomain"





I've added org.gradle.caching=false to my gradle.properties file and when I build, an old version of the archive reappears in my .gradle directory :(
– matdev
Jan 2 '18 at 15:12






I've tried using a task, but running it does not delete the classes.jar file contained in my .gradle/caches/transforms-1/files-1.1/ directory. Also, even with org.gradle.caching=false, the archive file keep on, reappearing in .gradle/caches
– matdev
Jan 9 '18 at 9:54






this statement control delete processif (cacheFile.name =~ "^$domain|^resolved-$domain") @matdev
– Arash Hatami
Jan 19 '18 at 11:04


if (cacheFile.name =~ "^$domain|^resolved-$domain")





Many thanks ! I managed to clear the cached aar files by adding the line if (cacheFile.name =~ "^*.aar") delete cacheFile.path
– matdev
Jan 22 '18 at 9:48





OK that sounds good ... answer updated @matdev
– Arash Hatami
Jan 22 '18 at 9:54



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế