Skip to content

Instantly share code, notes, and snippets.

@ahatzz11
Last active July 1, 2022 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahatzz11/1119bb69b27da703e0e3236bb9d9b51f to your computer and use it in GitHub Desktop.
Save ahatzz11/1119bb69b27da703e0e3236bb9d9b51f to your computer and use it in GitHub Desktop.
Gradle task to lock all subprojects
// This task performs a dependency lock on the main project as well as every subproject.
// This should stay create so that all the projects get the dependencyLocking config applied right away
// This isn't normal lazy gradle, but it is self-contained and that is nice
tasks.create<Exec>("lockItUp") {
allprojects {
// allprojects needs this
dependencyLocking {
lockAllConfigurations()
}
}
doLast {
// first, root!
exec {
executable = "./gradlew"
args = listOf("dependencies", "--write-locks", "-q")
}
// then, subprojects
subprojects.forEach {
println("Locking ${it.name}")
println(":${it.name}:dependencies --write-locks")
exec {
executable = "./gradlew"
args = listOf(":${it.name}:dependencies", "--write-locks", "-q")
}
}
commandLine("echo", "\uD83D\uDD12 IT IS LOCKED")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment