Last active
July 1, 2022 00:53
-
-
Save ahatzz11/1119bb69b27da703e0e3236bb9d9b51f to your computer and use it in GitHub Desktop.
Gradle task to lock all subprojects
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
// 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