Ratchet net.minecraft purity

- Add minecraftPurityRatchet over core/minecraft-purity-allowlist.txt, wired into check
- Register both purity ratchets from one closure instead of duplicating the scan
- Prune WorldCreationProgressReporter from core/purity-allowlist.txt
This commit is contained in:
Brian Neumann-Fopiano committed 2026-09-08 03:39:43 -04:00
1 parent 1913baed17
commit b225c0b5be
3 files changed
+42 -31

No files matched your search

+36 -30
View File
@@ -485,43 +485,49 @@ tasks.named('check').configure {
dependsOn('externalProviderTest') dependsOn('externalProviderTest')
} }
tasks.register('bukkitPurityRatchet') { Closure<Void> registerPurityRatchet = { String taskName, String label, String forbiddenPackage, String allowlistName ->
group = 'verification' tasks.register(taskName) {
description = 'Fails if files outside core/purity-allowlist.txt import org.bukkit (the allowlist only shrinks).' group = 'verification'
File allowlistFile = project.file('purity-allowlist.txt') description = "Fails if files outside core/${allowlistName} import ${forbiddenPackage} (the allowlist only shrinks)."
File sourceRoot = project.file('src/main/java') File allowlistFile = project.file(allowlistName)
inputs.file(allowlistFile) File sourceRoot = project.file('src/main/java')
inputs.dir(sourceRoot) inputs.file(allowlistFile)
doLast { inputs.dir(sourceRoot)
Set<String> allowed = allowlistFile.readLines().findAll { String line -> !line.isBlank() }.toSet() doLast {
List<String> offenders = new ArrayList<>() Set<String> allowed = allowlistFile.readLines().findAll { String line -> !line.isBlank() }.toSet()
List<String> coupled = new ArrayList<>() List<String> offenders = new ArrayList<>()
sourceRoot.eachFileRecurse { File f -> List<String> coupled = new ArrayList<>()
if (!f.name.endsWith('.java')) { sourceRoot.eachFileRecurse { File f ->
return if (!f.name.endsWith('.java')) {
} return
if (f.text.contains('org.bukkit')) { }
String rel = sourceRoot.toPath().relativize(f.toPath()).toString() if (f.text.contains(forbiddenPackage)) {
coupled.add(rel) String rel = sourceRoot.toPath().relativize(f.toPath()).toString()
if (!allowed.contains(rel)) { coupled.add(rel)
offenders.add(rel) if (!allowed.contains(rel)) {
offenders.add(rel)
}
} }
} }
} if (!offenders.isEmpty()) {
if (!offenders.isEmpty()) { throw new GradleException(label + " purity ratchet violated - new " + forbiddenPackage + " coupling in:\n " + offenders.join('\n ') + "\nDecouple these files or (only with strong justification) add them to core/" + allowlistName)
throw new GradleException("Bukkit purity ratchet violated - new org.bukkit coupling in:\n " + offenders.join('\n ') + "\nDecouple these files or (only with strong justification) add them to core/purity-allowlist.txt") }
} int shrunk = allowed.size() - coupled.size()
int shrunk = allowed.size() - coupled.size() if (shrunk > 0) {
if (shrunk > 0) { println(label + " purity ratchet: " + coupled.size() + " coupled files (" + shrunk + " fewer than allowlist - consider tightening core/" + allowlistName + ")")
println("Purity ratchet: " + coupled.size() + " coupled files (" + shrunk + " fewer than allowlist - consider tightening core/purity-allowlist.txt)") } else {
} else { println(label + " purity ratchet: " + coupled.size() + " coupled files (at allowlist ceiling)")
println("Purity ratchet: " + coupled.size() + " coupled files (at allowlist ceiling)") }
} }
} }
return null
} }
registerPurityRatchet('bukkitPurityRatchet', 'Bukkit', 'org.bukkit', 'purity-allowlist.txt')
registerPurityRatchet('minecraftPurityRatchet', 'Minecraft', 'net.minecraft', 'minecraft-purity-allowlist.txt')
tasks.named('check').configure { tasks.named('check').configure {
dependsOn('bukkitPurityRatchet') dependsOn('bukkitPurityRatchet', 'minecraftPurityRatchet')
} }
apply from: rootProject.file('gradle/generation-build-revision.gradle') apply from: rootProject.file('gradle/generation-build-revision.gradle')
+6
View File
@@ -0,0 +1,6 @@
art/arcane/iris/core/lifecycle/CapabilitySnapshot.java
art/arcane/iris/core/lifecycle/WorldLifecycleSupport.java
art/arcane/iris/core/runtime/WorldRuntimeControlService.java
art/arcane/iris/core/service/LogFilterSVC.java
art/arcane/iris/core/structure/BulkStructureImporter.java
art/arcane/iris/core/structure/VillageImporter.java
-1
View File
@@ -84,7 +84,6 @@ art/arcane/iris/core/tools/IrisPackBenchmarking.java
art/arcane/iris/core/tools/IrisReflectiveAPI.java art/arcane/iris/core/tools/IrisReflectiveAPI.java
art/arcane/iris/core/tools/IrisToolbelt.java art/arcane/iris/core/tools/IrisToolbelt.java
art/arcane/iris/core/tools/IrisWorldCreator.java art/arcane/iris/core/tools/IrisWorldCreator.java
art/arcane/iris/core/tools/WorldCreationProgressReporter.java
art/arcane/iris/engine/IrisEngineEffects.java art/arcane/iris/engine/IrisEngineEffects.java
art/arcane/iris/engine/IrisWorldManager.java art/arcane/iris/engine/IrisWorldManager.java
art/arcane/iris/engine/MarkerSpawnScanner.java art/arcane/iris/engine/MarkerSpawnScanner.java