From a2dac3a0b0c94d3d354d3687f471e463ce8e5fff Mon Sep 17 00:00:00 2001 From: david morales <118213696+davidmoralesz@users.noreply.github.com> Date: Fri, 9 Oct 2026 17:29:52 -0600 Subject: [PATCH 1/2] chore(devtools): sync with project-template v0.4.0 --- .devtools/scripts/template-sync.sh | 66 +++++++++++++++++++++--------- .template-version | 2 +- AGENTS.md | 2 +- 3 files changed, 49 insertions(+), 21 deletions(-) diff --git a/.devtools/scripts/template-sync.sh b/.devtools/scripts/template-sync.sh index 7fb428a..10f7bad 100755 --- a/.devtools/scripts/template-sync.sh +++ b/.devtools/scripts/template-sync.sh @@ -13,6 +13,11 @@ # blocks inside files the project otherwise owns. Paths listed in this repo's # .template-ignore are left alone. # +# A project can also opt in to profiles, one per line in its .template-profiles. A +# profile is a second manifest, .template/manifest., whose files and blocks are +# read from .template/profiles// instead of the template's root, so a language's +# files do not sit in every new project. +# # Exit codes: 0 in step (or synced), 1 drift found by --check, 2 anything else. # The template-drift workflow depends on that split, so a failure of this script is # never mistaken for "no drift". @@ -39,7 +44,7 @@ while [[ $# -gt 0 ]]; do --check) mode=check; shift ;; --from) from="${2:?--from needs a directory}"; shift 2 ;; --ref) ref="${2:?--ref needs a tag}"; shift 2 ;; - -h | --help) sed -n '2,20p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;; + -h | --help) sed -n '2,25p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;; *) die "unknown argument: $1" ;; esac done @@ -63,8 +68,7 @@ if [[ -z "${from}" ]]; then || die "cannot clone ${url} at ${ref}" fi -manifest="${from}/.template/manifest" -[[ -f "${manifest}" ]] || die "${from} has no .template/manifest; is it the template?" +[[ -f "${from}/.template/manifest" ]] || die "${from} has no .template/manifest; is it the template?" if [[ -z "${ref}" ]]; then ref="$(git -C "${from}" describe --tags --always 2>/dev/null || echo unknown)" fi @@ -107,8 +111,12 @@ report() { fi } +# Where the manifest being applied reads its files from: the template's root for the base +# manifest, a profile's directory for a profile. +src_root="${from}" + sync_file() { - local path="$1" src="${from}/$1" + local path="$1" src="${src_root}/$1" [[ -f "${src}" ]] || die "manifest lists ${path}, but the template does not have it" local same=true @@ -140,7 +148,7 @@ sync_file() { } sync_block() { - local path="$1" name="$2" src="${from}/$1" + local path="$1" name="$2" src="${src_root}/$1" [[ -f "${src}" ]] || die "manifest lists ${path}, but the template does not have it" block_of "${src}" "${name}" >"${work}/theirs" @@ -180,20 +188,40 @@ sync_block() { changed=$((changed + 1)) } -while read -r kind path name _; do - case "${kind}" in - '' | '#'*) continue ;; - esac - if ignored "${path}"; then - echo "– ${path}: ignored by .template-ignore" - continue - fi - case "${kind}" in - file) sync_file "${path}" ;; - block) sync_block "${path}" "${name:?manifest: block ${path} needs a name}" ;; - *) die "manifest: unknown entry '${kind} ${path}'" ;; - esac -done <"${manifest}" +# apply_manifest : sync, or check, every entry in it. +apply_manifest() { + local kind path name _ + while read -r kind path name _; do + case "${kind}" in + '' | '#'*) continue ;; + esac + if ignored "${path}"; then + echo "– ${path}: ignored by .template-ignore" + continue + fi + case "${kind}" in + file) sync_file "${path}" ;; + block) sync_block "${path}" "${name:?manifest: block ${path} needs a name}" ;; + *) die "manifest: unknown entry '${kind} ${path}'" ;; + esac + done <"$1" +} + +apply_manifest "${from}/.template/manifest" + +# Profiles come after the base manifest, in the order the project lists them. +if [[ -f .template-profiles ]]; then + while read -r profile _; do + case "${profile}" in + '' | '#'*) continue ;; + esac + [[ "${profile}" =~ ^[a-z0-9][a-z0-9-]*$ ]] || die ".template-profiles: '${profile}' is not a profile name" + [[ -f "${from}/.template/manifest.${profile}" ]] \ + || die ".template-profiles lists '${profile}', but the template has no .template/manifest.${profile}" + src_root="${from}/.template/profiles/${profile}" + apply_manifest "${from}/.template/manifest.${profile}" + done <.template-profiles +fi recorded="$(cat .template-version 2>/dev/null || true)" diff --git a/.template-version b/.template-version index 7becae1..fb7a04c 100644 --- a/.template-version +++ b/.template-version @@ -1 +1 @@ -v0.3.2 +v0.4.0 diff --git a/AGENTS.md b/AGENTS.md index 4ced103..8e3292e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -54,7 +54,7 @@ weekly workflow reports as an issue. | CI behaviour (lint, PR checks, release) | `studiobimo/.github`, `.github/workflows/` | the `@v1` tag moving | | Branch and PR-size rules | `studiobimo/.github`, `.devtools/` | the `@v1` tag moving; lefthook refetches it daily | | Shared hooks and tool versions | `studiobimo/project-template` | `make -C .devtools sync` | -| Files and blocks listed in the template's `.template/manifest` | `studiobimo/project-template` | `make -C .devtools sync` | +| Files and blocks listed in the template's `.template/manifest`, and in the manifest of each profile in `.template-profiles` | `studiobimo/project-template` | `make -C .devtools sync` | A managed block sits between `>>> template:` and `<<< template:` marker lines, like this section. Edit outside the markers freely; inside them, change the template instead. If a From 065eba2dd91f5e39eba4e0068e6d2e7f198bb215 Mon Sep 17 00:00:00 2001 From: david morales <118213696+davidmoralesz@users.noreply.github.com> Date: Fri, 9 Oct 2026 18:13:23 -0600 Subject: [PATCH 2/2] chore(devtools): adopt the java-gradle template profile The Gradle convention plugins, Makefile targets, CI wrapper, hooks, Dependabot entry and .gitattributes rule now come from project-template. Gains the publishing tasks, so the mod-publish plugin is added to the catalog and the lockfiles and checksums refreshed. --- .devtools/Makefile | 43 +--- .devtools/gradle.mk | 44 ++++ .gitattributes | 9 +- .github/dependabot.yml | 3 + .github/workflows/ci.yml | 5 + .template-profiles | 1 + .template-version | 2 +- build-logic/build.gradle | 2 + build-logic/gradle.lockfile | 10 +- .../src/main/groovy/multiloader-common.gradle | 19 +- .../src/main/groovy/multiloader-loader.gradle | 58 +++++ gradle.properties | 11 + gradle/libs.versions.toml | 2 + gradle/verification-metadata.xml | 52 ++++ gradlew.bat | 224 +++++++++--------- lefthook.yml | 22 +- 16 files changed, 337 insertions(+), 170 deletions(-) create mode 100644 .devtools/gradle.mk create mode 100644 .template-profiles diff --git a/.devtools/Makefile b/.devtools/Makefile index 75b6c13..6961b70 100644 --- a/.devtools/Makefile +++ b/.devtools/Makefile @@ -1,43 +1,2 @@ include base.mk - -GRADLE := cd $(ROOT) && JAVA_HOME="$$(/usr/libexec/java_home -v $$(cat .java-version) 2>/dev/null || echo $$JAVA_HOME)" ./gradlew - -.PHONY: fmt test build check client-test lock stray kill-stray run-fabric run-neoforge run-fabric-server run-neoforge-server clean - -fmt: ## Format Java sources - $(GRADLE) spotlessApply - -test: ## Unit tests with coverage gate - $(GRADLE) :common:check - -build: ## Compile, lint (Error Prone), test and package both loaders - $(GRADLE) build - -check: lint build ## Everything CI runs - -client-test: ## Screenshot the GUI in a real client (opens a window, so it is not part of check) - $(GRADLE) :fabric:runClientGameTest - -lock: lock-tools ## Refresh every lockfile and the sha256 dependency verification after a version change - $(GRADLE) --write-verification-metadata sha256 --refresh-dependencies resolveAndLockAll buildEnvironment build --write-locks - -stray: ## List JVMs a dev run or GameTest left behind - @$(CURDIR)/scripts/stray-java.sh || true - -kill-stray: ## Stop JVMs a dev run or GameTest left behind - @$(CURDIR)/scripts/stray-java.sh --kill - -run-fabric: ## Launch the Fabric dev client - $(GRADLE) :fabric:runClient - -run-neoforge: ## Launch the NeoForge dev client - $(GRADLE) :neoforge:runClient - -run-fabric-server: ## Launch the Fabric dev server (headless) - $(GRADLE) :fabric:runServer - -run-neoforge-server: ## Launch the NeoForge dev server (headless) - $(GRADLE) :neoforge:runServer - -clean: ## Remove build outputs - $(GRADLE) clean +include gradle.mk diff --git a/.devtools/gradle.mk b/.devtools/gradle.mk new file mode 100644 index 0000000..7f2a74a --- /dev/null +++ b/.devtools/gradle.mk @@ -0,0 +1,44 @@ +# Managed by studiobimo/project-template (profile java-gradle); change it there. Include it +# from Makefile, after base.mk, and add the project's own targets (and their .PHONY) there. + +GRADLE := cd $(ROOT) && JAVA_HOME="$$(/usr/libexec/java_home -v $$(cat .java-version) 2>/dev/null || echo $$JAVA_HOME)" ./gradlew + +.PHONY: fmt test build check client-test lock stray kill-stray run-fabric run-neoforge run-fabric-server run-neoforge-server clean + +fmt: ## Format Java sources + $(GRADLE) spotlessApply + +test: ## Unit tests + $(GRADLE) :common:check + +build: ## Compile, lint (Error Prone), test and package both loaders + $(GRADLE) build + +check: lint build ## Everything CI runs + +client-test: ## Run the client GameTest in a real client (opens a window, so it is not part of check) + $(GRADLE) :fabric:runClientGameTest + +lock: lock-tools ## Refresh every lockfile and the sha256 dependency verification after a version change + $(GRADLE) --write-verification-metadata sha256 --refresh-dependencies resolveAndLockAll buildEnvironment build --write-locks + +stray: ## List JVMs a dev run or GameTest left behind + @$(CURDIR)/scripts/stray-java.sh || true + +kill-stray: ## Stop JVMs a dev run or GameTest left behind + @$(CURDIR)/scripts/stray-java.sh --kill + +run-fabric: ## Launch the Fabric dev client + $(GRADLE) :fabric:runClient + +run-neoforge: ## Launch the NeoForge dev client + $(GRADLE) :neoforge:runClient + +run-fabric-server: ## Launch the Fabric dev server (headless) + $(GRADLE) :fabric:runServer + +run-neoforge-server: ## Launch the NeoForge dev server (headless) + $(GRADLE) :neoforge:runServer + +clean: ## Remove build outputs + $(GRADLE) clean diff --git a/.gitattributes b/.gitattributes index 2b98c48..e97e989 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,10 +6,15 @@ *.zip binary # <<< template:base -*.bat text eol=crlf *.cmd text eol=crlf -gradlew text eol=lf +# >>> template:gradle +# The wrapper scripts are stored exactly as Gradle ships them: gradlew.bat with CRLF, gradlew with +# LF. If git converted them, the blob Dependabot commits on a wrapper bump would never match the +# repository's, and every check that compares the tree would report gradlew.bat as changed. +*.bat -text +gradlew text eol=lf +# <<< template:gradle *.jar binary *.ogg binary diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 93b83a8..b3633cf 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,5 +1,7 @@ version: 2 updates: + # >>> template:gradle + # Minecraft, Fabric and NeoForge versions are ported deliberately, so Dependabot ignores them. - package-ecosystem: gradle directory: / schedule: @@ -27,6 +29,7 @@ updates: update-types: [version-update:semver-major] - dependency-name: net.neoforged.moddev update-types: [version-update:semver-major] + # <<< template:gradle # >>> template:base - package-ecosystem: github-actions diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6302f2f..4f4a7e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,8 @@ name: CI +# Thin wrapper around the org's Java/Gradle toolchain workflow. `check` is the +# same target `make -C .devtools check` runs, so local and CI results match. + on: push: branches: [main] @@ -10,6 +13,8 @@ permissions: {} jobs: check: + # A called workflow can never hold more than its caller, so the caller has to + # grant what it needs. `permissions: {}` above keeps every other job at nothing. permissions: contents: read uses: studiobimo/.github/.github/workflows/ci-java-gradle.yml@v1 diff --git a/.template-profiles b/.template-profiles new file mode 100644 index 0000000..c2d3687 --- /dev/null +++ b/.template-profiles @@ -0,0 +1 @@ +java-gradle diff --git a/.template-version b/.template-version index fb7a04c..5aff472 100644 --- a/.template-version +++ b/.template-version @@ -1 +1 @@ -v0.4.0 +v0.4.1 diff --git a/build-logic/build.gradle b/build-logic/build.gradle index c555c2b..6d44250 100644 --- a/build-logic/build.gradle +++ b/build-logic/build.gradle @@ -3,8 +3,10 @@ plugins { } dependencies { + // Plugins applied by the convention scripts in src/main/groovy implementation(libs.spotless.gradle) implementation(libs.errorprone.gradle) + implementation(libs.mod.publish.gradle) } dependencyLocking { diff --git a/build-logic/gradle.lockfile b/build-logic/gradle.lockfile index b3bf66d..569b76f 100644 --- a/build-logic/gradle.lockfile +++ b/build-logic/gradle.lockfile @@ -16,13 +16,19 @@ com.squareup.okio:okio-jvm:3.6.0=runtimeClasspath,testRuntimeClasspath com.squareup.okio:okio:3.6.0=runtimeClasspath,testRuntimeClasspath commons-codec:commons-codec:1.22.1=runtimeClasspath,testRuntimeClasspath dev.equo.ide:solstice:1.8.2=runtimeClasspath,testRuntimeClasspath +me.modmuss50:mod-publish-plugin:2.2.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath net.ltgt.gradle:gradle-errorprone-plugin:5.1.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.eclipse.jgit:org.eclipse.jgit:7.8.0.202609011348-r=runtimeClasspath,testRuntimeClasspath org.eclipse.platform:org.eclipse.osgi:3.24.300=runtimeClasspath,testRuntimeClasspath -org.jetbrains.kotlin:kotlin-stdlib-common:1.9.10=runtimeClasspath,testRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib-common:2.3.20=runtimeClasspath,testRuntimeClasspath org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.10=runtimeClasspath,testRuntimeClasspath org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10=runtimeClasspath,testRuntimeClasspath -org.jetbrains.kotlin:kotlin-stdlib:1.9.10=runtimeClasspath,testRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib:2.3.20=runtimeClasspath,testRuntimeClasspath +org.jetbrains.kotlinx:kotlinx-serialization-bom:1.11.0=runtimeClasspath,testRuntimeClasspath +org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.11.0=runtimeClasspath,testRuntimeClasspath +org.jetbrains.kotlinx:kotlinx-serialization-core:1.11.0=runtimeClasspath,testRuntimeClasspath +org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.11.0=runtimeClasspath,testRuntimeClasspath +org.jetbrains.kotlinx:kotlinx-serialization-json:1.11.0=runtimeClasspath,testRuntimeClasspath org.jetbrains:annotations:13.0=runtimeClasspath,testRuntimeClasspath org.slf4j:slf4j-api:2.0.18=runtimeClasspath,testRuntimeClasspath org.tukaani:xz:1.9=runtimeClasspath,testRuntimeClasspath diff --git a/build-logic/src/main/groovy/multiloader-common.gradle b/build-logic/src/main/groovy/multiloader-common.gradle index c2a99a9..63d5178 100644 --- a/build-logic/src/main/groovy/multiloader-common.gradle +++ b/build-logic/src/main/groovy/multiloader-common.gradle @@ -1,3 +1,4 @@ +// Conventions shared by every subproject (common, fabric, neoforge). plugins { id 'java-library' id 'com.diffplug.spotless' @@ -7,6 +8,17 @@ plugins { // Precompiled script plugins cannot use the type-safe accessor, so look the catalog up by name. def libs = versionCatalogs.named('libs') +// Two values differ from one project to the next and live in gradle.properties: +// nullaway_package the package NullAway enforces nullness in +// external_source_path sources copied in from another repository, as a path under a source +// root (dev/bimo/model); Error Prone and Spotless leave them alone. +// Empty or unset when there are none. +def nullawayPackage = findProperty('nullaway_package') +if (!nullawayPackage) { + throw new GradleException('Set nullaway_package in gradle.properties (the package NullAway checks).') +} +def externalSourcePath = (findProperty('external_source_path') ?: '').toString() + // .java-version is read by Gradle, actions/setup-java (java-version-file), jenv, mise and asdf. def javaVersion = rootProject.layout.projectDirectory.file('.java-version').asFile.text.trim() as int @@ -57,9 +69,9 @@ tasks.withType(JavaCompile).configureEach { options.compilerArgs.addAll(['-Xlint:all,-processing,-serial,-classfile', '-Werror']) options.errorprone { disableWarningsInGeneratedCode = true - excludedPaths = '.*/build/generated/.*' + excludedPaths = externalSourcePath ? ".*/(build/generated|${externalSourcePath})/.*".toString() : '.*/build/generated/.*' // Minecraft is not null-annotated; enforce nullness only in our packages. - option('NullAway:AnnotatedPackages', 'dev.bimo.tallyhopper') + option('NullAway:AnnotatedPackages', nullawayPackage.toString()) option('NullAway:JSpecifyMode', 'true') error('NullAway') } @@ -74,6 +86,9 @@ tasks.named('compileTestJava', JavaCompile) { spotless { java { target 'src/*/java/**/*.java' + if (externalSourcePath) { + targetExclude("src/main/java/${externalSourcePath}/**".toString()) + } palantirJavaFormat(libs.findVersion('palantir-java-format').get().requiredVersion) removeUnusedImports() formatAnnotations() diff --git a/build-logic/src/main/groovy/multiloader-loader.gradle b/build-logic/src/main/groovy/multiloader-loader.gradle index ac8a6a4..f448a56 100644 --- a/build-logic/src/main/groovy/multiloader-loader.gradle +++ b/build-logic/src/main/groovy/multiloader-loader.gradle @@ -1,5 +1,8 @@ +// Conventions for loader subprojects: compile and package the common sources +// into each loader's jar, and publish that jar when a release is tagged. plugins { id 'multiloader-common' + id 'me.modmuss50.mod-publish-plugin' } configurations { @@ -38,3 +41,58 @@ tasks.named('sourcesJar', Jar) { dependsOn(configurations.commonResources) from(configurations.commonResources) } + +// Publishing. `./gradlew publishMods` is what the release workflow runs, with RELEASE_TAG set to +// the tag release-please just cut; without it nothing is uploaded and each platform only prints +// what it would have sent. +def releaseTag = providers.environmentVariable('RELEASE_TAG') +def modJar = tasks.named('jar', Jar).flatMap { it.archiveFile } + +publishMods { + file = modJar + // Both loaders publish under one project, so the version says which jar it is. + version = "${project.version}-${project.name}" + displayName = "${mod_name} ${project.version} for ${project.name == 'neoforge' ? 'NeoForge' : 'Fabric'}" + changelog = "See the [release notes](${sources}/releases/tag/v${project.version})." + type = project.version.toString().startsWith('0.') ? BETA : STABLE + modLoaders.add(project.name) + dryRun = !releaseTag.isPresent() + + if (modrinth_project_id) { + modrinth { + projectId = modrinth_project_id + accessToken = providers.environmentVariable('MODRINTH_TOKEN') + minecraftVersions.add(minecraft_version) + if (project.name == 'fabric') { + requires('fabric-api') + } + } + } + if (curseforge_project_id) { + curseforge { + projectId = curseforge_project_id + accessToken = providers.environmentVariable('CURSEFORGE_TOKEN') + minecraftVersions.add(minecraft_version) + clientRequired = true + serverRequired = true + if (project.name == 'fabric') { + requires('fabric-api') + } + } + } +} + +// release-please has already created the GitHub Release by the time this runs, and the publish +// plugin can only create one of its own, so the jar is attached with the GitHub CLI instead. +def attachToGithubRelease = tasks.register('attachToGithubRelease', Exec) { + group = 'publishing' + description = 'Attaches the jar to the GitHub Release named by RELEASE_TAG.' + inputs.file(modJar) + onlyIf('RELEASE_TAG is set') { releaseTag.isPresent() } + environment('GH_TOKEN', providers.environmentVariable('GITHUB_TOKEN').getOrElse('')) + commandLine('gh', 'release', 'upload', releaseTag.getOrElse(''), modJar.get().asFile.path, '--clobber') +} + +tasks.named('publishMods') { + dependsOn(attachToGithubRelease) +} diff --git a/gradle.properties b/gradle.properties index 8952e95..d54d2fd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,6 +18,17 @@ homepage=https://github.com/studiobimo/tallyhopper sources=https://github.com/studiobimo/tallyhopper issues=https://github.com/studiobimo/tallyhopper/issues +# Read by build-logic's convention plugins: the package NullAway checks, and sources copied in +# from another repository that Error Prone and Spotless skip (a path under a source root, such as +# dev/bimo/model). Empty when there are none. +nullaway_package=dev.bimo.tallyhopper +external_source_path= + +# Where a release is published. Empty means that platform is skipped; fill each in once its +# project page exists. The tokens are the MODRINTH_TOKEN and CURSEFORGE_TOKEN repository secrets. +modrinth_project_id= +curseforge_project_id= + # Minecraft platform versions. These are bumped deliberately per Minecraft # release, not by Dependabot. https://projects.neoforged.net/neoforged/neoform minecraft_version=26.3 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 08fae9d..00d5c43 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,6 +16,7 @@ jspecify = "1.0.0" junit = "6.1.3" assertj = "3.27.7" jacoco = "0.8.15" +mod-publish = "2.2.1" [libraries] mixin = { module = "net.fabricmc:sponge-mixin", version.ref = "mixin" } @@ -30,6 +31,7 @@ assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj" } spotless-gradle = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" } errorprone-gradle = { module = "net.ltgt.gradle:gradle-errorprone-plugin", version.ref = "errorprone-plugin" } +mod-publish-gradle = { module = "me.modmuss50:mod-publish-plugin", version.ref = "mod-publish" } [plugins] fabric-loom = { id = "net.fabricmc.fabric-loom", version.ref = "fabric-loom" } diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 680989a..18baf32 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -1072,6 +1072,14 @@ + + + + + + + + @@ -2488,6 +2496,14 @@ + + + + + + + + @@ -2496,6 +2512,11 @@ + + + + + @@ -2522,6 +2543,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gradlew.bat b/gradlew.bat index 3185a43..03754c4 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,112 +1,112 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem gradlew startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables, and ensure extensions are enabled -setlocal EnableExtensions - -@rem Catch executions from older scripts and ensure they exit cleanly. -@rem This can be removed once we can be reasonably confident that few people -@rem will be migrating directly to this new wrapper. -goto afterSafetyNet -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -goto exitWithErrorLevel -:afterSafetyNet - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -1>&2 echo. -1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -1>&2 echo. -1>&2 echo Please set the JAVA_HOME variable in your environment to match the -1>&2 echo location of your Java installation. - -"%COMSPEC%" /c exit 1 -goto exitWithErrorLevel - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -1>&2 echo. -1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -1>&2 echo. -1>&2 echo Please set the JAVA_HOME variable in your environment to match the -1>&2 echo location of your Java installation. - -"%COMSPEC%" /c exit 1 -goto exitWithErrorLevel - -:execute -@rem Setup the command line - - - -@rem Execute gradlew -@rem endlocal doesn't take effect until after the line is parsed and variables are expanded -@rem which allows us to clear the local environment before executing the java command -endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel & goto exitWithErrorLevel - -@rem This label must not be changed. We rely on old scripts being able to jump to this point. -:exitWithErrorLevel -@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts -"%COMSPEC%" /c exit %ERRORLEVEL% +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem gradlew startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions + +@rem Catch executions from older scripts and ensure they exit cleanly. +@rem This can be removed once we can be reasonably confident that few people +@rem will be migrating directly to this new wrapper. +goto afterSafetyNet +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +goto exitWithErrorLevel +:afterSafetyNet + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +1>&2 echo. +1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +1>&2 echo. +1>&2 echo Please set the JAVA_HOME variable in your environment to match the +1>&2 echo location of your Java installation. + +"%COMSPEC%" /c exit 1 +goto exitWithErrorLevel + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +1>&2 echo. +1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +1>&2 echo. +1>&2 echo Please set the JAVA_HOME variable in your environment to match the +1>&2 echo location of your Java installation. + +"%COMSPEC%" /c exit 1 +goto exitWithErrorLevel + +:execute +@rem Setup the command line + + + +@rem Execute gradlew +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel & goto exitWithErrorLevel + +@rem This label must not be changed. We rely on old scripts being able to jump to this point. +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/lefthook.yml b/lefthook.yml index c558726..e73a714 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -22,6 +22,17 @@ remotes: - lefthook/org.yml # <<< template:base +# >>> template:java +# Added to the hooks in the base block. A project's own pre-commit jobs go below the closing +# marker, indented under `jobs:`; a job there with the same name as one here changes it. +pre-push: + jobs: + # Compile, Error Prone and the tests, whatever the push contains. + - name: gradle-check + run: >- + JAVA_HOME="$(/usr/libexec/java_home -v "$(cat .java-version)" 2>/dev/null || echo "$JAVA_HOME")" + ./gradlew build -q + pre-commit: # Files Gradle writes: its lockfiles, the dependency checksums, the wrapper scripts # (gradlew.bat has to keep its CRLF line endings) and the data generators' output. @@ -29,7 +40,7 @@ pre-commit: - 'gradle/verification-metadata.xml' - '*gradle.lockfile' - 'gradlew' - - 'gradlew.bat' + - '*.bat' - 'common/src/generated/**' jobs: @@ -52,11 +63,4 @@ pre-commit: run: >- JAVA_HOME="$(/usr/libexec/java_home -v "$(cat .java-version)" 2>/dev/null || echo "$JAVA_HOME")" ./gradlew spotlessApply -q - -pre-push: - jobs: - # Compile, Error Prone and the tests, whatever the push contains. - - name: gradle-check - run: >- - JAVA_HOME="$(/usr/libexec/java_home -v "$(cat .java-version)" 2>/dev/null || echo "$JAVA_HOME")" - ./gradlew build -q +# <<< template:java