2019-07-11 08:45:33 +08:00
|
|
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
|
|
|
import net.minecraftforge.gradle.common.util.RunConfig
|
|
|
|
import net.minecraftforge.gradle.userdev.UserDevExtension
|
|
|
|
import net.minecraftforge.gradle.userdev.tasks.RenameJarInPlace
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
id("net.minecraftforge.gradle")
|
2022-01-07 12:52:12 +08:00
|
|
|
id("org.spongepowered.mixin")
|
2020-07-16 09:48:47 +08:00
|
|
|
`java-library`
|
2019-07-11 08:45:33 +08:00
|
|
|
}
|
|
|
|
|
2021-12-01 06:23:49 +08:00
|
|
|
applyPlatformAndCoreConfiguration(javaRelease = 17)
|
2019-07-11 08:45:33 +08:00
|
|
|
applyShadowConfiguration()
|
|
|
|
|
2022-03-02 10:15:49 +08:00
|
|
|
val minecraftVersion = "1.18.2"
|
2020-03-22 16:42:53 +08:00
|
|
|
val nextMajorMinecraftVersion: String = minecraftVersion.split('.').let { (useless, major) ->
|
|
|
|
"$useless.${major.toInt() + 1}"
|
|
|
|
}
|
2022-03-05 11:15:18 +08:00
|
|
|
val forgeVersion = "40.0.3"
|
2021-12-03 02:21:57 +08:00
|
|
|
|
2021-12-03 03:43:49 +08:00
|
|
|
val apiClasspath = configurations.create("apiClasspath") {
|
|
|
|
isCanBeResolved = true
|
|
|
|
extendsFrom(configurations.api.get())
|
|
|
|
}
|
2019-07-11 08:45:33 +08:00
|
|
|
|
|
|
|
dependencies {
|
2021-12-03 03:43:49 +08:00
|
|
|
"api"(project(":worldedit-core"))
|
2021-12-13 07:49:32 +08:00
|
|
|
"implementation"(platform("org.apache.logging.log4j:log4j-bom:${Versions.LOG4J}") {
|
|
|
|
because("Mojang provides Log4J")
|
2021-01-25 18:14:09 +08:00
|
|
|
})
|
2019-07-11 08:45:33 +08:00
|
|
|
|
|
|
|
"minecraft"("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
|
2022-01-07 12:52:12 +08:00
|
|
|
"annotationProcessor"("org.spongepowered:mixin:0.8.5:processor")
|
2019-07-11 08:45:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
configure<UserDevExtension> {
|
2021-12-03 03:43:49 +08:00
|
|
|
mappings("official", minecraftVersion)
|
2019-07-11 08:45:33 +08:00
|
|
|
|
2019-09-05 11:55:47 +08:00
|
|
|
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
|
|
|
|
|
2019-07-11 08:45:33 +08:00
|
|
|
runs {
|
|
|
|
val runConfig = Action<RunConfig> {
|
|
|
|
properties(mapOf(
|
2021-06-14 02:32:38 +08:00
|
|
|
"forge.logging.markers" to "SCAN,REGISTRIES,REGISTRYDUMP",
|
|
|
|
"forge.logging.console.level" to "debug"
|
2019-07-11 08:45:33 +08:00
|
|
|
))
|
|
|
|
workingDirectory = project.file("run").canonicalPath
|
|
|
|
source(sourceSets["main"])
|
2021-12-03 02:21:57 +08:00
|
|
|
lazyToken("minecraft_classpath") {
|
2021-12-03 03:43:49 +08:00
|
|
|
apiClasspath.resolve().joinToString(File.pathSeparator) { it.absolutePath }
|
2021-12-03 02:21:57 +08:00
|
|
|
}
|
|
|
|
}
|
2021-12-03 03:43:49 +08:00
|
|
|
create("client", runConfig)
|
|
|
|
create("server", runConfig)
|
2019-07-11 08:45:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-01-07 12:52:12 +08:00
|
|
|
configure<org.spongepowered.asm.gradle.plugins.MixinExtension> {
|
|
|
|
add(sourceSets["main"], "worldedit.mixins.refmap.json")
|
|
|
|
config("worldedit.mixins.json")
|
|
|
|
}
|
|
|
|
|
2019-07-11 08:45:33 +08:00
|
|
|
configure<BasePluginConvention> {
|
|
|
|
archivesBaseName = "$archivesBaseName-mc$minecraftVersion"
|
|
|
|
}
|
2021-06-14 02:32:38 +08:00
|
|
|
|
|
|
|
val javaComponent = components["java"] as AdhocComponentWithVariants
|
|
|
|
javaComponent.withVariantsFromConfiguration(configurations["apiElements"]) {
|
|
|
|
skip()
|
|
|
|
}
|
|
|
|
|
|
|
|
javaComponent.withVariantsFromConfiguration(configurations["runtimeElements"]) {
|
|
|
|
skip()
|
|
|
|
}
|
2021-12-01 06:23:49 +08:00
|
|
|
|
2021-06-14 02:32:38 +08:00
|
|
|
tasks.register<Jar>("deobfJar") {
|
|
|
|
from(sourceSets["main"].output)
|
|
|
|
archiveClassifier.set("dev")
|
|
|
|
}
|
|
|
|
|
|
|
|
val reobfApiElements = configurations.register("reobfApiElements") {
|
|
|
|
isVisible = false
|
|
|
|
description = "Re-obfuscated API elements for libs"
|
|
|
|
isCanBeResolved = false
|
|
|
|
isCanBeConsumed = true
|
|
|
|
attributes {
|
|
|
|
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_API))
|
|
|
|
attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY))
|
|
|
|
attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.EXTERNAL))
|
|
|
|
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
|
|
|
|
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
|
|
|
|
}
|
|
|
|
outgoing.artifact(tasks.named("jar")) {
|
|
|
|
builtBy(project.provider { tasks.named("reobfJar") })
|
|
|
|
}
|
|
|
|
extendsFrom(configurations["api"])
|
|
|
|
}
|
|
|
|
|
|
|
|
javaComponent.addVariantsFromConfiguration(reobfApiElements.get()) {
|
|
|
|
mapToMavenScope("compile")
|
|
|
|
}
|
|
|
|
|
|
|
|
val reobfRuntimeElements = configurations.register("reobfRuntimeElements") {
|
|
|
|
isVisible = false
|
|
|
|
description = "Re-obfuscated runtime elements for libs"
|
|
|
|
isCanBeResolved = false
|
|
|
|
isCanBeConsumed = true
|
|
|
|
attributes {
|
|
|
|
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME))
|
|
|
|
attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY))
|
|
|
|
attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.EXTERNAL))
|
|
|
|
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
|
|
|
|
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
|
|
|
|
}
|
|
|
|
outgoing.artifact(tasks.named("jar")) {
|
|
|
|
builtBy(project.provider { tasks.named("reobfJar") })
|
|
|
|
}
|
|
|
|
extendsFrom(configurations["reobfApiElements"])
|
|
|
|
extendsFrom(configurations["runtimeClasspath"].copy { d -> d.group != "net.minecraftforge" })
|
|
|
|
}
|
|
|
|
|
|
|
|
javaComponent.addVariantsFromConfiguration(reobfRuntimeElements.get()) {
|
|
|
|
mapToMavenScope("runtime")
|
|
|
|
}
|
|
|
|
|
2021-04-07 04:45:57 +08:00
|
|
|
configure<PublishingExtension> {
|
|
|
|
publications.named<MavenPublication>("maven") {
|
|
|
|
artifactId = the<BasePluginConvention>().archivesBaseName
|
2021-06-14 02:32:38 +08:00
|
|
|
from(components["java"])
|
2021-04-07 04:45:57 +08:00
|
|
|
}
|
|
|
|
}
|
2019-07-11 08:45:33 +08:00
|
|
|
|
|
|
|
tasks.named<Copy>("processResources") {
|
|
|
|
// this will ensure that this task is redone when the versions change.
|
2020-03-22 16:42:53 +08:00
|
|
|
val properties = mapOf(
|
2021-06-14 02:32:38 +08:00
|
|
|
"version" to project.ext["internalVersion"],
|
|
|
|
"forgeVersion" to forgeVersion,
|
|
|
|
"minecraftVersion" to minecraftVersion,
|
|
|
|
"nextMajorMinecraftVersion" to nextMajorMinecraftVersion
|
2020-03-22 16:42:53 +08:00
|
|
|
)
|
|
|
|
properties.forEach { (key, value) ->
|
|
|
|
inputs.property(key, value)
|
|
|
|
}
|
2019-07-11 08:45:33 +08:00
|
|
|
|
2021-05-14 13:01:45 +08:00
|
|
|
filesMatching("META-INF/mods.toml") {
|
2020-03-22 16:42:53 +08:00
|
|
|
expand(properties)
|
2019-07-11 08:45:33 +08:00
|
|
|
}
|
|
|
|
|
2020-02-04 13:17:08 +08:00
|
|
|
// copy from -core resources as well
|
2020-02-04 13:26:13 +08:00
|
|
|
from(project(":worldedit-core").tasks.named("processResources"))
|
2019-07-11 08:45:33 +08:00
|
|
|
}
|
|
|
|
|
2021-02-23 14:05:23 +08:00
|
|
|
addJarManifest(WorldEditKind.Mod, includeClasspath = false)
|
2019-07-11 08:45:33 +08:00
|
|
|
|
|
|
|
tasks.named<ShadowJar>("shadowJar") {
|
|
|
|
dependencies {
|
2019-10-19 15:48:49 +08:00
|
|
|
relocate("org.antlr.v4", "com.sk89q.worldedit.antlr4")
|
2019-07-11 08:45:33 +08:00
|
|
|
|
2019-10-19 15:48:49 +08:00
|
|
|
include(dependency("org.antlr:antlr4-runtime"))
|
2020-04-25 09:49:11 +08:00
|
|
|
include(dependency("org.mozilla:rhino-runtime"))
|
2019-07-11 09:55:09 +08:00
|
|
|
}
|
|
|
|
minimize {
|
2020-04-25 09:49:11 +08:00
|
|
|
exclude(dependency("org.mozilla:rhino-runtime"))
|
2019-07-11 08:45:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
val reobf = extensions.getByName<NamedDomainObjectContainer<RenameJarInPlace>>("reobf")
|
2021-07-29 14:01:35 +08:00
|
|
|
reobf.create("shadowJar")
|
2019-07-11 08:45:33 +08:00
|
|
|
}
|