Skip to content

Commit 35855c2

Browse files
traskgithub-actions[bot]
and
github-actions[bot]
authored
Update gradle locking (#2758)
to align with naming in docs: https://docs.gradle.org/current/userguide/dependency_locking.html#lock_all_configurations_in_one_build_execution also, fixed an issue I was having when regenerating the lock files by moving it to java-conventions Co-authored-by: github-actions[bot] <github-action[bot]@users.noreply.github.com>
1 parent aa0e6d6 commit 35855c2

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

.github/workflows/comment-driven-automation.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
available_commands="Available commands:
6464
* \`/spotless\` - runs \`./gradlew spotlessApply\`
6565
* \`/license\` - runs \`./gradlew generateLicenseReport\`
66-
* \`/lockfile\` - runs \`./gradlew generateLockfiles --write-locks\`
66+
* \`/lockfile\` - runs \`./gradlew resolveAndLockAll --write-locks\`
6767
* \`/help\` - displays available commands
6868
"
6969
# TODO add thumbs up on triggering comment
@@ -87,13 +87,13 @@ jobs:
8787
git commit -m "./gradlew generateLicenseReport"
8888
git push
8989
elif [[ "$COMMAND" == "lockfile" ]]; then
90-
./gradlew generateLockfiles --write-locks
90+
./gradlew resolveAndLockAll --write-locks
9191
git add "*.lockfile"
9292
if git diff --cached --quiet; then
9393
gh pr comment $NUMBER --body "Already up-to-date"
9494
exit 0 # success
9595
fi
96-
git commit -m "./gradlew generateLockfiles --write-locks"
96+
git commit -m "./gradlew resolveAndLockAll --write-locks"
9797
git push
9898
elif [[ "$COMMAND" == "help" ]]; then
9999
gh pr comment $NUMBER --body "$available_commands"

build.gradle.kts

-23
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,3 @@ subprojects {
1616
}
1717

1818
extra["isRelease"] = (System.getProperty("isRelease") ?: "false").toBoolean()
19-
20-
allprojects {
21-
22-
if (!path.startsWith(":smoke-tests")) {
23-
configurations.configureEach {
24-
if (name.toLowerCase().endsWith("runtimeclasspath")) {
25-
resolutionStrategy.activateDependencyLocking()
26-
}
27-
}
28-
}
29-
30-
tasks.register("generateLockfiles") {
31-
doFirst {
32-
// you must run with --write-locks parameter
33-
require(gradle.startParameter.isWriteDependencyLocks)
34-
}
35-
doLast {
36-
if (configurations.findByName("runtimeClasspath") != null) {
37-
configurations.named("runtimeClasspath").get().resolve()
38-
}
39-
}
40-
}
41-
}

buildSrc/src/main/kotlin/ai.java-conventions.gradle.kts

+20
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,23 @@ dependencyCheck {
148148
skipConfigurations = listOf("errorprone", "spotbugs", "checkstyle", "annotationProcessor")
149149
failBuildOnCVSS = 0f // fail on any reported CVE
150150
}
151+
152+
if (!path.startsWith(":smoke-tests")) {
153+
configurations.configureEach {
154+
if (name.toLowerCase().endsWith("runtimeclasspath")) {
155+
resolutionStrategy.activateDependencyLocking()
156+
}
157+
}
158+
}
159+
160+
// see https://docs.gradle.org/current/userguide/dependency_locking.html#lock_all_configurations_in_one_build_execution
161+
tasks.register("resolveAndLockAll") {
162+
doFirst {
163+
require(gradle.startParameter.isWriteDependencyLocks)
164+
}
165+
doLast {
166+
if (configurations.findByName("runtimeClasspath") != null) {
167+
configurations.named("runtimeClasspath").get().resolve()
168+
}
169+
}
170+
}

0 commit comments

Comments
 (0)