Files
thaumicenergistics-neo/build.gradle
T
2026-11-01 22:38:46 +08:00

228 lines
9.7 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
plugins {
id 'net.neoforged.moddev' version '2.0.78'
id 'maven-publish'
}
// The workspace uses Git-derived versions. A standalone export owns its release version.
if (project != rootProject && rootProject.file('versioning.gradle').isFile()) {
apply from: rootProject.file('versioning.gradle')
} else {
version = findProperty('mod_version') ?: '0.0.0-alpha'
}
repositories {
mavenCentral()
// The root project adds Maven Local; this module resolves published dependencies from remote repositories.
removeAll { it.name.startsWith('MavenLocal') }
// Declare JEI here too: standalone exports do not inherit the root repositories.
withType(org.gradle.api.artifacts.repositories.MavenArtifactRepository)
.findAll { it.url?.host == 'maven.blamejared.com' }
.each { repository -> remove(repository) }
// Route publisher-specific coordinates exclusively to their actual repository.
// A slow/unreachable NeoForge mirror must not intercept JEI or optional mod lookups.
[
'mezz.jei': 'https://maven.blamejared.com/',
'curse.maven': 'https://cursemaven.com',
'maven.modrinth': 'https://api.modrinth.com/maven',
// The AE2WT API is a separate artifact; the full mod only embeds its API Jar.
'de.mari_023': 'https://modmaven.dev'
].each { artifactGroup, repositoryUrl ->
exclusiveContent {
forRepository {
maven { url repositoryUrl }
}
filter { includeGroup artifactGroup }
}
}
}
group = mod_group
var modName = mod_name
var mcVersion = minecraft_version
base { archivesName = "${modName}-${mcVersion}-neoforge" }
def compatBaseRun = ['compatSmokeTest', 'compatWT', 'compatAAE', 'compatAE2LT', 'enableExtendedAeCompatTest']
.any { key -> providers.gradleProperty(key).map { it.toBoolean() }.getOrElse(false) }
def thaumcraftJar = layout.projectDirectory.file("library/thaumcraft-${thaumcraft_version}.jar")
def verifyLocalThaumcraft = tasks.register('verifyLocalThaumcraft') {
group = 'build setup'
description = 'Checks that the unpublished Thaumcraft port Jar is present.'
doLast {
if (!thaumcraftJar.asFile.isFile()) {
throw new GradleException("Missing unpublished TC port: ${thaumcraftJar.asFile}\n"
+ "Place thaumcraft-${thaumcraft_version}.jar in ${thaumcraftJar.asFile.parentFile}. "
+ 'All other dependencies are downloaded automatically. See README.md.')
}
}
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(21)
withSourcesJar()
}
sourceSets {
gameTest {
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}
configurations {
gameTestImplementation.extendsFrom implementation
gameTestCompileOnly.extendsFrom compileOnly
gameTestRuntimeOnly.extendsFrom runtimeOnly
}
neoForge {
version = neoforge_version
addModdingDependenciesTo(sourceSets.gameTest)
runs {
client { client() }
server { server() }
smokeServer {
server()
gameDirectory = file('build/smoke-server')
programArgument '--nogui'
}
smokeGameTests {
type = 'gameTestServer'
sourceSet = sourceSets.gameTest
gameDirectory = file('build/smoke-gametests')
systemProperty 'neoforge.enabledGameTestNamespaces', 'thaumicenergistics_tests'
}
}
mods { "${mod_id}" { sourceSet sourceSets.main } }
if (providers.gradleProperty('compatSmokeTest').map { it.toBoolean() }.getOrElse(false)) {
mods { thaumicenergistics_tests { sourceSet sourceSets.gameTest } }
}
}
// ModDevGradle can add Maven Local again while configuring main/gameTest source sets.
// Remove those repositories after configuration without touching its generated Minecraft artifact repositories.
afterEvaluate {
repositories.removeAll { it.name.startsWith('MavenLocal') }
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.10.2'
// 兼容联调开关自动补齐基础运行前置;普通生产构建仍仅 compileOnly。
if (compatBaseRun) {
runtimeOnly("org.appliedenergistics:appliedenergistics2:${ae2_version}") {
exclude group: 'org.appliedenergistics', module: 'guideme'
}
runtimeOnly("maven.modrinth:guideme:PALpfSdf") { transitive = false } // 21.1.1
// The unpublished TC port is intentionally the only local binary dependency.
runtimeOnly files(thaumcraftJar)
runtimeOnly("maven.modrinth:curios:yohfFbgD") { transitive = false } // 9.5.1+1.21.1
}
if (providers.gradleProperty('compatWT').map { it.toBoolean() }.getOrElse(false)) {
// Full AE2WT 19.5.1; its API stays a separate compileOnly dependency below.
runtimeOnly("maven.modrinth:applied-energistics-2-wireless-terminals:CxSEpEnO") {
transitive = false
}
}
compileOnly "org.appliedenergistics:appliedenergistics2:${ae2_version}:api"
compileOnly "org.appliedenergistics:appliedenergistics2:${ae2_version}" // 加这行保留!!让AE2内部类可编译
compileOnly files(thaumcraftJar) // Keep TC port.261: compile and runtime must agree.
// Full JEI artifact preserves the same API/internal compile surface as the former local Jar.
compileOnly("mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}") { transitive = false }
compileOnly("curse.maven:ae2-jei-integration-1074338:7727898") { transitive = false } // 1.2.1
compileOnly("maven.modrinth:inventory-profiles-next:vjuNnHLv") { transitive = false } // NeoForge 1.21.1 / 2.2.5
compileOnly("maven.modrinth:extendedae-plus:DLFDZIVx") { transitive = false } // 1.6.1, EAP InputEvents mixin target
compileOnly "maven.modrinth:jade:${jade_version}"
// COMPAT-PLAN 编译依赖:全部可选集成,零运行时强依赖(普通代码仅 ModList 守护 +
// 注册表软查;Mixin 目标类引用仅出现在各自独立 mixins.json 的兼容配置内)。
// ae2wtlib_api:ItemWT/WTMenuHost/AddTerminalEvent 正式接入奥术终端功能。
compileOnly("de.mari_023:ae2wtlib_api:19.5.1") {
transitive = false
}
// AdvancedAE:AdvPatternProviderLogic 独立卡槽组与源质能力组 Mixin 编译。
compileOnly("maven.modrinth:advancedae:ablTMAjP") {
transitive = false
}
// AE2 Lightning Tech:过载样板供应器独立派发路径源质门控 Mixin 编译。
compileOnly("maven.modrinth:ae2-lightning-tech:AosdXlfS") {
transitive = false
}
// EAE-COMPAT 联调开关:仅指定 -PenableExtendedAeCompatTest=true 时加载 Extended AE
// (1.21-2.2.35-neoforge,Modrinth bC302UUP)作运行时依赖;兼容代码零 EAE 编译引用,
// API 由本体内嵌,基础前置由 compatBaseRun 提供,Glodium 在此补齐。
if (providers.gradleProperty('enableExtendedAeCompatTest')
.map { it.toBoolean() }
.getOrElse(false)) {
runtimeOnly("maven.modrinth:extended-ae:bC302UUP") {
transitive = false
}
runtimeOnly("maven.modrinth:glodium:pfbmdJ3b") { transitive = false }
}
// COMPAT-PLAN 联调开关:同上,仅运行环境加载,生产构建不受影响。
// AAE 内嵌 AE2AddonLib/API,外部前置 GeckoLib 在此补齐。
if (providers.gradleProperty('compatAAE')
.map { it.toBoolean() }
.getOrElse(false)) {
runtimeOnly("maven.modrinth:advancedae:ablTMAjP") {
transitive = false
}
runtimeOnly("maven.modrinth:geckolib:RVIo5f6E") { transitive = false }
}
// AE2LT 必需前置 Thunderbolt Core(2.0.3-beta2,Modrinth oyVnlG5A),随开关一起加载。
if (providers.gradleProperty('compatAE2LT')
.map { it.toBoolean() }
.getOrElse(false)) {
runtimeOnly("maven.modrinth:ae2-lightning-tech:AosdXlfS") {
transitive = false
}
runtimeOnly("maven.modrinth:thunderbolt-core:oyVnlG5A") {
transitive = false
}
}
}
tasks.withType(JavaCompile).configureEach {
dependsOn verifyLocalThaumcraft
it.options.encoding = 'UTF-8'
it.options.release = 21
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
}
// 模组元数据与 Jar 始终使用同一构建版本(工作区 Git 版本或独立项目 mod_version)。
var modVersion = version.toString()
def loaderRange = project.findProperty('loader_version_range') ?: '[4,)'
def neoforgeRange = project.findProperty('neoforge_version_range') ?: '[21,)'
def mcRange = project.findProperty('minecraft_version_range') ?: '[1.21.1,1.22)'
// Generate expanded metadata separately so IDEA does not have to interpret resource matching actions.
def metadataProperties = [
'version': modVersion, 'loader_version_range': loaderRange,
'neoforge_version_range': neoforgeRange, 'minecraft_version_range': mcRange
]
def generateModMetadata = tasks.register('generateModMetadata', ProcessResources) {
inputs.properties(metadataProperties)
filteringCharset = 'UTF-8'
expand(metadataProperties)
from('src/main/templates')
into(layout.buildDirectory.dir('generated/resources/modMetadata'))
}
sourceSets.main.resources.srcDir(generateModMetadata)
neoForge.ideSyncTask(generateModMetadata)
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from(projectDir) {
include 'LICENSE', 'LICENSE-ASSETS.md', 'LICENSE-CC-BY-NC-SA-3.0.txt'
}
// PCL/启动器显示的 jar 图标(mod 列表图标走 neoforge.mods.toml 的 logoFile)
from('src/main/resources') {
include 'pack.png'
}
}