diff --git a/core/build.gradle b/core/build.gradle index 8f8f53c1b..299588439 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -485,43 +485,49 @@ tasks.named('check').configure { dependsOn('externalProviderTest') } -tasks.register('bukkitPurityRatchet') { - group = 'verification' - description = 'Fails if files outside core/purity-allowlist.txt import org.bukkit (the allowlist only shrinks).' - File allowlistFile = project.file('purity-allowlist.txt') - File sourceRoot = project.file('src/main/java') - inputs.file(allowlistFile) - inputs.dir(sourceRoot) - doLast { - Set allowed = allowlistFile.readLines().findAll { String line -> !line.isBlank() }.toSet() - List offenders = new ArrayList<>() - List coupled = new ArrayList<>() - sourceRoot.eachFileRecurse { File f -> - if (!f.name.endsWith('.java')) { - return - } - if (f.text.contains('org.bukkit')) { - String rel = sourceRoot.toPath().relativize(f.toPath()).toString() - coupled.add(rel) - if (!allowed.contains(rel)) { - offenders.add(rel) +Closure registerPurityRatchet = { String taskName, String label, String forbiddenPackage, String allowlistName -> + tasks.register(taskName) { + group = 'verification' + description = "Fails if files outside core/${allowlistName} import ${forbiddenPackage} (the allowlist only shrinks)." + File allowlistFile = project.file(allowlistName) + File sourceRoot = project.file('src/main/java') + inputs.file(allowlistFile) + inputs.dir(sourceRoot) + doLast { + Set allowed = allowlistFile.readLines().findAll { String line -> !line.isBlank() }.toSet() + List offenders = new ArrayList<>() + List coupled = new ArrayList<>() + sourceRoot.eachFileRecurse { File f -> + if (!f.name.endsWith('.java')) { + return + } + if (f.text.contains(forbiddenPackage)) { + String rel = sourceRoot.toPath().relativize(f.toPath()).toString() + coupled.add(rel) + if (!allowed.contains(rel)) { + offenders.add(rel) + } } } - } - if (!offenders.isEmpty()) { - 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() - if (shrunk > 0) { - println("Purity ratchet: " + coupled.size() + " coupled files (" + shrunk + " fewer than allowlist - consider tightening core/purity-allowlist.txt)") - } else { - println("Purity ratchet: " + coupled.size() + " coupled files (at allowlist ceiling)") + 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) + } + int shrunk = allowed.size() - coupled.size() + if (shrunk > 0) { + println(label + " purity ratchet: " + coupled.size() + " coupled files (" + shrunk + " fewer than allowlist - consider tightening core/" + allowlistName + ")") + } else { + println(label + " 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 { - dependsOn('bukkitPurityRatchet') + dependsOn('bukkitPurityRatchet', 'minecraftPurityRatchet') } apply from: rootProject.file('gradle/generation-build-revision.gradle') diff --git a/core/minecraft-purity-allowlist.txt b/core/minecraft-purity-allowlist.txt new file mode 100644 index 000000000..8301dff67 --- /dev/null +++ b/core/minecraft-purity-allowlist.txt @@ -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 diff --git a/core/purity-allowlist.txt b/core/purity-allowlist.txt index 8add17141..213fdd9ec 100644 --- a/core/purity-allowlist.txt +++ b/core/purity-allowlist.txt @@ -84,7 +84,6 @@ art/arcane/iris/core/tools/IrisPackBenchmarking.java art/arcane/iris/core/tools/IrisReflectiveAPI.java art/arcane/iris/core/tools/IrisToolbelt.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/IrisWorldManager.java art/arcane/iris/engine/MarkerSpawnScanner.java