-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean.ps1
More file actions
87 lines (73 loc) · 3.46 KB
/
clean.ps1
File metadata and controls
87 lines (73 loc) · 3.46 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
# StudySuite Cleanup Script for PowerShell
Write-Host "🧹 Cleaning StudySuite project..." -ForegroundColor Green
# Stop Gradle daemons
Write-Host "Stopping Gradle daemons..." -ForegroundColor Yellow
& .\gradlew --stop
# Wait for processes to release files
Write-Host "Waiting for processes to release files..." -ForegroundColor Yellow
Start-Sleep -Seconds 3
# Clean project
Write-Host "Cleaning project..." -ForegroundColor Yellow
& .\gradlew clean
# Clean build cache
Write-Host "Cleaning build cache..." -ForegroundColor Yellow
& .\gradlew cleanBuildCache
# Clean project build directories
Write-Host "Cleaning project build directories..." -ForegroundColor Yellow
if (Test-Path "build") {
Remove-Item -Recurse -Force "build" -ErrorAction SilentlyContinue
Write-Host "✓ Project build directory cleaned" -ForegroundColor Green
}
if (Test-Path "app\build") {
Remove-Item -Recurse -Force "app\build" -ErrorAction SilentlyContinue
Write-Host "✓ App build directory cleaned" -ForegroundColor Green
}
# Clean IDE files
Write-Host "Cleaning IDE files..." -ForegroundColor Yellow
if (Test-Path ".idea") {
Remove-Item -Recurse -Force ".idea" -ErrorAction SilentlyContinue
Write-Host "✓ IntelliJ IDEA files cleaned" -ForegroundColor Green
}
if (Test-Path ".vscode") {
Remove-Item -Recurse -Force ".vscode" -ErrorAction SilentlyContinue
Write-Host "✓ VS Code files cleaned" -ForegroundColor Green
}
if (Test-Path ".snapshots") {
Remove-Item -Recurse -Force ".snapshots" -ErrorAction SilentlyContinue
Write-Host "✓ Snapshot files cleaned" -ForegroundColor Green
}
# Clean Android build cache
Write-Host "Cleaning Android build cache..." -ForegroundColor Yellow
$androidCachePath = "$env:USERPROFILE\.android\build-cache"
if (Test-Path $androidCachePath) {
Remove-Item -Recurse -Force $androidCachePath -ErrorAction SilentlyContinue
Write-Host "✓ Android build cache cleaned" -ForegroundColor Green
}
# Clean Gradle caches (handle locked files gracefully)
Write-Host "Cleaning Gradle caches..." -ForegroundColor Yellow
$gradleCachePath = "$env:USERPROFILE\.gradle\caches"
if (Test-Path $gradleCachePath) {
try {
Remove-Item -Recurse -Force $gradleCachePath -ErrorAction Stop
Write-Host "✓ Gradle caches cleaned successfully" -ForegroundColor Green
} catch {
Write-Host "⚠ Some Gradle cache files are locked. They will be cleaned on next restart." -ForegroundColor Yellow
Write-Host " Locked files: $($_.Exception.Message)" -ForegroundColor Gray
}
}
# Clean Gradle wrapper cache
Write-Host "Cleaning Gradle wrapper cache..." -ForegroundColor Yellow
$gradleWrapperCachePath = "gradle\wrapper\dists"
if (Test-Path $gradleWrapperCachePath) {
Remove-Item -Recurse -Force $gradleWrapperCachePath -ErrorAction SilentlyContinue
Write-Host "✓ Gradle wrapper cache cleaned" -ForegroundColor Green
}
# Clean temporary files
Write-Host "Cleaning temporary files..." -ForegroundColor Yellow
Get-ChildItem -Path . -Include "*.tmp", "*.log", "*.lock" -Recurse -ErrorAction SilentlyContinue | Remove-Item -Force -ErrorAction SilentlyContinue
Write-Host "✓ Temporary files cleaned" -ForegroundColor Green
Write-Host ""
Write-Host "🎉 Cleanup complete!" -ForegroundColor Green
Write-Host "If you encounter build issues, restart your computer and run this script again." -ForegroundColor Yellow
Write-Host ""
Read-Host "Press Enter to continue"