2019-09-05 03:55:47 +00:00
|
|
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
|
|
|
import net.minecraftforge.gradle.common.util.RunConfig
|
2020-04-01 01:13:32 +00:00
|
|
|
import net.minecraftforge.gradle.mcp.task.GenerateSRG
|
2020-08-14 19:29:15 +00:00
|
|
|
import net.minecraftforge.gradle.userdev.UserDevExtension
|
2019-09-05 03:55:47 +00:00
|
|
|
import net.minecraftforge.gradle.userdev.tasks.RenameJarInPlace
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
id("net.minecraftforge.gradle")
|
2020-08-14 19:29:15 +00:00
|
|
|
`java-library`
|
2019-09-05 03:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
applyPlatformAndCoreConfiguration()
|
|
|
|
applyShadowConfiguration()
|
|
|
|
|
2020-08-23 15:18:29 +00:00
|
|
|
val minecraftVersion = "1.16.2"
|
2020-08-14 19:29:15 +00:00
|
|
|
val nextMajorMinecraftVersion: String = minecraftVersion.split('.').let { (useless, major) ->
|
|
|
|
"$useless.${major.toInt() + 1}"
|
|
|
|
}
|
|
|
|
val mappingsMinecraftVersion = "1.16"
|
|
|
|
val forgeVersion = "32.0.92"
|
2019-09-05 03:55:47 +00:00
|
|
|
|
|
|
|
configurations.all {
|
|
|
|
resolutionStrategy {
|
|
|
|
force("com.google.guava:guava:21.0")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2020-08-14 19:29:15 +00:00
|
|
|
"api"(project(":worldedit-core"))
|
2021-03-29 13:29:16 +00:00
|
|
|
"implementation"(enforcedPlatform("org.apache.logging.log4j:log4j-bom:2.11.2") {
|
|
|
|
because("Forge provides Log4J at 2.11.2 (Mojang provides 2.8.1, but Forge bumps)")
|
2019-09-05 03:55:47 +00:00
|
|
|
|
|
|
|
"minecraft"("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
|
|
|
|
}
|
|
|
|
|
|
|
|
configure<UserDevExtension> {
|
|
|
|
mappings(mapOf(
|
|
|
|
"channel" to "snapshot",
|
2020-08-14 19:29:15 +00:00
|
|
|
"version" to "20200514-$mappingsMinecraftVersion"
|
2019-09-05 03:55:47 +00:00
|
|
|
))
|
|
|
|
|
|
|
|
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
|
|
|
|
|
|
|
|
runs {
|
|
|
|
val runConfig = Action<RunConfig> {
|
|
|
|
properties(mapOf(
|
|
|
|
"forge.logging.markers" to "SCAN,REGISTRIES,REGISTRYDUMP",
|
|
|
|
"forge.logging.console.level" to "debug"
|
|
|
|
))
|
|
|
|
workingDirectory = project.file("run").canonicalPath
|
|
|
|
source(sourceSets["main"])
|
|
|
|
}
|
|
|
|
create("client", runConfig)
|
|
|
|
create("server", runConfig)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
configure<BasePluginConvention> {
|
|
|
|
archivesBaseName = "$archivesBaseName-mc$minecraftVersion"
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.named<Copy>("processResources") {
|
|
|
|
// this will ensure that this task is redone when the versions change.
|
2020-08-14 19:29:15 +00:00
|
|
|
val properties = mapOf(
|
|
|
|
"version" to project.ext["internalVersion"],
|
|
|
|
"forgeVersion" to forgeVersion,
|
|
|
|
"minecraftVersion" to minecraftVersion,
|
|
|
|
"nextMajorMinecraftVersion" to nextMajorMinecraftVersion
|
|
|
|
)
|
|
|
|
properties.forEach { (key, value) ->
|
|
|
|
inputs.property(key, value)
|
|
|
|
}
|
2019-09-05 03:55:47 +00:00
|
|
|
|
|
|
|
// replace stuff in mcmod.info, nothing else
|
|
|
|
from(sourceSets["main"].resources.srcDirs) {
|
|
|
|
include("META-INF/mods.toml")
|
|
|
|
|
|
|
|
// replace version and mcversion
|
2020-08-14 19:29:15 +00:00
|
|
|
expand(properties)
|
2019-09-05 03:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// copy everything else except the mcmod.info
|
|
|
|
from(sourceSets["main"].resources.srcDirs) {
|
|
|
|
exclude("META-INF/mods.toml")
|
|
|
|
}
|
|
|
|
|
2020-08-14 19:29:15 +00:00
|
|
|
// copy from -core resources as well
|
|
|
|
from(project(":worldedit-core").tasks.named("processResources"))
|
2020-03-08 06:09:36 +00:00
|
|
|
}
|
2019-09-05 03:55:47 +00:00
|
|
|
|
2021-02-25 21:58:17 +00:00
|
|
|
addJarManifest(WorldEditKind.Mod, includeClasspath = false)
|
2020-08-14 19:29:15 +00:00
|
|
|
|
2019-09-05 03:55:47 +00:00
|
|
|
tasks.named<ShadowJar>("shadowJar") {
|
|
|
|
dependencies {
|
2020-08-14 19:29:15 +00:00
|
|
|
relocate("org.antlr.v4", "com.sk89q.worldedit.antlr4")
|
2019-09-05 03:55:47 +00:00
|
|
|
|
2020-08-14 19:29:15 +00:00
|
|
|
include(dependency("org.antlr:antlr4-runtime"))
|
2020-04-25 01:46:03 +00:00
|
|
|
include(dependency("org.mozilla:rhino-runtime"))
|
2019-09-05 03:55:47 +00:00
|
|
|
}
|
|
|
|
minimize {
|
2020-04-25 01:46:03 +00:00
|
|
|
exclude(dependency("org.mozilla:rhino-runtime"))
|
2019-09-05 03:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
val reobf = extensions.getByName<NamedDomainObjectContainer<RenameJarInPlace>>("reobf")
|
|
|
|
reobf.maybeCreate("shadowJar").run {
|
|
|
|
mappings = tasks.getByName<GenerateSRG>("createMcpToSrg").output
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.register<Jar>("deobfJar") {
|
|
|
|
from(sourceSets["main"].output)
|
|
|
|
archiveClassifier.set("dev")
|
|
|
|
}
|
|
|
|
|
|
|
|
artifacts {
|
|
|
|
add("archives", tasks.named("deobfJar"))
|
|
|
|
}
|