• Stars
    star
    928
  • Rank 49,232 (Top 1.0 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

When Gradle or the IDE let you down, just --nuke all them caches

deep-clean

A Kotlin script that nukes all build caches from Gradle/Android projects. Useful when Gradle or the IDE let you down 💔

deep-clean in action

🎩 h/t to @Takhion for the original idea, and to @holgerbrandl for KScript.

The script has been tested on macOS 🍎, but it is completely untested on Linux 🐧 and Windows 🖥️. KScript may not work at all on Windows!

⚠️There may be major issues on Windows/Linux when using -n, please let me know if you encounter any such issue!

USE AT YOUR OWN RISK IN ANY CASE!

Running the script

deep-clean requires three components to be on your PATH:

If you have all three commands on your PATH, then you can simply download and execute the script:

$ cd /your/project/root.folder
$ [kscript] deep-clean.kts [options]

Note: on macOS and Linux the script does not need kscript to be invoked, because it has a shebang. On Windows, you will need to explicitly specify you want to use kscript to run it.

Where the options are:

-b --backup           Renames files and folders instead of deleting them. Implies
                      --verbose.
-d --dry-run          Don't delete anything. Useful for testing. Implies --verbose.
-i --ide-files        This also deletes IDEA/Android Studio project files (*.iml).
                      If used in conjunction with --nuke it will also delete the
                      .idea folder in the current directory.
-p --ide-preferences  ⚠️  THIS IS DANGEROUS SHIT ⚠️  Will wipe your IDE settings!
                      This deletes the GLOBAL IDEA/Android Studio preferences.
                      This option requires the --nuke option to be active too, since
                      it touches global system state.
--not-recursive       Don't recursively search sub-folders of this folder for matches.
                      The default behaviour is to look for matches in sub-directories,
                      since things like 'build' folders and '.iml' files are not all
                      found at the top level of a project directory structure. This
                      flag is useful if you know you have matches you want to keep,
                      e.g., if your code contains a package with a name like 'build'.
                      This option severely limits the effectiveness of the deep clean.
-n --nuke             ⚠️  THIS IS DANGEROUS SHIT ⚠️  Super-deep clean
                      This includes clearing out global folders, including:
                       * the global Gradle cache
                       * the global Maven artefacts
                       * the wrapper-downloaded Gradle distros
                       * the Gradle daemon data (logs, locks, etc.)
                       * the Android build cache
                      Nukes the entire thing from orbit — it's the only way to be sure.
-v --verbose          Print detailed information about all commands.

For this script to work, you need to have kotlin, kscript and maven on your PATH. If you DON'T have all three commands on your PATH, then read on to the next section to install them.

Installing the script dependencies

To make the script run, we'll first need to install all the required dependencies. All dependencies are available on SDKMan! (Windows, Linux, macOS). Note that KScript support for Windows is not officially available yet.

$ sdk install kotlin
$ sdk install maven
$ sdk install kscript

Licence

Copyright 2022 Sebastiano Poggi

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

For more information please refer to the LICENSE file.

More Repositories

1

uplift

A playground for elevation on Android
Kotlin
350
star
2

giffify

Giffify - easily create optimised GIFs from a video
Python
65
star
3

launcher-icon

A simple demo project that showcases how to set up Android launcher icons
Java
37
star
4

advanced-kotlin-workshop

Code for my "Practical Advanced Kotlin in Practice" workshop
Kotlin
33
star
5

smartlock-demo

A simple but complete demo of how to use SmartLock for Passwords -- see https://developers.google.com/identity/smartlock-passwords/android/
Java
32
star
6

ide-showcase

A playground to showcase cool IDE features.
Kotlin
14
star
7

pushbeat

Sample GCP AppEngine Ktor REST API and corresponding Android app
Kotlin
10
star
8

sandbox-demo

Compose for Desktop falling sand simulator
Kotlin
10
star
9

ktor-gradle-kts-template

A template repository for Kotlin projects with Gradle KTS support and advanced dependencies configuration.
Kotlin
6
star
10

custom-theme-playground

If an owl falls in a forest but there's nobody around, do you still lose your streak?
Kotlin
4
star
11

share-callback-demo

Demo of how to use standard system dialogs to share content and get a callback (e.g., for tracking)
Kotlin
3
star
12

if-this-then-that

Given IFTTT is now useless, this replaces it.
2
star
13

framer

Grabs a screenshot from a connected Android device and frames it, faster than Android Studio
Java
2
star
14

volley

A clone of Google's own Volley library
Java
1
star
15

compose-desktop-fonts-enumerator

An experiment on how to enumerate System fonts on Compose for Desktop
Kotlin
1
star
16

code-merge

A tool to simplify merging code changes from a separate codebase
Kotlin
1
star