-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
186 lines (164 loc) Β· 6.85 KB
/
build.gradle
File metadata and controls
186 lines (164 loc) Β· 6.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.compose) apply false
}
task cleanSpecificDependencies {
group = 'cleanup'
description = 'Clean specific dependencies from cache'
doLast {
def dependenciesToClean = [
'com.github.paymentwall:android-gamepay-sdk-core-ui:0.0.50',
'com.facebook.shimmer:shimmer:0.5.0',
'com.github.corouteam:GlideToVectorYou:v2.0.0',
'org.jfrog.cardinalcommerce.gradle:cardinalmobilesdk:2.2.7-5'
]
// Function to check if dependency exists in cache
def checkDependencyExists = { dep ->
def (group, artifact, version) = dep.split(':')
def cacheBase = "${System.getProperty('user.home')}/.gradle/caches"
def foundFiles = []
// Check modules cache
def modulesPath = "${cacheBase}/modules-2/files-2.1/${group}/${artifact}/${version}"
def modulesDir = file(modulesPath)
if (modulesDir.exists()) {
foundFiles.add("modules: ${modulesPath}")
}
// Check transforms (broader search)
def transformsDirs = fileTree(cacheBase) {
include '**/transforms-*/**'
include "**/*${artifact}*"
}
transformsDirs.each { file ->
if (file.absolutePath.contains(artifact)) {
foundFiles.add("transform: ${file.absolutePath}")
}
}
// Check metadata
def metadataFiles = fileTree("${cacheBase}/modules-2") {
include '**/metadata-*/**'
include "**/*${artifact}*"
}
metadataFiles.each { file ->
if (file.absolutePath.contains(artifact)) {
foundFiles.add("metadata: ${file.absolutePath}")
}
}
// Check artifacts cache
def artifactDirs = fileTree(cacheBase) {
include '**/artifacts-*/**'
include "**/*${artifact}*"
}
artifactDirs.each { file ->
if (file.absolutePath.contains(artifact)) {
foundFiles.add("artifacts: ${file.absolutePath}")
}
}
// Check jars cache
def jarDirs = fileTree(cacheBase) {
include '**/jars-*/**'
include "**/*${artifact}*"
}
jarDirs.each { file ->
if (file.absolutePath.contains(artifact)) {
foundFiles.add("jars: ${file.absolutePath}")
}
}
return foundFiles
}
// Pre-cleanup verification
println "\nπ Pre-cleanup verification:"
def preCleanupStatus = [:]
dependenciesToClean.each { dep ->
def foundFiles = checkDependencyExists(dep)
preCleanupStatus[dep] = foundFiles
println " π¦ $dep: ${foundFiles.size()} cache entries found"
}
println "\nπ§Ή Starting cleanup process..."
dependenciesToClean.each { dep ->
println "\nπ§Ή Cleaning: $dep"
def (group, artifact, version) = dep.split(':')
def cacheBase = "${System.getProperty('user.home')}/.gradle/caches"
// Clean modules cache
def modulesPath = "${cacheBase}/modules-2/files-2.1/${group}/${artifact}/${version}"
def modulesDir = file(modulesPath)
if (modulesDir.exists()) {
println " π Removing modules: $modulesPath"
delete modulesDir
} else {
println " β οΈ Modules not found: $modulesPath"
}
// Clean transforms
def transformsDirs = fileTree(cacheBase) {
include '**/transforms-*/**'
include "**/*${artifact}*"
}
transformsDirs.each { file ->
if (file.absolutePath.contains(artifact)) {
println " π Removing transform: ${file.absolutePath}"
delete file
}
}
// Clean metadata
def metadataFiles = fileTree("${cacheBase}/modules-2") {
include '**/metadata-*/**'
include "**/*${artifact}*"
}
metadataFiles.each { file ->
if (file.absolutePath.contains(artifact)) {
println " π Removing metadata: ${file.absolutePath}"
delete file
}
}
// Clean artifacts cache
def artifactFiles = fileTree(cacheBase) {
include '**/artifacts-*/**'
include "**/*${artifact}*"
}
artifactFiles.each { file ->
if (file.absolutePath.contains(artifact)) {
println " π¦ Removing artifacts: ${file.absolutePath}"
delete file
}
}
// Clean jars cache
def jarFiles = fileTree(cacheBase) {
include '**/jars-*/**'
include "**/*${artifact}*"
}
jarFiles.each { file ->
if (file.absolutePath.contains(artifact)) {
println " πΊ Removing jars: ${file.absolutePath}"
delete file
}
}
}
println "\nπ Post-cleanup verification:"
def allCleanedSuccessfully = true
dependenciesToClean.each { dep ->
def remainingFiles = checkDependencyExists(dep)
def preCount = preCleanupStatus[dep].size()
def postCount = remainingFiles.size()
if (remainingFiles.isEmpty()) {
println " β
$dep: Completely removed (was: $preCount, now: 0)"
} else {
println " β $dep: ${remainingFiles.size()} files still remain (was: $preCount, now: $postCount)"
remainingFiles.each { file ->
println " π Remaining: $file"
}
allCleanedSuccessfully = false
}
}
println "\n" + ("=" * 60)
if (allCleanedSuccessfully) {
println "β
SUCCESS: All specified dependencies completely removed from cache!"
} else {
println "β οΈ WARNING: Some dependency files could not be removed"
println " This might be due to files being in use or permission issues"
println " Try stopping any running Gradle daemons with: ./gradlew --stop"
}
println "Run: ./gradlew build --refresh-dependencies to download fresh copies"
println "=" * 60
}
}