Created
October 14, 2018 14:47
-
-
Save featzima/9cebe6d785a69bc7b24e1735de8309c2 to your computer and use it in GitHub Desktop.
The cleaner for all gradle projects on a disc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File | |
interface IProjectDetector { | |
fun isProjectRootFolder(folder: File): Boolean | |
} | |
interface IProjectCleaner { | |
fun clean(folder: File) | |
} | |
interface IProjectManager : IProjectDetector, IProjectCleaner | |
class GradleProjectManager : IProjectManager { | |
override fun isProjectRootFolder(folder: File): Boolean { | |
return File(folder, "build.gradle").exists() | |
&& File(folder, "gradlew").exists() | |
&& File(folder, "gradlew.bat").exists() | |
} | |
override fun clean(folder: File) { | |
println("cleaning $folder") | |
File(folder, ".gradle").deleteRecursively() | |
File(folder, "build").deleteRecursively() | |
folder | |
.listFiles() | |
.filter { it.isDirectory } | |
.forEach { File(it, "build").deleteRecursively() } | |
} | |
} | |
fun main(args: Array<String>) { | |
val projectManagers: List<IProjectManager> = listOf(GradleProjectManager()) | |
File("C:\\") | |
.walkTopDown() | |
.filter { it.isDirectory } | |
.forEach { folder -> | |
projectManagers | |
.filter { it.isProjectRootFolder(folder) } | |
.forEach { it.clean(folder) } | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment