156 lines
5.7 KiB
Groovy
156 lines
5.7 KiB
Groovy
plugins {
|
|
id 'java-library'
|
|
id 'maven-publish'
|
|
id 'net.neoforged.gradle.userdev' version '7.0.170'
|
|
}
|
|
|
|
tasks.named('wrapper', Wrapper).configure {
|
|
distributionType = Wrapper.DistributionType.BIN
|
|
gradleVersion = '8.10'
|
|
}
|
|
|
|
version = mod_version
|
|
group = mod_group_id
|
|
|
|
base {
|
|
archivesName = mod_id
|
|
}
|
|
|
|
java {
|
|
toolchain {
|
|
languageVersion = JavaLanguageVersion.of(21)
|
|
}
|
|
withSourcesJar()
|
|
}
|
|
|
|
// 方案A验证用:无 mod 源码集(仅承载 Demo 资源,不注册任何模组)
|
|
sourceSets {
|
|
demo {
|
|
java { srcDir 'src/demo/java' }
|
|
resources { srcDir 'src/demo/resources' }
|
|
}
|
|
}
|
|
|
|
//minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
|
|
//minecraft.accessTransformers.publish rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
|
|
|
|
runs {
|
|
configureEach {
|
|
systemProperty 'forge.logging.markers', 'REGISTRIES'
|
|
//systemProperty 'forge.logging.console.level', 'debug'
|
|
systemProperty 'mixin.debug.verbose', 'true'
|
|
systemProperty 'mixin.debug.export', 'true'
|
|
}
|
|
|
|
client {
|
|
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
|
// TEMP-DEBUG: auto-join world for deadlock repro (REMOVE AFTER DEBUG)
|
|
// 临时注释:方案A验证需手动连 Demo 服务器(不自动进单人)
|
|
//argument '--quickPlaySingleplayer'
|
|
//argument '新的世界'
|
|
// 关闭 JVM 热路径堆栈省略,便于定位并行子任务中反复抛出的 ClassCastException
|
|
jvmArguments '-XX:-OmitStackTraceInFastThrow'
|
|
modSource project.sourceSets.main
|
|
}
|
|
|
|
server {
|
|
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
|
argument '--nogui'
|
|
modSource project.sourceSets.main
|
|
}
|
|
|
|
gameTestServer {
|
|
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
|
}
|
|
|
|
data {
|
|
arguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
|
|
}
|
|
}
|
|
|
|
sourceSets.main.resources {
|
|
srcDir 'src/generated/resources'
|
|
}
|
|
|
|
dependencies {
|
|
implementation "net.neoforged:neoforge:${neo_version}"
|
|
}
|
|
|
|
// Opt-in isolated runtime fixture; excluded from normal builds.
|
|
if (providers.gradleProperty('interactionRegression').isPresent()) {
|
|
sourceSets.main.java.srcDir('tests/integration')
|
|
sourceSets.main.java.exclude('**/ChunkHandoffRegression.java')
|
|
}
|
|
if (providers.gradleProperty('ownershipRegression').isPresent()) {
|
|
if (providers.gradleProperty('interactionRegression').isPresent()) {
|
|
throw new GradleException('Run ownershipRegression and interactionRegression separately.')
|
|
}
|
|
sourceSets.main.java.srcDir('tests/ownership')
|
|
dependencies { runtimeOnly files(providers.gradleProperty('ccTestJar').get()) }
|
|
tasks.matching { it.name == 'runServer' }.configureEach {
|
|
doLast {
|
|
def output = file('runs/server/logs/latest.log').getText('UTF-8')
|
|
['OWNERSHIP REGRESSION PASS', 'OWNERSHIP EDGE PASS', 'OWNERSHIP CALLBACK PASS', 'OWNERSHIP RESUME PASS'].each { marker ->
|
|
if (!output.contains(marker)) throw new GradleException("Missing runtime test result: ${marker}")
|
|
}
|
|
if (output.contains('Encountered an unexpected exception')) throw new GradleException('Runtime regression server crashed.')
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.withType(ProcessResources).configureEach {
|
|
var replaceProperties = [
|
|
minecraft_version : minecraft_version,
|
|
minecraft_version_range: minecraft_version_range,
|
|
neo_version : neo_version,
|
|
neo_version_range : neo_version_range,
|
|
loader_version_range: loader_version_range,
|
|
mod_id : mod_id,
|
|
mod_name : mod_name,
|
|
mod_license : mod_license,
|
|
mod_version : mod_version,
|
|
mod_authors : mod_authors,
|
|
mod_description : mod_description
|
|
]
|
|
inputs.properties replaceProperties
|
|
|
|
filesMatching(['META-INF/neoforge.mods.toml']) {
|
|
expand replaceProperties
|
|
}
|
|
}
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
options.encoding = 'UTF-8'
|
|
}
|
|
|
|
idea {
|
|
module {
|
|
downloadSources = true
|
|
downloadJavadoc = true
|
|
}
|
|
}
|
|
|
|
// Pure-Java scheduling regressions run in check without bootstrapping Minecraft.
|
|
def regressionClasses = layout.buildDirectory.dir('regression')
|
|
tasks.register('compileConcurrencyRegression', JavaCompile) {
|
|
source = files('tests/TaskBarrierRegression.java', 'tests/ManagedFutureAwaitRegression.java',
|
|
'src/main/java/dev/modzuozhi/core/compat/TaskBarrier.java',
|
|
'src/main/java/dev/modzuozhi/core/compat/ManagedFutureAwait.java',
|
|
'src/main/java/dev/modzuozhi/core/compat/PauseOwnership.java', 'tests/PauseOwnershipRegression.java',
|
|
'src/main/java/dev/modzuozhi/core/compat/TickProgress.java', 'tests/TickProgressRegression.java',
|
|
'src/main/java/dev/modzuozhi/core/compat/PayloadWorkQueue.java', 'tests/PayloadWorkQueueRegression.java')
|
|
classpath = files()
|
|
destinationDirectory = regressionClasses
|
|
}
|
|
['TaskBarrierRegression', 'ManagedFutureAwaitRegression', 'PauseOwnershipRegression', 'TickProgressRegression', 'PayloadWorkQueueRegression'].each { regressionMain ->
|
|
def regressionTask = tasks.register("run${regressionMain}", JavaExec) {
|
|
dependsOn 'compileConcurrencyRegression'
|
|
classpath = files(regressionClasses)
|
|
mainClass = regressionMain
|
|
javaLauncher = javaToolchains.launcherFor {
|
|
languageVersion = JavaLanguageVersion.of(21)
|
|
}
|
|
}
|
|
tasks.named('check') { dependsOn regressionTask }
|
|
}
|