From 32404f03fb314f6a9f03699bfc98ae9a41379c7b Mon Sep 17 00:00:00 2001 From: rubensworks Date: Sun, 13 Sep 2026 07:31:11 +0000 Subject: [PATCH] Add a build check guarding against @OnlyIn slipping in from 1.21 upmerges @OnlyIn was removed in NeoForge 26, but it is still valid on the 1.21 branch, so upmerges can silently reintroduce it. NeoForge then logs a startup warning via OnlyInWarningsHandler. Related to #238 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01MXLQ4EF4nPh69C3ig3hjHZ --- build.gradle | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/build.gradle b/build.gradle index 5e1a50588..ff3295310 100644 --- a/build.gradle +++ b/build.gradle @@ -398,3 +398,17 @@ tasks.register('updateGitHooks', Copy) { into './.git/hooks' } compileJava.dependsOn updateGitHooks + +// @OnlyIn does not exist anymore since NeoForge 26, guard against upmerges from 1.21 reintroducing it +tasks.register('checkNoOnlyIn') { + def javaSources = fileTree('src').matching { include '**/*.java' } + inputs.files(javaSources).withPropertyName('javaSources') + doLast { + def offenders = javaSources.files.findAll { it.text.contains('@OnlyIn') } + if (offenders) { + throw new GradleException('@OnlyIn does not exist anymore in this NeoForge version, remove it from:\n' + + offenders.sort().collect { " ${it}" }.join('\n')) + } + } +} +check.dependsOn checkNoOnlyIn