From 2dbf7704cc73a31bcca3c2da354fdc2b620e9488 Mon Sep 17 00:00:00 2001 From: ewired Date: Fri, 30 Oct 2026 07:30:54 -0400 Subject: [PATCH] Add Gradle dependency lockfile --- .gitattributes | 6 +++++- .github/workflows/verify.yml | 26 ++++++++++++++++++++++++ build.gradle | 38 +++++++++++++++++++++++++++++++++++- gradle.lockfile | 22 +++++++++++++++++++++ settings.gradle | 13 ++++++++++++ 5 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 gradle.lockfile create mode 100644 settings.gradle diff --git a/.gitattributes b/.gitattributes index 1489a259..571b1718 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,6 @@ * text=auto eol=lf -*.java eol=lf \ No newline at end of file +*.java eol=lf + +# Gradle dependency lockfiles are generated with LF and are hash-sensitive: +# a CRLF checkout would change every line and invalidate the lock. +gradle.lockfile text eol=lf diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 56c88508..1e99db83 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -47,3 +47,29 @@ jobs: run: xvfb-run -s '-screen 0 1024x768x24' ./gradlew test + + # Catch dependency changes that would make the lockfile inconsistent. + # Regenerate after a dependency change and commit the result: + # ./gradlew --write-locks lockClasspaths + lockfile-drift: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 25 + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: '25' + + - name: Regenerate lockfile + run: ./gradlew --no-daemon --write-locks lockClasspaths + + - name: Fail if lockfile changed + run: | + if ! git diff --exit-code -- gradle.lockfile; then + echo "::error::gradle.lockfile is out of date. Regenerate it and commit the result:" + echo " ./gradlew --write-locks lockClasspaths" + exit 1 + fi diff --git a/build.gradle b/build.gradle index f32f8654..55e05967 100644 --- a/build.gradle +++ b/build.gradle @@ -154,4 +154,40 @@ publishing { signing { sign publishing.publications.mavenJava -} \ No newline at end of file +} + +// Regenerate after any dependency change: +// ./gradlew --write-locks lockClasspaths +dependencyLocking { + lockAllConfigurations() +} + +def lockedConfigurations = [ + 'annotationProcessor', + 'compileClasspath', + 'runtimeClasspath', + 'testCompileClasspath', + 'testRuntimeClasspath', +] + +// Registered only if absent: parent builds register a task of this name on +// every project they contain, and a second registration fails the build. +if (tasks.findByName('lockClasspaths') == null) { + tasks.register('lockClasspaths') { + group = 'build' + description = 'Resolve the locked configurations so --write-locks records them' + doLast { + lockedConfigurations.each { n -> + def c = configurations.findByName(n) + if (c != null && c.canBeResolved) { + try { + c.resolve() + } catch (Throwable ignored) { + // A configuration that cannot resolve is still recorded by + // --write-locks; failure here must not abort the task. + } + } + } + } + } +} diff --git a/gradle.lockfile b/gradle.lockfile new file mode 100644 index 00000000..b9b1c014 --- /dev/null +++ b/gradle.lockfile @@ -0,0 +1,22 @@ +# This is a Gradle generated file for dependency locking. +# Manual edits can break the build and are not advised. +# This file is expected to be part of source control. +com.google.code.gson:gson:2.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.miglayout:miglayout-core:4.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.miglayout:miglayout-swing:4.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.neuronrobotics:nrjavaserial:5.1.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +commons-net:commons-net:3.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +gov.nist.math:jama:1.0.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.ultreia:bluecove:2.1.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +javax.usb:usb-api:1.0.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +junit:junit:4.12=testCompileClasspath,testRuntimeClasspath +net.sf.bluecove:bluecove-gpl:2.1.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-lang3:3.2.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-math3:3.6.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.hamcrest:hamcrest-core:1.3=testCompileClasspath,testRuntimeClasspath +org.igniterealtime.smack:smack:3.2.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.igniterealtime.smack:smackx:3.2.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.usb4java:libusb4java:1.2.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.usb4java:usb4java-javax:1.2.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.usb4java:usb4java:1.2.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +empty=annotationProcessor diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..22619d92 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,13 @@ +// build.gradle applies com.diffplug.spotless by id without a version; the +// parent build supplies it, but standalone it must come from pluginManagement. +pluginManagement { + plugins { + id 'com.diffplug.spotless' version '6.25.0' + } + repositories { + gradlePluginPortal() + mavenCentral() + } +} + +rootProject.name = 'java-bowler'