163 lines
4.2 KiB
Groovy
163 lines
4.2 KiB
Groovy
import java.nio.file.Files
|
|
import java.nio.file.StandardCopyOption
|
|
import net.neoforged.moddevgradle.internal.RunGameTask
|
|
|
|
plugins {
|
|
id("net.neoforged.moddev")
|
|
id 'maven-publish'
|
|
}
|
|
|
|
repositories {
|
|
maven {
|
|
name = 'NeoForged'
|
|
url = 'https://maven.neoforged.net/releases/'
|
|
}
|
|
maven {
|
|
name 'Maven for PR #2297' // https://github.com/neoforged/NeoForge/pull/2297
|
|
url 'https://prmaven.neoforged.net/NeoForge/pr2297'
|
|
content {
|
|
includeModule('net.neoforged', 'neoforge')
|
|
includeModule('net.neoforged', 'testframework')
|
|
}
|
|
}
|
|
}
|
|
|
|
def aw2at = Aw2AtTask.configureDefault(
|
|
getProject(),
|
|
rootProject.layout.projectDirectory.file("src/main/resources/moonrise.accesswidener").getAsFile(),
|
|
sourceSets.main
|
|
)
|
|
|
|
neoForge {
|
|
version = rootProject.neoforge_version
|
|
validateAccessTransformers = true
|
|
accessTransformers.files.setFrom(aw2at.flatMap { t -> t.getOutputFile() })
|
|
mods {
|
|
moonrise {
|
|
sourceSet sourceSets.main
|
|
sourceSet rootProject.sourceSets.main
|
|
}
|
|
}
|
|
runs {
|
|
client {
|
|
client()
|
|
}
|
|
server {
|
|
server()
|
|
}
|
|
}
|
|
unitTest {
|
|
enable()
|
|
testedMod = mods.moonrise
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
runtimeOnly(project(":").sourceSets.main.output)
|
|
shadow(project(":"))
|
|
compileOnly(project(":"))
|
|
|
|
libs("ca.spottedleaf:concurrentutil:${rootProject.concurrentutil_version}") { setTransitive(false) }
|
|
libs("ca.spottedleaf:yamlconfig:${rootProject.yamlconfig_version}") { setTransitive(false) }
|
|
additionalRuntimeClasspath libs("org.yaml:snakeyaml:${rootProject.snakeyaml_version}")
|
|
|
|
implementation "me.shedaniel.cloth:cloth-config-neoforge:${rootProject.cloth_version}"
|
|
jarJar "me.shedaniel.cloth:cloth-config-neoforge:${rootProject.cloth_version}"
|
|
}
|
|
|
|
tasks.processResources {
|
|
def properties = [
|
|
"version": project.version,
|
|
"minecraft_version": minecraft_version,
|
|
"mod_version": mod_version
|
|
]
|
|
inputs.properties(properties)
|
|
filesMatching("META-INF/neoforge.mods.toml") {
|
|
expand properties
|
|
}
|
|
}
|
|
|
|
tasks.jar {
|
|
archiveClassifier = "dev"
|
|
}
|
|
|
|
tasks.shadowJar {
|
|
archiveClassifier = "dev-all"
|
|
destinationDirectory = layout.buildDirectory.dir("libs")
|
|
configurations = [project.configurations.shadow]
|
|
relocate 'ca.spottedleaf.concurrentutil', 'ca.spottedleaf.moonrise.libs.ca.spottedleaf.concurrentutil'
|
|
relocate 'ca.spottedleaf.yamlconfig', 'ca.spottedleaf.moonrise.libs.ca.spottedleaf.yamlconfig'
|
|
relocate 'org.yaml.snakeyaml', 'ca.spottedleaf.moonrise.libs.org.yaml.snakeyaml'
|
|
}
|
|
|
|
tasks.register("productionJar", Zip.class) {
|
|
archiveClassifier = ""
|
|
archiveExtension = "jar"
|
|
destinationDirectory = layout.buildDirectory.dir("libs")
|
|
from(tasks.jarJar)
|
|
from(zipTree(tasks.shadowJar.archiveFile))
|
|
}
|
|
|
|
tasks.assemble {
|
|
dependsOn tasks.productionJar
|
|
}
|
|
|
|
publishMods {
|
|
file = productionJar.archiveFile
|
|
modLoaders = ["neoforge"]
|
|
|
|
modrinth {
|
|
incompatible(
|
|
"notenoughcrashes",
|
|
"starlight-neoforge",
|
|
"canary"
|
|
)
|
|
}
|
|
curseforge {
|
|
incompatible(
|
|
"not-enough-crashes-forge",
|
|
"starlight-neoforge",
|
|
"canary"
|
|
)
|
|
}
|
|
}
|
|
|
|
afterEvaluate {
|
|
neoForge.runs.configureEach { cfg ->
|
|
runConfigCommon.systemProperties.get().each {
|
|
cfg.systemProperties.put it.key, it.value
|
|
}
|
|
}
|
|
}
|
|
|
|
// Setup a run with lithium for compatibility testing
|
|
neoForge {
|
|
runs {
|
|
lithiumClient {
|
|
client()
|
|
disableIdeRun()
|
|
}
|
|
}
|
|
}
|
|
tasks.withType(RunGameTask).configureEach {
|
|
if (name == "runLithiumClient") {
|
|
return
|
|
}
|
|
def out = gameDirectory.get().getAsFile().toPath().resolve("mods/lithium-tmp.jar")
|
|
doFirst {
|
|
Files.deleteIfExists(out)
|
|
}
|
|
}
|
|
def lithium = configurations.lithium
|
|
tasks.runLithiumClient {
|
|
def out = gameDirectory.get().getAsFile().toPath().resolve("mods/lithium-tmp.jar")
|
|
doFirst {
|
|
for (File file in lithium) {
|
|
Files.copy(file.toPath(), out, StandardCopyOption.REPLACE_EXISTING)
|
|
}
|
|
}
|
|
doLast {
|
|
Files.deleteIfExists(out)
|
|
}
|
|
}
|