tasks { register("copyGitHooks") { description = "Copies the git hooks from scripts/git-hooks to the .git folder." group = "plugins.git-hook" from("$rootDir/scripts/git-hooks/") { include("**/*.sh") rename("(.*).sh", "$1") } into("$rootDir/.git/hooks") } register("installGitHooks") { description = "Installs the scripts git hooks from scripts/git-hooks." group = "plugins.git-hook" workingDir(rootDir) commandLine("chmod") args("-R", "+x", ".git/hooks/") dependsOn(named("copyGitHooks")) doLast { print("Git hooks installed successfully.") } } register("deleteGitHooks") { description = "Delete the scripts git hooks." group = "plugins.git-hook" delete(fileTree(".git/hooks/")) } afterEvaluate { tasks["clean"].dependsOn(tasks.named("installGitHooks")) } }