226 lines
9.4 KiB
Groovy
226 lines
9.4 KiB
Groovy
plugins {
|
||
id 'net.neoforged.moddev' version '2.0.78'
|
||
id 'maven-publish'
|
||
}
|
||
|
||
apply from: file('../../versioning.gradle')
|
||
|
||
repositories {
|
||
mavenCentral()
|
||
// The root project adds Maven Local; this module resolves published dependencies from remote repositories.
|
||
removeAll { it.name.startsWith('MavenLocal') }
|
||
// Keep the inherited JEI repository from handling unrelated AE2/Modrinth lookups.
|
||
withType(org.gradle.api.artifacts.repositories.MavenArtifactRepository)
|
||
.findAll { it.url?.host == 'maven.blamejared.com' }
|
||
.each { repository -> repository.content { includeGroup 'mezz.jei' } }
|
||
// AE2 JEI Integration is published on CurseForge; pin its exact file through CurseMaven.
|
||
maven {
|
||
url "https://cursemaven.com"
|
||
content {
|
||
includeGroup "curse.maven"
|
||
}
|
||
}
|
||
// Fixed NeoForge releases for optional integrations and development runtime dependencies.
|
||
maven {
|
||
url "https://api.modrinth.com/maven"
|
||
content {
|
||
includeGroup "maven.modrinth"
|
||
}
|
||
}
|
||
// COMPAT-PLAN:ae2wtlib_api 独立坐标(完整 ae2wtlib jar 的 API 在内嵌 jar,
|
||
// 外层 compileOnly files 看不到 API 类,必须用 modmaven 的独立 API 构件)
|
||
maven {
|
||
url "https://modmaven.dev"
|
||
content {
|
||
includeGroup "de.mari_023"
|
||
}
|
||
}
|
||
}
|
||
|
||
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 modules/thaumicenergistics-neo/library/. "
|
||
+ 'All other dependencies are downloaded automatically. See BUILDING.md at the repository root.')
|
||
}
|
||
}
|
||
}
|
||
|
||
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()
|
||
}
|
||
|
||
// mods.toml 的 version 也用 git 实时版本(与 jar 版本一致,不依赖写死的 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)'
|
||
|
||
processResources {
|
||
// expand 值必须声明为 task 输入,否则 modVersion 变化时 Gradle 判 UP-TO-DATE 跳过,
|
||
// jar 内 mods.toml 会钉死在旧版本(2.4.32 固化事故根因)。
|
||
inputs.properties([
|
||
'version': modVersion, 'loader_version_range': loaderRange,
|
||
'neoforge_version_range': neoforgeRange, 'minecraft_version_range': mcRange
|
||
])
|
||
filesMatching('META-INF/neoforge.mods.toml') {
|
||
expand([
|
||
'version': modVersion, 'loader_version_range': loaderRange,
|
||
'neoforge_version_range': neoforgeRange, 'minecraft_version_range': mcRange
|
||
])
|
||
}
|
||
}
|
||
|
||
jar {
|
||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||
// PCL/启动器显示的 jar 图标(mod 列表图标走 neoforge.mods.toml 的 logoFile)
|
||
from('src/main/resources') {
|
||
include 'pack.png'
|
||
}
|
||
}
|