- GUI (phases 7-8): BuilderScreen, Panel, NumberSlider, CycleButton, BuilderUi keybinds (Right Shift menu, P pause macro), lang entries, README - ConfigStore.loadOrEmpty/saveQuietly; BuildSettings.Range; BuilderFeature settings()/stage()/togglePause() - Checks: ~60 Checkstyle rules (errors), PMD with 7 categories, checkArchitecture (layer rules + max 4 files per package, with baseline), javac -Xlint:all -Werror, rule rejecting non-English comments - File length limit raised to 250 lines - License: GPL-3.0-only (LICENSE, fabric.mod.json) - All code comments and log messages translated to English
122 lines
4.5 KiB
Kotlin
122 lines
4.5 KiB
Kotlin
plugins {
|
|
id("fabric-loom") version "1.18.4"
|
|
java
|
|
checkstyle
|
|
pmd
|
|
}
|
|
|
|
version = property("mod_version") as String
|
|
group = property("maven_group") as String
|
|
|
|
base {
|
|
archivesName.set(property("archives_base_name") as String)
|
|
}
|
|
|
|
repositories {
|
|
// nether-pathfinder — рантайм-зависимость Baritone (Aethereal) для dev-запусков
|
|
maven("https://babbaj.github.io/maven/") {
|
|
name = "Babbaj"
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
minecraft("com.mojang:minecraft:${property("minecraft_version")}")
|
|
mappings("net.fabricmc:yarn:${property("yarn_mappings")}:v2")
|
|
modImplementation("net.fabricmc:fabric-loader:${property("loader_version")}")
|
|
modImplementation("net.fabricmc.fabric-api:fabric-api:${property("fabric_version")}")
|
|
|
|
// Baritone (Aethereal): API для компиляции + сам мод в dev-рантайме
|
|
compileOnly(files("libs/aethereal-1.21.11.jar"))
|
|
modLocalRuntime(files("libs/aethereal-1.21.11.jar"))
|
|
modLocalRuntime("dev.babbaj:nether-pathfinder:1.4.1")
|
|
|
|
testImplementation(platform("org.junit:junit-bom:5.11.4"))
|
|
testImplementation("org.junit.jupiter:junit-jupiter")
|
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
}
|
|
|
|
java {
|
|
sourceCompatibility = JavaVersion.VERSION_21
|
|
targetCompatibility = JavaVersion.VERSION_21
|
|
withSourcesJar()
|
|
}
|
|
|
|
tasks.withType<JavaCompile>().configureEach {
|
|
options.encoding = "UTF-8"
|
|
options.release.set(21)
|
|
options.compilerArgs.addAll(listOf("-Xlint:all,-processing,-serial,-classfile", "-Werror"))
|
|
}
|
|
|
|
tasks.processResources {
|
|
inputs.property("version", project.version)
|
|
filesMatching("fabric.mod.json") {
|
|
expand("version" to project.version)
|
|
}
|
|
}
|
|
|
|
// Правило проекта: файл максимум 250 строк — FileLength (severity=error валит check)
|
|
checkstyle {
|
|
toolVersion = "10.21.2"
|
|
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
|
|
}
|
|
|
|
pmd {
|
|
toolVersion = "7.9.0"
|
|
isConsoleOutput = true
|
|
ruleSetFiles = rootProject.files("config/pmd/pmd.xml")
|
|
ruleSets = mutableListOf()
|
|
}
|
|
|
|
tasks.test {
|
|
useJUnitPlatform()
|
|
}
|
|
|
|
// Тесты — шумные правила JUnit в PMD (assert-сообщения, число assert) не применяем
|
|
tasks.named("pmdTest") {
|
|
enabled = false
|
|
}
|
|
|
|
// Архитектура (правила 6 и 11): максимум 4 файла в папке, слои зависят только вниз
|
|
val maxFilesPerDir = 4
|
|
val layerRules = mapOf(
|
|
"util" to setOf<String>(),
|
|
"core" to setOf("util"),
|
|
"interaction" to setOf("core", "util"),
|
|
"render" to setOf("util"),
|
|
"feature" to setOf("core", "interaction", "render", "util"),
|
|
"gui" to setOf("core", "feature", "render", "util"),
|
|
)
|
|
|
|
tasks.register("checkArchitecture") {
|
|
group = "verification"
|
|
description = "Лимит файлов в папке и направление зависимостей между слоями"
|
|
val srcRoot = layout.projectDirectory.dir("src/main/java/dev/loki/satura").asFile
|
|
val baselineFile = layout.projectDirectory.file("config/architecture/baseline.txt").asFile
|
|
doLast {
|
|
val errors = mutableListOf<String>()
|
|
srcRoot.walkTopDown().filter { it.isDirectory }.forEach { dir ->
|
|
val count = dir.listFiles { f -> f.extension == "java" }?.size ?: 0
|
|
if (count > maxFilesPerDir) {
|
|
errors += "${dir.relativeTo(srcRoot)}: $count файлов (максимум $maxFilesPerDir)"
|
|
}
|
|
}
|
|
val baseline = baselineFile.readLines().filter { it.isNotBlank() && !it.startsWith("#") }.toSet()
|
|
val importRe = Regex("^import (?:static )?dev\\.loki\\.satura\\.([a-z]+)")
|
|
srcRoot.walkTopDown().filter { it.extension == "java" }.forEach { file ->
|
|
val rel = file.relativeTo(srcRoot).invariantSeparatorsPath
|
|
val layer = rel.substringBefore('/')
|
|
val allowed = layerRules[layer] ?: return@forEach
|
|
file.readLines().mapNotNull { importRe.find(it)?.groupValues?.get(1) }.distinct()
|
|
.filter { it != layer && it !in allowed }
|
|
.filter { "$rel -> $it" !in baseline }
|
|
.forEach { errors += "$rel: слой '$layer' не может импортировать '$it'" }
|
|
}
|
|
if (errors.isNotEmpty()) {
|
|
throw GradleException("Нарушения архитектуры:\n" + errors.joinToString("\n") { " $it" })
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.named("check") {
|
|
dependsOn("checkArchitecture")
|
|
}
|