2016-08-17 15:23:28 -04:00
|
|
|
buildscript {
|
2016-10-02 11:58:41 -04:00
|
|
|
repositories {
|
2016-10-19 04:58:14 -04:00
|
|
|
maven {
|
2019-06-28 17:55:20 -04:00
|
|
|
name "Fabric Repository"
|
|
|
|
url 'https://maven.fabricmc.net'
|
2016-10-19 04:58:14 -04:00
|
|
|
}
|
2021-03-16 13:51:18 -04:00
|
|
|
mavenCentral()
|
2021-07-03 20:30:37 -04:00
|
|
|
mavenLocal()
|
2016-10-02 11:58:41 -04:00
|
|
|
}
|
|
|
|
dependencies {
|
2020-06-03 14:47:17 -04:00
|
|
|
classpath "cuchaz:enigma-cli:${project.enigma_version}"
|
|
|
|
classpath "net.fabricmc:stitch:${project.stitch_version}"
|
2022-04-15 18:17:53 -04:00
|
|
|
classpath "commons-io:commons-io:2.11.0"
|
|
|
|
classpath "de.undercouch:gradle-download-task:4.1.1"
|
|
|
|
classpath "net.fabricmc:tiny-remapper:${project.tiny_remapper_version}"
|
2021-03-26 15:04:22 -04:00
|
|
|
classpath "net.fabricmc.unpick:unpick:${project.unpick_version}"
|
|
|
|
classpath "net.fabricmc.unpick:unpick-format-utils:${project.unpick_version}"
|
2021-09-28 11:17:36 -04:00
|
|
|
classpath "net.fabricmc:name-proposal:${project.name_proposal_version}"
|
2016-10-02 11:58:41 -04:00
|
|
|
}
|
2016-08-17 15:23:28 -04:00
|
|
|
}
|
|
|
|
|
2018-12-08 07:32:48 -05:00
|
|
|
plugins {
|
2021-07-10 07:28:14 -04:00
|
|
|
id 'java' // for constants, packages, javadoc
|
2022-04-15 18:17:53 -04:00
|
|
|
id 'de.undercouch.download' version '4.1.2'
|
2018-12-08 07:32:48 -05:00
|
|
|
id 'maven-publish'
|
2022-04-15 18:17:53 -04:00
|
|
|
id "com.diffplug.spotless" version "6.4.2"
|
2021-07-19 16:49:44 -04:00
|
|
|
id 'net.fabricmc.filament' version '0.3.0'
|
2018-12-08 07:32:48 -05:00
|
|
|
}
|
2018-10-27 10:16:43 -04:00
|
|
|
|
2022-07-06 11:47:34 -04:00
|
|
|
def minecraft_version = "1.19.1-pre3"
|
2016-09-09 08:47:32 -04:00
|
|
|
|
|
|
|
def ENV = System.getenv()
|
2020-11-06 18:33:17 -05:00
|
|
|
// Fetch build number from Github Actions
|
2018-11-15 11:57:32 -05:00
|
|
|
def build_number = ENV.BUILD_NUMBER ?: "local"
|
|
|
|
|
2019-04-10 12:20:44 -04:00
|
|
|
def yarnVersion = "${minecraft_version}+build.$build_number"
|
2021-03-24 16:04:48 -04:00
|
|
|
version = yarnVersion
|
2016-09-09 08:47:32 -04:00
|
|
|
|
2021-04-28 18:13:10 -04:00
|
|
|
if (ENV.BRANCH_NAME) {
|
2021-04-28 18:16:02 -04:00
|
|
|
def branch = ENV.BRANCH_NAME.substring(ENV.BRANCH_NAME.lastIndexOf('/') + 1)
|
2021-04-28 14:42:32 -04:00
|
|
|
if (minecraft_version != branch) {
|
|
|
|
throw new IllegalStateException("Branch name (${branch}) does not match the mc version (${minecraft_version})")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 07:32:48 -05:00
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
maven {
|
2019-06-28 17:55:20 -04:00
|
|
|
name "Fabric Repository"
|
|
|
|
url 'https://maven.fabricmc.net'
|
2018-12-08 07:32:48 -05:00
|
|
|
}
|
2020-10-31 15:02:53 -04:00
|
|
|
maven {
|
|
|
|
name "Mojang"
|
|
|
|
url 'https://libraries.minecraft.net/'
|
|
|
|
}
|
2021-03-24 16:04:48 -04:00
|
|
|
mavenLocal()
|
2018-12-08 07:32:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
configurations {
|
2022-04-20 13:41:28 -04:00
|
|
|
asm
|
|
|
|
enigmaRuntime {
|
|
|
|
extendsFrom asm
|
|
|
|
}
|
2020-04-07 16:13:29 -04:00
|
|
|
javadocClasspath
|
2020-10-31 15:02:53 -04:00
|
|
|
decompileClasspath
|
2021-01-21 13:44:55 -05:00
|
|
|
mappingPoetJar {
|
|
|
|
transitive = false
|
|
|
|
}
|
|
|
|
mappingPoet {
|
|
|
|
extendsFrom mappingPoetJar
|
2022-04-20 14:45:02 -04:00
|
|
|
extendsFrom asm
|
2021-01-21 13:44:55 -05:00
|
|
|
transitive = true
|
|
|
|
}
|
2022-04-20 13:41:28 -04:00
|
|
|
unpick {
|
|
|
|
extendsFrom asm
|
|
|
|
}
|
2018-12-08 07:32:48 -05:00
|
|
|
}
|
|
|
|
|
2021-03-24 16:04:48 -04:00
|
|
|
def unpickMetaFile = file("unpick-definitions/unpick.json")
|
|
|
|
|
2018-12-08 07:32:48 -05:00
|
|
|
dependencies {
|
2021-10-13 14:29:39 -04:00
|
|
|
enigmaRuntime "cuchaz:enigma-swing:${project.enigma_version}"
|
2021-09-28 11:17:36 -04:00
|
|
|
enigmaRuntime "net.fabricmc:name-proposal:${project.name_proposal_version}"
|
2021-01-26 08:10:08 -05:00
|
|
|
javadocClasspath "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
|
2021-02-23 10:40:14 -05:00
|
|
|
javadocClasspath "org.jetbrains:annotations:${project.jetbrains_annotations_version}"
|
2021-04-01 03:49:22 -04:00
|
|
|
javadocClasspath "com.google.code.findbugs:jsr305:3.0.2" // for some other jsr annotations
|
2021-04-24 05:07:59 -04:00
|
|
|
decompileClasspath "net.fabricmc:cfr:${project.cfr_version}"
|
2021-06-07 09:44:50 -04:00
|
|
|
mappingPoetJar "net.fabricmc:mappingpoet:${project.mappingpoet_version}"
|
2021-03-26 15:04:22 -04:00
|
|
|
unpick "net.fabricmc.unpick:unpick-cli:${project.unpick_version}"
|
2022-04-20 13:41:28 -04:00
|
|
|
asm "org.ow2.asm:asm:${project.asm_version}"
|
|
|
|
asm "org.ow2.asm:asm-tree:${project.asm_version}"
|
|
|
|
asm "org.ow2.asm:asm-commons:${project.asm_version}"
|
|
|
|
asm "org.ow2.asm:asm-util:${project.asm_version}"
|
2018-12-08 07:32:48 -05:00
|
|
|
}
|
|
|
|
|
2019-05-12 21:45:52 -04:00
|
|
|
def setupGroup = "jar setup"
|
|
|
|
def yarnGroup = "yarn"
|
|
|
|
def buildMappingGroup = "mapping build"
|
|
|
|
def mapJarGroup = "jar mapping"
|
2018-10-27 10:16:43 -04:00
|
|
|
def mappingsDir = file("mappings")
|
|
|
|
def cacheFilesMinecraft = file(".gradle/minecraft")
|
2018-10-31 09:05:19 -04:00
|
|
|
def tempDir = file(".gradle/temp")
|
2018-10-27 10:16:43 -04:00
|
|
|
def mergedFile = file("${minecraft_version}-merged.jar")
|
2019-01-09 15:28:08 -05:00
|
|
|
def intermediaryJar = file("${minecraft_version}-intermediary.jar")
|
2021-03-24 16:04:48 -04:00
|
|
|
def unpickedJar = file("${minecraft_version}-intermediary-unpicked.jar")
|
2019-01-09 15:28:08 -05:00
|
|
|
def namedJar = file("${minecraft_version}-named.jar")
|
2018-10-27 10:16:43 -04:00
|
|
|
def versionFile = new File(cacheFilesMinecraft, "${minecraft_version}.json")
|
|
|
|
def clientJar = new File(cacheFilesMinecraft, "${minecraft_version}-client.jar")
|
2021-09-29 14:08:30 -04:00
|
|
|
// The vanilla server bootstrap jar (Contains the real server jar)
|
|
|
|
def serverBootstrapJar = new File(cacheFilesMinecraft, "${minecraft_version}-serverboostrap.jar")
|
|
|
|
// The real server jar, expected from the bootstrap
|
2018-10-27 10:16:43 -04:00
|
|
|
def serverJar = new File(cacheFilesMinecraft, "${minecraft_version}-server.jar")
|
2022-05-27 07:06:56 -04:00
|
|
|
def serverIntermediaryJar = file("${minecraft_version}-server-intermediary.jar")
|
2019-06-28 17:55:20 -04:00
|
|
|
def libraries = new File(cacheFilesMinecraft, "libraries")
|
2018-10-30 07:29:43 -04:00
|
|
|
def libs = new File("build/libs/")
|
2019-11-07 06:38:33 -05:00
|
|
|
|
|
|
|
import com.google.common.hash.Hashing
|
2019-06-28 16:12:16 -04:00
|
|
|
import cuchaz.enigma.command.CheckMappingsCommand
|
2019-06-28 17:55:20 -04:00
|
|
|
import cuchaz.enigma.command.ComposeMappingsCommand
|
2019-06-28 16:12:16 -04:00
|
|
|
import cuchaz.enigma.command.ConvertMappingsCommand
|
2019-11-24 05:53:08 -05:00
|
|
|
import cuchaz.enigma.command.MapSpecializedMethodsCommand
|
2019-05-12 21:45:52 -04:00
|
|
|
import groovy.io.FileType
|
|
|
|
import groovy.json.JsonSlurper
|
2018-10-31 12:54:00 -04:00
|
|
|
import net.fabricmc.stitch.commands.CommandMergeTiny
|
2019-06-28 18:17:32 -04:00
|
|
|
import net.fabricmc.stitch.commands.CommandReorderTiny
|
2019-04-18 17:22:36 -04:00
|
|
|
import net.fabricmc.stitch.commands.CommandRewriteIntermediary
|
2020-03-09 15:28:16 -04:00
|
|
|
import net.fabricmc.stitch.commands.tinyv2.CommandMergeTinyV2
|
|
|
|
import net.fabricmc.stitch.commands.tinyv2.CommandReorderTinyV2
|
2018-10-31 12:53:07 -04:00
|
|
|
import net.fabricmc.stitch.merge.JarMerger
|
2018-10-27 10:16:43 -04:00
|
|
|
import net.fabricmc.tinyremapper.OutputConsumerPath
|
|
|
|
import net.fabricmc.tinyremapper.TinyRemapper
|
|
|
|
import net.fabricmc.tinyremapper.TinyUtils
|
2021-09-28 11:17:36 -04:00
|
|
|
import net.fabricmc.nameproposal.MappingNameCompleter
|
2019-05-12 21:45:52 -04:00
|
|
|
import org.apache.commons.io.FileUtils
|
2021-09-24 08:06:15 -04:00
|
|
|
import org.objectweb.asm.ClassVisitor
|
|
|
|
import org.objectweb.asm.FieldVisitor
|
2021-09-20 08:00:25 -04:00
|
|
|
import org.objectweb.asm.Opcodes;
|
2019-05-12 21:45:52 -04:00
|
|
|
|
2019-06-29 07:08:36 -04:00
|
|
|
import java.nio.charset.StandardCharsets
|
2018-11-15 11:57:32 -05:00
|
|
|
import java.util.zip.GZIPOutputStream
|
2016-08-17 15:23:28 -04:00
|
|
|
|
|
|
|
boolean validateChecksum(File file, String checksum) {
|
|
|
|
if (file != null) {
|
2019-11-07 06:38:33 -05:00
|
|
|
def hash = com.google.common.io.Files.asByteSource(file).hash(Hashing.sha1())
|
2016-08-17 15:23:28 -04:00
|
|
|
def builder = new StringBuilder()
|
|
|
|
hash.asBytes().each {
|
|
|
|
builder.append(Integer.toString((it & 0xFF) + 0x100, 16).substring(1))
|
|
|
|
}
|
|
|
|
return builder.toString().equals(checksum)
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-10-27 10:16:43 -04:00
|
|
|
task downloadVersionsManifest {
|
2019-05-12 21:45:52 -04:00
|
|
|
group = setupGroup
|
2018-10-27 10:16:43 -04:00
|
|
|
//inputs.property "mc_ver", minecraft_version
|
|
|
|
inputs.property "currenttime", new Date()
|
2021-07-10 07:28:14 -04:00
|
|
|
def manifestFile = new File(cacheFilesMinecraft, "version_manifest_v2.json")
|
2018-10-27 10:16:43 -04:00
|
|
|
outputs.file(manifestFile)
|
|
|
|
doLast {
|
|
|
|
logger.lifecycle(":downloading minecraft versions manifest")
|
2022-06-21 14:24:55 -04:00
|
|
|
FileUtils.copyURLToFile(new URL("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json"), manifestFile)
|
2018-10-27 10:16:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def getManifestVersion(File manifestFile, String minecraft_version) {
|
|
|
|
def manifest = manifestFile.exists() ? new JsonSlurper().parseText(FileUtils.readFileToString(manifestFile)) : null
|
2019-11-07 06:38:33 -05:00
|
|
|
return manifest != null ? manifest.versions.stream().filter({
|
|
|
|
it.id.equals(minecraft_version)
|
|
|
|
}).findFirst() : java.util.Optional.empty()
|
2018-10-27 10:16:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
task downloadWantedVersionManifest(dependsOn: downloadVersionsManifest) {
|
2019-05-12 21:45:52 -04:00
|
|
|
group = setupGroup
|
2018-10-27 10:16:43 -04:00
|
|
|
def manifestFile = downloadVersionsManifest.outputs.files.singleFile
|
|
|
|
def manifestVersion = getManifestVersion(manifestFile, minecraft_version)
|
|
|
|
|
|
|
|
//have to grab the release time as there's a current timestamp on each element?!
|
|
|
|
inputs.property "releaseTime", manifestVersion.isPresent() ? manifestVersion.get().releaseTime : -1
|
|
|
|
|
|
|
|
outputs.file versionFile
|
|
|
|
|
|
|
|
doLast {
|
2019-11-07 06:38:33 -05:00
|
|
|
manifestVersion = getManifestVersion(manifestFile, minecraft_version)
|
|
|
|
//nb need to re-read here in case it didn't exist before
|
2018-10-27 10:16:43 -04:00
|
|
|
if (manifestVersion.isPresent() || versionFile.exists()) {
|
|
|
|
|
|
|
|
if (manifestVersion.isPresent()) {
|
|
|
|
FileUtils.copyURLToFile(new URL(manifestVersion.get().url), versionFile)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
throw new RuntimeException("No version data for Minecraft version ${minecraft_version}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2016-08-17 15:23:28 -04:00
|
|
|
|
2018-10-27 10:16:43 -04:00
|
|
|
task downloadMcJars(dependsOn: downloadWantedVersionManifest) {
|
2019-05-12 21:45:52 -04:00
|
|
|
group = setupGroup
|
2018-10-27 10:16:43 -04:00
|
|
|
inputs.files versionFile
|
2016-08-17 15:23:28 -04:00
|
|
|
|
2021-09-29 14:08:30 -04:00
|
|
|
outputs.files(clientJar, serverBootstrapJar)
|
2016-08-17 15:23:28 -04:00
|
|
|
|
2018-10-27 10:16:43 -04:00
|
|
|
outputs.upToDateWhen {
|
2016-08-17 15:23:28 -04:00
|
|
|
def version = new JsonSlurper().parseText(FileUtils.readFileToString(versionFile))
|
2021-09-29 14:08:30 -04:00
|
|
|
return clientJar.exists() && serverBootstrapJar.exists() && validateChecksum(clientJar, version.downloads.client.sha1) && validateChecksum(serverBootstrapJar, version.downloads.server.sha1)
|
2018-10-27 10:16:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
doLast {
|
|
|
|
if (!versionFile.exists()) {
|
|
|
|
throw new RuntimeException("Can't download the jars without the ${versionFile.name} file!")
|
|
|
|
}
|
2016-08-17 15:23:28 -04:00
|
|
|
|
2018-10-27 10:16:43 -04:00
|
|
|
//reload in case it changed
|
|
|
|
def version = new JsonSlurper().parseText(FileUtils.readFileToString(versionFile))
|
|
|
|
|
|
|
|
logger.lifecycle(":downloading minecraft jars")
|
2016-08-17 15:23:28 -04:00
|
|
|
|
2020-03-09 15:28:16 -04:00
|
|
|
download {
|
|
|
|
src new URL(version.downloads.client.url)
|
|
|
|
dest clientJar
|
|
|
|
overwrite false
|
2016-08-17 15:23:28 -04:00
|
|
|
}
|
|
|
|
|
2020-03-09 15:28:16 -04:00
|
|
|
download {
|
|
|
|
src new URL(version.downloads.server.url)
|
2021-09-29 14:08:30 -04:00
|
|
|
dest serverBootstrapJar
|
2020-03-09 15:28:16 -04:00
|
|
|
overwrite false
|
2016-08-17 15:23:28 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-07 13:12:34 -05:00
|
|
|
task downloadIntermediary(type: Download) {
|
2019-06-28 17:55:20 -04:00
|
|
|
group = buildMappingGroup
|
2019-11-07 13:12:34 -05:00
|
|
|
def url = "https://github.com/FabricMC/intermediary/raw/master/mappings/${minecraft_version}.tiny"
|
2019-11-07 13:15:42 -05:00
|
|
|
src com.google.common.net.UrlEscapers.urlFragmentEscaper().escape(url)
|
2019-11-07 13:12:34 -05:00
|
|
|
dest new File(cacheFilesMinecraft, "${minecraft_version}-intermediary.tiny")
|
2019-06-28 17:55:20 -04:00
|
|
|
}
|
|
|
|
|
2020-03-09 15:28:16 -04:00
|
|
|
task downloadIntermediaryV2(type: Download) {
|
|
|
|
group = buildMappingGroup
|
|
|
|
def url = "https://maven.fabricmc.net/net/fabricmc/intermediary/${minecraft_version}/intermediary-${minecraft_version}-v2.jar"
|
|
|
|
src com.google.common.net.UrlEscapers.urlFragmentEscaper().escape(url)
|
|
|
|
dest new File(cacheFilesMinecraft, "${minecraft_version}-intermediary-v2.jar")
|
|
|
|
|
|
|
|
def output = new File(cacheFilesMinecraft, "${minecraft_version}-intermediary-v2.tiny")
|
2021-07-10 07:28:14 -04:00
|
|
|
outputs.file output
|
|
|
|
|
|
|
|
doLast {
|
|
|
|
copy {
|
|
|
|
from({ zipTree(downloadIntermediaryV2.dest) }) {
|
|
|
|
from 'mappings/mappings.tiny'
|
|
|
|
rename 'mappings.tiny', "../${output.name}"
|
|
|
|
}
|
|
|
|
|
|
|
|
into output.parentFile
|
|
|
|
}
|
2020-03-09 15:28:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-29 14:08:30 -04:00
|
|
|
import java.util.zip.ZipFile
|
|
|
|
|
|
|
|
// Extracts the real server jar from the boostrap jar
|
|
|
|
task extractServerJar(dependsOn: downloadMcJars) {
|
|
|
|
group = setupGroup
|
|
|
|
inputs.file serverBootstrapJar
|
|
|
|
outputs.file serverJar
|
|
|
|
|
|
|
|
doLast {
|
|
|
|
new ZipFile(serverBootstrapJar as File).withCloseable { zip ->
|
2021-11-11 13:17:23 -05:00
|
|
|
def serverVersionsEntry = zip.getEntry("META-INF/versions.list")
|
2021-09-29 14:08:30 -04:00
|
|
|
|
2021-11-11 13:17:23 -05:00
|
|
|
if (!serverVersionsEntry) {
|
|
|
|
throw new RuntimeException("Could not find versions.list")
|
2021-09-29 14:08:30 -04:00
|
|
|
}
|
|
|
|
|
2021-11-11 13:17:23 -05:00
|
|
|
def jarPath = null
|
|
|
|
|
|
|
|
zip.getInputStream(serverVersionsEntry).withCloseable { is ->
|
|
|
|
def versions = is.text.split("\t")
|
|
|
|
assert versions.length == 3
|
|
|
|
jarPath = versions[2]
|
|
|
|
}
|
|
|
|
|
|
|
|
def serverJarEntry = zip.getEntry("META-INF/versions/${jarPath}")
|
|
|
|
|
|
|
|
if (!serverJarEntry) {
|
|
|
|
throw new RuntimeException("Failed to find server jar entry ${jarPath}")
|
|
|
|
}
|
|
|
|
|
|
|
|
zip.getInputStream(serverJarEntry).withCloseable { is ->
|
2021-09-29 14:08:30 -04:00
|
|
|
serverJar.bytes = is.readAllBytes()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task mergeJars(dependsOn: extractServerJar) {
|
2019-05-12 21:45:52 -04:00
|
|
|
group = setupGroup
|
2021-09-29 14:08:30 -04:00
|
|
|
inputs.files (serverJar, clientJar)
|
2018-10-27 10:16:43 -04:00
|
|
|
outputs.file(mergedFile)
|
2016-08-17 15:23:28 -04:00
|
|
|
|
2018-10-27 10:16:43 -04:00
|
|
|
doLast {
|
|
|
|
logger.lifecycle(":merging jars")
|
2016-08-17 15:23:28 -04:00
|
|
|
|
2021-09-29 14:08:30 -04:00
|
|
|
if (mergedFile.exists()) {
|
2019-01-16 13:37:56 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-09-29 19:55:48 -04:00
|
|
|
def jarMerger = new JarMerger(clientJar, serverJar, mergedFile)
|
2016-08-17 15:23:28 -04:00
|
|
|
jarMerger.merge()
|
|
|
|
jarMerger.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-06-28 17:55:20 -04:00
|
|
|
task downloadMcLibs(dependsOn: downloadWantedVersionManifest) {
|
|
|
|
group = setupGroup
|
|
|
|
inputs.files versionFile
|
|
|
|
|
2019-07-02 17:36:55 -04:00
|
|
|
outputs.dir(libraries)
|
2019-06-28 17:55:20 -04:00
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
outputs.upToDateWhen { false }
|
2016-08-17 15:23:28 -04:00
|
|
|
|
2018-10-27 10:16:43 -04:00
|
|
|
doLast {
|
2019-06-28 17:55:20 -04:00
|
|
|
if (!versionFile.exists()) {
|
|
|
|
throw new RuntimeException("Can't download the jars without the ${versionFile.name} file!")
|
|
|
|
}
|
|
|
|
|
2019-06-29 07:08:36 -04:00
|
|
|
def version = new JsonSlurper().parseText(FileUtils.readFileToString(versionFile, StandardCharsets.UTF_8))
|
2019-06-28 17:55:20 -04:00
|
|
|
|
|
|
|
logger.lifecycle(":downloading minecraft libraries")
|
|
|
|
|
|
|
|
if (!libraries.exists()) {
|
|
|
|
libraries.mkdirs()
|
|
|
|
}
|
|
|
|
|
|
|
|
version.libraries.each {
|
2022-05-04 14:34:27 -04:00
|
|
|
if (it.downloads.artifact == null) return // TODO: happens for downloads.classifiers - implement properly?
|
|
|
|
|
2019-06-28 17:55:20 -04:00
|
|
|
def downloadUrl = it.downloads.artifact.url
|
|
|
|
|
|
|
|
download {
|
|
|
|
src downloadUrl
|
|
|
|
dest new File(libraries, downloadUrl.substring(downloadUrl.lastIndexOf("/") + 1))
|
|
|
|
overwrite false
|
|
|
|
}
|
2020-10-31 15:02:53 -04:00
|
|
|
|
|
|
|
project.dependencies.add("decompileClasspath", it.name)
|
2018-10-27 10:16:43 -04:00
|
|
|
}
|
2016-08-17 15:23:28 -04:00
|
|
|
}
|
|
|
|
}
|
2016-09-08 18:42:45 -04:00
|
|
|
|
2019-11-07 13:12:34 -05:00
|
|
|
task invertIntermediary(dependsOn: downloadIntermediary, type: FileOutput) {
|
2019-05-12 21:45:52 -04:00
|
|
|
group = buildMappingGroup
|
2019-11-07 13:12:34 -05:00
|
|
|
def v1Input = downloadIntermediary.dest
|
2016-09-21 08:52:54 -04:00
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
output = new File(cacheFilesMinecraft, "${minecraft_version}-intermediary-inverted.tiny")
|
|
|
|
outputs.file(output)
|
2019-06-28 17:55:20 -04:00
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
outputs.upToDateWhen { false }
|
2016-10-19 04:58:14 -04:00
|
|
|
|
2019-06-28 17:55:20 -04:00
|
|
|
doLast {
|
|
|
|
logger.lifecycle(":building inverted intermediary")
|
2019-11-07 06:38:33 -05:00
|
|
|
|
|
|
|
String[] v1Args = [
|
|
|
|
v1Input.getAbsolutePath(),
|
|
|
|
output.getAbsolutePath(),
|
|
|
|
"intermediary", "official"
|
2018-10-27 10:16:43 -04:00
|
|
|
]
|
2016-10-19 04:58:14 -04:00
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
new CommandReorderTiny().run(v1Args)
|
2018-10-27 10:16:43 -04:00
|
|
|
}
|
2016-10-19 04:58:14 -04:00
|
|
|
}
|
|
|
|
|
2021-07-10 07:28:14 -04:00
|
|
|
task invertIntermediaryv2(dependsOn: downloadIntermediaryV2, type: FileOutput) {
|
2020-03-09 15:28:16 -04:00
|
|
|
group = buildMappingGroup
|
|
|
|
def v2Input = new File(cacheFilesMinecraft, "${minecraft_version}-intermediary-v2.tiny")
|
|
|
|
|
|
|
|
output = new File(cacheFilesMinecraft, "${minecraft_version}-intermediary-inverted-v2.tiny")
|
|
|
|
outputs.file(output)
|
|
|
|
|
|
|
|
outputs.upToDateWhen { false }
|
|
|
|
|
|
|
|
doLast {
|
|
|
|
logger.lifecycle(":building inverted intermediary v2")
|
|
|
|
|
|
|
|
String[] v2Args = [
|
|
|
|
v2Input.getAbsolutePath(),
|
|
|
|
output.getAbsolutePath(),
|
|
|
|
"intermediary", "official"
|
|
|
|
]
|
|
|
|
|
|
|
|
new CommandReorderTinyV2().run(v2Args)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-07 13:12:34 -05:00
|
|
|
task patchIntermediary(dependsOn: [mergeJars, downloadIntermediary]) {
|
2019-05-12 21:45:52 -04:00
|
|
|
group = buildMappingGroup
|
2020-03-09 15:28:16 -04:00
|
|
|
def intermediaryTinyInput = downloadIntermediary.outputs.files.singleFile
|
2019-04-18 17:22:36 -04:00
|
|
|
|
|
|
|
def outputFile = new File(cacheFilesMinecraft, "${minecraft_version}-intermediary-full.tiny")
|
|
|
|
outputs.file(outputFile)
|
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
outputs.upToDateWhen { false }
|
2019-04-18 17:22:36 -04:00
|
|
|
|
|
|
|
doLast {
|
|
|
|
logger.lifecycle(":patching intermediary")
|
|
|
|
String[] args = [
|
2019-11-07 06:38:33 -05:00
|
|
|
mergedFile.getAbsolutePath(),
|
|
|
|
intermediaryTinyInput.getAbsolutePath(),
|
|
|
|
outputFile.getAbsolutePath(),
|
|
|
|
"--writeAll"
|
2019-04-18 17:22:36 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
new CommandRewriteIntermediary().run(args)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-07 13:12:34 -05:00
|
|
|
task mapIntermediaryJar(dependsOn: [downloadMcLibs, downloadIntermediary, mergeJars]) {
|
2019-06-28 17:55:20 -04:00
|
|
|
group = mapJarGroup
|
|
|
|
inputs.files downloadMcLibs.outputs.files.files
|
|
|
|
outputs.file(intermediaryJar)
|
|
|
|
|
|
|
|
//Force the task to always run
|
2019-11-07 06:38:33 -05:00
|
|
|
outputs.upToDateWhen { false }
|
2019-06-28 17:55:20 -04:00
|
|
|
|
|
|
|
doLast {
|
|
|
|
logger.lifecycle(":mapping minecraft to intermediary")
|
2019-11-07 13:12:34 -05:00
|
|
|
def tinyInput = downloadIntermediary.dest
|
2021-11-22 13:18:04 -05:00
|
|
|
mapJar(intermediaryJar, mergedFile, tinyInput, libraries, "official", "intermediary")
|
2019-06-28 17:55:20 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-27 07:06:56 -04:00
|
|
|
task mapServerIntermediaryJar(dependsOn: [downloadMcLibs, downloadIntermediary, extractServerJar]) {
|
|
|
|
group = mapJarGroup
|
|
|
|
inputs.files downloadMcLibs.outputs.files.files
|
|
|
|
outputs.file(serverIntermediaryJar)
|
2021-09-16 16:03:56 -04:00
|
|
|
|
2022-05-27 07:06:56 -04:00
|
|
|
//Force the task to always run
|
|
|
|
outputs.upToDateWhen { false }
|
2021-09-16 16:03:56 -04:00
|
|
|
|
2022-05-27 07:06:56 -04:00
|
|
|
doLast {
|
|
|
|
logger.lifecycle(":mapping minecraft server to intermediary")
|
|
|
|
def tinyInput = downloadIntermediary.dest
|
|
|
|
mapJar(serverIntermediaryJar, serverJar, tinyInput, libraries, "official", "intermediary")
|
|
|
|
}
|
2019-06-28 17:55:20 -04:00
|
|
|
}
|
|
|
|
|
2022-05-27 07:06:56 -04:00
|
|
|
task yarnUnpicked(dependsOn: "unpickIntermediaryJar", type: EnigmaTask) {
|
2019-06-28 17:55:20 -04:00
|
|
|
group = yarnGroup
|
2022-05-27 07:06:56 -04:00
|
|
|
jar = unpickedJar
|
|
|
|
mappings = mappingsDir
|
|
|
|
}
|
2021-09-16 16:03:56 -04:00
|
|
|
|
2022-05-27 07:06:56 -04:00
|
|
|
task yarn(dependsOn: mapIntermediaryJar, type: EnigmaTask) {
|
|
|
|
group = yarnGroup
|
|
|
|
jar = intermediaryJar
|
|
|
|
mappings = mappingsDir
|
|
|
|
}
|
2021-09-16 16:03:56 -04:00
|
|
|
|
2022-05-27 07:06:56 -04:00
|
|
|
task yarnCommon(dependsOn: mapServerIntermediaryJar, type: EnigmaTask) {
|
|
|
|
group = yarnGroup
|
|
|
|
jar = serverIntermediaryJar
|
|
|
|
mappings = mappingsDir
|
2019-06-28 17:55:20 -04:00
|
|
|
}
|
|
|
|
|
2021-03-30 17:39:16 -04:00
|
|
|
task checkMappings(dependsOn: mapIntermediaryJar) {
|
2019-06-28 17:55:20 -04:00
|
|
|
group = buildMappingGroup
|
|
|
|
inputs.dir mappingsDir
|
|
|
|
doLast {
|
|
|
|
logger.lifecycle(":checking mappings")
|
|
|
|
|
|
|
|
String[] args = [
|
2021-02-13 17:57:02 -05:00
|
|
|
intermediaryJar.getAbsolutePath(),
|
2019-11-07 06:38:33 -05:00
|
|
|
mappingsDir.getAbsolutePath()
|
2019-06-28 17:55:20 -04:00
|
|
|
]
|
|
|
|
|
2021-02-13 17:57:02 -05:00
|
|
|
try {
|
|
|
|
new CheckMappingsCommand().run(args)
|
|
|
|
} catch (IllegalStateException ignored) {
|
|
|
|
// just print, don't fail the task
|
|
|
|
}
|
2019-06-28 17:55:20 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-24 05:53:08 -05:00
|
|
|
task buildYarnTiny(dependsOn: mapIntermediaryJar, type: WithV2FileOutput) {
|
2019-05-12 21:45:52 -04:00
|
|
|
group = buildMappingGroup
|
2018-10-27 10:16:43 -04:00
|
|
|
inputs.dir mappingsDir
|
|
|
|
if (!libs.exists()) {
|
|
|
|
libs.mkdirs()
|
|
|
|
}
|
2018-10-31 09:05:19 -04:00
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
v1Output = new File(tempDir, "yarn-mappings.tiny")
|
|
|
|
v2Output = new File(tempDir, "yarn-mappings-v2.tiny")
|
|
|
|
|
|
|
|
outputs.upToDateWhen { false }
|
2018-10-31 09:05:19 -04:00
|
|
|
|
2018-10-27 10:16:43 -04:00
|
|
|
doLast {
|
|
|
|
logger.lifecycle(":generating tiny mappings")
|
|
|
|
|
2019-11-24 05:53:08 -05:00
|
|
|
new MapSpecializedMethodsCommand().run(
|
|
|
|
intermediaryJar.getAbsolutePath(),
|
|
|
|
"enigma",
|
|
|
|
mappingsDir.getAbsolutePath(),
|
|
|
|
"tinyv2:intermediary:named",
|
|
|
|
v2Output.getAbsolutePath()
|
|
|
|
)
|
|
|
|
|
|
|
|
new ConvertMappingsCommand().run(
|
|
|
|
"tinyv2",
|
|
|
|
v2Output.getAbsolutePath(),
|
|
|
|
"tiny:intermediary:named",
|
|
|
|
v1Output.getAbsolutePath())
|
2018-10-31 09:05:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-28 17:55:20 -04:00
|
|
|
task mergeTiny(dependsOn: ["buildYarnTiny", "invertIntermediary"], type: FileOutput) {
|
2019-05-12 21:45:52 -04:00
|
|
|
group = buildMappingGroup
|
2019-11-07 06:38:33 -05:00
|
|
|
def yarnTinyInput = buildYarnTiny.v1Output
|
|
|
|
def intermediaryTinyInput = invertIntermediary.output
|
2018-10-31 09:05:19 -04:00
|
|
|
|
2019-06-28 18:17:32 -04:00
|
|
|
def unorderedResultMappings = new File(tempDir, "mappings-unordered.tiny")
|
2019-11-07 06:38:33 -05:00
|
|
|
output = new File(tempDir, "mappings.tiny")
|
|
|
|
outputs.file(output)
|
2018-10-31 09:05:19 -04:00
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
outputs.upToDateWhen { false }
|
2018-10-27 10:16:43 -04:00
|
|
|
|
2018-10-31 09:05:19 -04:00
|
|
|
doLast {
|
2018-12-09 16:14:34 -05:00
|
|
|
logger.lifecycle(":merging yarn and intermediary")
|
2018-10-31 09:05:19 -04:00
|
|
|
String[] args = [
|
2019-11-07 06:38:33 -05:00
|
|
|
intermediaryTinyInput.getAbsolutePath(),
|
|
|
|
yarnTinyInput.getAbsolutePath(),
|
|
|
|
unorderedResultMappings.getAbsolutePath(),
|
|
|
|
"intermediary",
|
|
|
|
"official"
|
2018-10-31 09:05:19 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
new CommandMergeTiny().run(args)
|
2019-06-28 18:17:32 -04:00
|
|
|
|
|
|
|
logger.lifecycle(":reordering merged intermediary")
|
|
|
|
String[] args2 = [
|
2019-11-07 06:38:33 -05:00
|
|
|
unorderedResultMappings.getAbsolutePath(),
|
|
|
|
output.getAbsolutePath(),
|
|
|
|
"official", "intermediary", "named"
|
2019-06-28 18:17:32 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
new CommandReorderTiny().run(args2)
|
2018-10-31 09:05:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
task tinyJar(type: Jar, dependsOn: mergeTiny) {
|
2019-05-12 21:45:52 -04:00
|
|
|
group = buildMappingGroup
|
2019-11-07 06:38:33 -05:00
|
|
|
outputs.upToDateWhen { false }
|
2019-12-11 06:52:21 -05:00
|
|
|
archiveFileName = "yarn-${yarnVersion}.jar"
|
|
|
|
destinationDirectory.set(file("build/libs"))
|
2018-11-02 12:02:21 -04:00
|
|
|
classifier = ""
|
2019-11-07 06:38:33 -05:00
|
|
|
from(mergeTiny.output) {
|
2018-11-02 11:07:46 -04:00
|
|
|
rename { "mappings/mappings.tiny" }
|
|
|
|
}
|
2022-01-02 13:54:44 -05:00
|
|
|
manifest {
|
|
|
|
attributes("Minecraft-Version-Id": minecraft_version)
|
|
|
|
}
|
2018-11-02 11:07:46 -04:00
|
|
|
}
|
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
task compressTiny(dependsOn: [tinyJar, mergeTiny], type: FileOutput) {
|
2019-05-12 21:45:52 -04:00
|
|
|
group = buildMappingGroup
|
2018-12-09 16:14:34 -05:00
|
|
|
def outputFile = new File(libs, "yarn-tiny-${yarnVersion}.gz")
|
2018-10-31 09:05:19 -04:00
|
|
|
outputs.file(outputFile)
|
2019-11-07 06:38:33 -05:00
|
|
|
output = outputFile
|
2018-10-31 09:05:19 -04:00
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
def inputFile = mergeTiny.output
|
2018-10-27 10:16:43 -04:00
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
outputs.upToDateWhen { false }
|
2018-10-31 09:05:19 -04:00
|
|
|
|
|
|
|
doLast {
|
2018-10-27 10:16:43 -04:00
|
|
|
logger.lifecycle(":compressing tiny mappings")
|
|
|
|
|
|
|
|
def buffer = new byte[1024]
|
|
|
|
def fileOutputStream = new FileOutputStream(outputFile)
|
|
|
|
def outputStream = new GZIPOutputStream(fileOutputStream)
|
|
|
|
def fileInputStream = new FileInputStream(inputFile)
|
|
|
|
|
|
|
|
def length
|
|
|
|
while ((length = fileInputStream.read(buffer)) > 0) {
|
|
|
|
outputStream.write(buffer, 0, length)
|
|
|
|
}
|
|
|
|
|
|
|
|
fileInputStream.close()
|
|
|
|
outputStream.finish()
|
|
|
|
outputStream.close()
|
|
|
|
}
|
|
|
|
}
|
2016-09-21 08:52:54 -04:00
|
|
|
|
2018-11-02 12:17:55 -04:00
|
|
|
clean.doFirst {
|
|
|
|
delete tempDir, cacheFilesMinecraft
|
|
|
|
}
|
|
|
|
|
2022-04-20 14:45:02 -04:00
|
|
|
tasks.build.dependsOn "compressTiny","tinyJar","v2UnmergedYarnJar", "v2MergedYarnJar", "javadocJar"
|
2016-10-02 11:58:41 -04:00
|
|
|
|
2019-11-07 13:12:34 -05:00
|
|
|
task exportMappingsOfficial(dependsOn: downloadIntermediary) {
|
|
|
|
def composeInput = downloadIntermediary.dest
|
2018-10-27 10:37:37 -04:00
|
|
|
|
2018-10-27 10:16:43 -04:00
|
|
|
doLast {
|
2019-06-28 17:55:20 -04:00
|
|
|
logger.lifecycle(":exporting mappings")
|
|
|
|
String[] args = [
|
2019-11-07 06:38:33 -05:00
|
|
|
"tiny",
|
|
|
|
composeInput.getAbsolutePath(),
|
|
|
|
"enigma",
|
|
|
|
file("mappings/").getAbsolutePath(),
|
|
|
|
"enigma",
|
|
|
|
file("mappings_official/").getAbsolutePath(),
|
|
|
|
"right"
|
2019-06-28 17:55:20 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
new ComposeMappingsCommand().run(args)
|
2019-01-09 15:28:08 -05:00
|
|
|
}
|
|
|
|
}
|
2018-10-27 10:16:43 -04:00
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
task importMappingsOfficial(dependsOn: invertIntermediary) {
|
|
|
|
def composeInput = invertIntermediary.output
|
2018-10-27 10:16:43 -04:00
|
|
|
|
2019-01-09 15:28:08 -05:00
|
|
|
doLast {
|
2019-06-28 17:55:20 -04:00
|
|
|
logger.lifecycle(":importing mappings")
|
|
|
|
String[] args = [
|
2019-11-07 06:38:33 -05:00
|
|
|
"tiny",
|
|
|
|
composeInput.getAbsolutePath(),
|
|
|
|
"enigma",
|
|
|
|
file("mappings_official/").getAbsolutePath(),
|
|
|
|
"enigma",
|
|
|
|
file("mappings/").getAbsolutePath(),
|
|
|
|
"right"
|
2019-06-28 17:55:20 -04:00
|
|
|
]
|
2018-10-27 10:16:43 -04:00
|
|
|
|
2019-06-28 17:55:20 -04:00
|
|
|
new ComposeMappingsCommand().run(args)
|
2018-10-27 10:16:43 -04:00
|
|
|
}
|
2018-10-31 12:53:07 -04:00
|
|
|
}
|
2018-10-30 07:29:43 -04:00
|
|
|
|
2021-03-24 16:04:48 -04:00
|
|
|
task mapNamedJar(dependsOn: ["mergeV2", "unpickIntermediaryJar"]) {
|
2019-05-12 21:45:52 -04:00
|
|
|
group = mapJarGroup
|
|
|
|
inputs.files downloadMcLibs.outputs.files.files
|
|
|
|
outputs.file(namedJar)
|
|
|
|
|
|
|
|
//Force the task to always run
|
|
|
|
outputs.upToDateWhen { false }
|
|
|
|
|
2021-02-23 10:40:14 -05:00
|
|
|
def jsrToJetbrains = [
|
|
|
|
"javax/annotation/Nullable": "org/jetbrains/annotations/Nullable",
|
|
|
|
"javax/annotation/Nonnull": "org/jetbrains/annotations/NotNull",
|
|
|
|
"javax/annotation/concurrent/Immutable": "org/jetbrains/annotations/Unmodifiable"
|
|
|
|
]
|
|
|
|
|
2019-05-12 21:45:52 -04:00
|
|
|
doLast {
|
|
|
|
logger.lifecycle(":mapping minecraft to named")
|
|
|
|
|
2021-03-24 16:04:48 -04:00
|
|
|
mapJar(namedJar, unpickedJar, mergeV2.output, libraries, "intermediary", "named") {
|
2021-02-23 10:40:14 -05:00
|
|
|
it.withMappings { out ->
|
|
|
|
jsrToJetbrains.each { e ->
|
|
|
|
out.acceptClass e.key, e.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-07 06:38:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-14 11:26:02 -04:00
|
|
|
combineUnpickDefinitions {
|
|
|
|
group = 'unpick'
|
|
|
|
input = file('unpick-definitions')
|
|
|
|
output = new File(tempDir, 'definitions.unpick')
|
2021-03-24 16:04:48 -04:00
|
|
|
}
|
|
|
|
|
2021-05-14 11:26:02 -04:00
|
|
|
remapUnpickDefinitionsIntermediary {
|
|
|
|
dependsOn buildYarnTiny
|
|
|
|
group = 'unpick'
|
|
|
|
output = new File(tempDir, 'intermediary-definitions.unpick')
|
|
|
|
mappings = buildYarnTiny.v2Output
|
2021-03-24 16:04:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
task unpickIntermediaryJar(type: JavaExec, dependsOn: [mapIntermediaryJar, "constantsJar", remapUnpickDefinitionsIntermediary]) {
|
|
|
|
outputs.upToDateWhen { false }
|
|
|
|
group "unpick"
|
|
|
|
|
2021-07-10 07:28:14 -04:00
|
|
|
mainClass = "daomephsta.unpick.cli.Main"
|
2021-03-25 08:45:12 -04:00
|
|
|
systemProperty "java.util.logging.config.file", file('unpick-logging.properties')
|
2021-03-24 16:04:48 -04:00
|
|
|
classpath configurations.unpick
|
|
|
|
|
|
|
|
doFirst {
|
2021-05-14 11:26:02 -04:00
|
|
|
args intermediaryJar.absolutePath, unpickedJar.absolutePath, remapUnpickDefinitionsIntermediary.output.get().asFile.absolutePath, constantsJar.archiveFile.get().asFile.absolutePath
|
2021-03-24 16:04:48 -04:00
|
|
|
|
|
|
|
configurations.decompileClasspath.files.each {
|
|
|
|
args it.absolutePath
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup the build for the unpicked constants
|
|
|
|
|
2021-11-16 13:18:51 -05:00
|
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
|
|
targetCompatibility = JavaVersion.VERSION_17
|
2021-03-24 16:04:48 -04:00
|
|
|
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
|
|
it.options.encoding = "UTF-8"
|
2021-11-16 13:18:51 -05:00
|
|
|
it.options.release = 17
|
2021-03-24 16:04:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
constants
|
2021-03-30 17:39:16 -04:00
|
|
|
packageDocs // package info files
|
2021-03-24 16:04:48 -04:00
|
|
|
}
|
|
|
|
|
2022-04-15 18:17:53 -04:00
|
|
|
spotless {
|
|
|
|
java {
|
|
|
|
licenseHeaderFile(rootProject.file("HEADER"))
|
|
|
|
}
|
2021-03-28 15:33:12 -04:00
|
|
|
}
|
|
|
|
|
2021-03-24 16:04:48 -04:00
|
|
|
task constantsJar(type: Jar) {
|
|
|
|
from sourceSets.constants.output
|
|
|
|
archiveClassifier = "constants"
|
|
|
|
}
|
|
|
|
|
|
|
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
|
|
archiveClassifier = "sources"
|
|
|
|
from sourceSets.constants.allSource
|
|
|
|
}
|
|
|
|
|
2021-03-30 17:39:16 -04:00
|
|
|
// Only build jars for package infos if we need to actually expose stuff like annotation in the future.
|
|
|
|
|
2021-03-24 16:04:48 -04:00
|
|
|
build.dependsOn constantsJar
|
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
task insertAutoGeneratedEnumMappings(dependsOn : [buildYarnTiny,mapIntermediaryJar], type : FileOutput){
|
|
|
|
group = buildMappingGroup
|
2021-09-28 11:17:36 -04:00
|
|
|
File noEnumV2 = buildYarnTiny.v2Output
|
2019-11-07 06:38:33 -05:00
|
|
|
output = new File(tempDir, "unmerged-named-v2-with-enum.tiny")
|
|
|
|
|
|
|
|
outputs.upToDateWhen { false }
|
|
|
|
|
|
|
|
doLast {
|
|
|
|
logger.lifecycle(":seeking auto-mappable fields for unmerged mappings")
|
|
|
|
|
2021-09-28 11:17:36 -04:00
|
|
|
MappingNameCompleter.completeNames(
|
|
|
|
intermediaryJar.toPath(),
|
|
|
|
noEnumV2.toPath(),
|
|
|
|
downloadIntermediary.dest.toPath(),
|
|
|
|
output.toPath()
|
|
|
|
)
|
2019-11-07 06:38:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-09 15:28:16 -04:00
|
|
|
task mergeV2(dependsOn: ["v2UnmergedYarnJar", "invertIntermediaryv2"], type: FileOutput) {
|
|
|
|
def mergedV2 = new File(tempDir, "merged-v2.tiny");
|
|
|
|
|
|
|
|
output = new File(tempDir, "merged-reordered-v2.tiny")
|
|
|
|
outputs.upToDateWhen { false }
|
|
|
|
|
|
|
|
doLast {
|
|
|
|
logger.lifecycle(":merging yarn and intermediary v2")
|
|
|
|
String[] args = [
|
|
|
|
invertIntermediaryv2.output.getAbsolutePath(),
|
|
|
|
insertAutoGeneratedEnumMappings.output.getAbsolutePath(),
|
|
|
|
mergedV2.getAbsolutePath(),
|
|
|
|
"intermediary",
|
|
|
|
"official"
|
|
|
|
]
|
|
|
|
|
|
|
|
new CommandMergeTinyV2().run(args)
|
|
|
|
|
|
|
|
//Reorder the mappings to match the output of loom
|
|
|
|
args = [
|
|
|
|
mergedV2.getAbsolutePath(),
|
|
|
|
output.getAbsolutePath(),
|
|
|
|
"official",
|
|
|
|
"intermediary",
|
|
|
|
"named"
|
|
|
|
]
|
|
|
|
new CommandReorderTinyV2().run(args)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-24 16:04:48 -04:00
|
|
|
task v2UnmergedYarnJar(dependsOn: [insertAutoGeneratedEnumMappings, combineUnpickDefinitions], type: Jar) {
|
2019-11-07 06:38:33 -05:00
|
|
|
def mappings = insertAutoGeneratedEnumMappings.output
|
|
|
|
group = "mapping build"
|
|
|
|
outputs.upToDateWhen { false }
|
2019-12-11 06:52:21 -05:00
|
|
|
archiveFileName = "yarn-${yarnVersion}-v2.jar"
|
2019-11-07 06:38:33 -05:00
|
|
|
|
|
|
|
from(file(mappings)) {
|
|
|
|
rename mappings.name, "mappings/mappings.tiny"
|
2019-05-12 21:45:52 -04:00
|
|
|
}
|
2021-03-24 16:04:48 -04:00
|
|
|
from(combineUnpickDefinitions.output) {
|
2021-05-14 11:26:02 -04:00
|
|
|
rename combineUnpickDefinitions.output.get().asFile.name, "extras/definitions.unpick"
|
2021-03-24 16:04:48 -04:00
|
|
|
}
|
|
|
|
from (file(unpickMetaFile)) {
|
2021-03-26 15:04:22 -04:00
|
|
|
expand version: project.unpick_version
|
2021-03-24 16:04:48 -04:00
|
|
|
rename unpickMetaFile.name, "extras/unpick.json"
|
|
|
|
}
|
2019-12-11 06:52:21 -05:00
|
|
|
destinationDirectory.set(file("build/libs"))
|
2022-01-02 13:54:44 -05:00
|
|
|
manifest {
|
|
|
|
attributes("Minecraft-Version-Id": minecraft_version)
|
|
|
|
}
|
2019-05-12 21:45:52 -04:00
|
|
|
}
|
|
|
|
|
2020-03-09 15:28:16 -04:00
|
|
|
task v2MergedYarnJar(dependsOn: ["mergeV2"], type: Jar) {
|
|
|
|
def mappings = mergeV2.output
|
|
|
|
group = "mapping build"
|
|
|
|
outputs.upToDateWhen { false }
|
|
|
|
archiveFileName = "yarn-${yarnVersion}-mergedv2.jar"
|
|
|
|
|
|
|
|
from(file(mappings)) {
|
|
|
|
rename mappings.name, "mappings/mappings.tiny"
|
|
|
|
}
|
2021-03-24 16:04:48 -04:00
|
|
|
from(combineUnpickDefinitions.output) {
|
2021-05-14 11:26:02 -04:00
|
|
|
rename combineUnpickDefinitions.output.get().asFile.name, "extras/definitions.unpick"
|
2021-03-24 16:04:48 -04:00
|
|
|
}
|
|
|
|
from (file(unpickMetaFile)) {
|
2021-03-26 15:04:22 -04:00
|
|
|
expand version: project.unpick_version
|
2021-03-24 16:04:48 -04:00
|
|
|
rename unpickMetaFile.name, "extras/unpick.json"
|
|
|
|
}
|
2020-03-09 15:28:16 -04:00
|
|
|
destinationDirectory.set(file("build/libs"))
|
2022-01-02 13:54:44 -05:00
|
|
|
manifest {
|
|
|
|
attributes("Minecraft-Version-Id": minecraft_version)
|
|
|
|
}
|
2020-03-09 15:28:16 -04:00
|
|
|
}
|
2019-05-12 21:45:52 -04:00
|
|
|
|
2020-04-07 16:13:29 -04:00
|
|
|
def fakeSourceDir = file(".gradle/temp/fakeSource")
|
2021-01-21 13:44:55 -05:00
|
|
|
task genFakeSource(type: JavaExec, dependsOn: ["mergeV2", "mapNamedJar"]) {
|
2020-04-07 16:13:29 -04:00
|
|
|
group = "javadoc generation"
|
|
|
|
outputs.upToDateWhen { false }
|
|
|
|
|
2021-07-10 07:28:14 -04:00
|
|
|
mainClass = "net.fabricmc.mappingpoet.Main"
|
2021-01-21 13:44:55 -05:00
|
|
|
classpath configurations.mappingPoet
|
|
|
|
// use merged v2 so we have all namespaces in jd
|
|
|
|
args mergeV2.output.getAbsolutePath(), namedJar.getAbsolutePath(), fakeSourceDir.getAbsolutePath(), libraries.getAbsolutePath()
|
2020-04-07 16:13:29 -04:00
|
|
|
|
2021-01-21 13:44:55 -05:00
|
|
|
doLast {
|
2020-04-07 16:13:29 -04:00
|
|
|
logger.lifecycle ":Fake source generated"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-24 16:04:48 -04:00
|
|
|
task decompileCFR(type: JavaExec, dependsOn: [mapNamedJar]) {
|
2021-07-10 07:28:14 -04:00
|
|
|
mainClass = "org.benf.cfr.reader.Main"
|
2020-10-31 15:02:53 -04:00
|
|
|
|
|
|
|
args namedJar.getAbsolutePath(), "--outputdir", file("namedSrc").absolutePath
|
|
|
|
|
|
|
|
doFirst {
|
|
|
|
file("namedSrc").deleteDir()
|
2021-07-10 07:28:14 -04:00
|
|
|
classpath = configurations.decompileClasspath
|
2020-10-31 15:02:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-18 09:55:18 -04:00
|
|
|
javadoc {
|
2020-04-07 16:13:29 -04:00
|
|
|
dependsOn genFakeSource
|
|
|
|
dependsOn downloadMcLibs
|
|
|
|
group = "javadoc generation"
|
|
|
|
outputs.upToDateWhen { false }
|
2021-01-21 13:44:55 -05:00
|
|
|
|
|
|
|
def mappingPoetJar = project.provider { zipTree configurations.mappingPoetJar.singleFile }
|
|
|
|
|
|
|
|
failOnError = false
|
2021-07-10 07:28:14 -04:00
|
|
|
maxMemory = '2G'
|
2021-01-21 13:44:55 -05:00
|
|
|
|
|
|
|
// verbose = true // enable to debug
|
2020-04-07 16:13:29 -04:00
|
|
|
options {
|
2021-01-21 13:44:55 -05:00
|
|
|
// verbose() // enable to debug
|
2021-11-16 13:18:51 -05:00
|
|
|
source = "17"
|
2020-04-07 16:13:29 -04:00
|
|
|
encoding = 'UTF-8'
|
|
|
|
charSet = 'UTF-8'
|
|
|
|
memberLevel = JavadocMemberLevel.PRIVATE
|
2021-01-21 13:44:55 -05:00
|
|
|
splitIndex true
|
|
|
|
tags(
|
|
|
|
'apiNote:a:API Note:',
|
|
|
|
'implSpec:a:Implementation Requirements:',
|
|
|
|
'implNote:a:Implementation Note:'
|
|
|
|
)
|
|
|
|
taglets "net.fabricmc.mappingpoet.jd.MappingTaglet"
|
|
|
|
// taglet path, header, extra stylesheet settings deferred
|
2021-04-02 08:03:52 -04:00
|
|
|
it.use()
|
2021-01-21 13:44:55 -05:00
|
|
|
|
|
|
|
addBooleanOption "-allow-script-in-comments", true
|
2022-02-16 11:19:57 -05:00
|
|
|
addBooleanOption "-ignore-source-errors", true
|
2020-04-07 16:13:29 -04:00
|
|
|
links(
|
|
|
|
'https://guava.dev/releases/21.0/api/docs/',
|
|
|
|
'https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.0/',
|
|
|
|
'https://logging.apache.org/log4j/2.x/log4j-api/apidocs/',
|
2021-02-23 10:40:14 -05:00
|
|
|
"https://javadoc.io/doc/org.jetbrains/annotations/${project.jetbrains_annotations_version}/",
|
2021-04-01 03:49:22 -04:00
|
|
|
'https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.2/',
|
2020-04-07 16:13:29 -04:00
|
|
|
'https://javadoc.lwjgl.org/',
|
2021-03-12 15:18:08 -05:00
|
|
|
'https://fastutil.di.unimi.it/docs/',
|
2021-01-26 08:10:08 -05:00
|
|
|
'https://netty.io/4.1/api/',
|
2020-04-07 16:13:29 -04:00
|
|
|
'https://commons.apache.org/proper/commons-logging/javadocs/api-1.1.3/',
|
|
|
|
'https://commons.apache.org/proper/commons-lang/javadocs/api-3.5',
|
|
|
|
'https://commons.apache.org/proper/commons-io/javadocs/api-2.5',
|
|
|
|
'https://commons.apache.org/proper/commons-codec/archives/1.10/apidocs',
|
|
|
|
'https://commons.apache.org/proper/commons-compress/javadocs/api-1.8.1/',
|
2021-01-26 08:10:08 -05:00
|
|
|
"https://maven.fabricmc.net/docs/fabric-loader-${project.fabric_loader_version}/",
|
2021-11-16 13:18:51 -05:00
|
|
|
"https://docs.oracle.com/en/java/javase/17/docs/api/"
|
2020-04-07 16:13:29 -04:00
|
|
|
)
|
2021-11-16 13:18:51 -05:00
|
|
|
// https://docs.oracle.com/en/java/javase/17/docs/specs/man/javadoc.html#additional-options-provided-by-the-standard-doclet
|
2021-01-21 13:44:55 -05:00
|
|
|
addBooleanOption 'Xdoclint:html', true
|
|
|
|
addBooleanOption 'Xdoclint:syntax', true
|
|
|
|
addBooleanOption 'Xdoclint:reference', true
|
|
|
|
addBooleanOption 'Xdoclint:accessibility', true
|
2020-04-07 16:13:29 -04:00
|
|
|
}
|
2021-03-30 17:39:16 -04:00
|
|
|
source fileTree(fakeSourceDir) + sourceSets.constants.allJava + sourceSets.packageDocs.allJava
|
2021-01-21 13:44:55 -05:00
|
|
|
classpath = configurations.javadocClasspath.plus downloadMcLibs.outputs.files.asFileTree
|
|
|
|
|
2021-07-10 07:28:14 -04:00
|
|
|
doLast {
|
|
|
|
project.copy {
|
2021-01-21 13:44:55 -05:00
|
|
|
from mappingPoetJar
|
|
|
|
include "copy_on_click.js"
|
|
|
|
into javadoc.outputDirectory
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
doFirst {
|
|
|
|
// lazy setting
|
|
|
|
options {
|
|
|
|
tagletPath configurations.mappingPoet.files.toList()
|
2021-07-10 07:28:14 -04:00
|
|
|
header mappingPoetJar.get().filter { it.name == 'javadoc_header.txt' }.singleFile.text.trim() // cannot include line breaks
|
2021-01-21 13:44:55 -05:00
|
|
|
addFileOption "-add-stylesheet", mappingPoetJar.get().filter { it.name == 'forms.css' }.singleFile
|
|
|
|
}
|
|
|
|
}
|
2020-04-07 16:13:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
task javadocJar(type: Jar, dependsOn: ["javadoc"]) {
|
|
|
|
group = "javadoc generation"
|
|
|
|
|
|
|
|
from javadoc.destinationDir
|
|
|
|
|
|
|
|
archiveVersion.set yarnVersion
|
2021-01-21 13:44:55 -05:00
|
|
|
archiveClassifier = 'javadoc'
|
2020-04-07 16:13:29 -04:00
|
|
|
}
|
|
|
|
|
2021-04-01 16:45:41 -04:00
|
|
|
generatePackageInfoMappings {
|
|
|
|
dependsOn mapIntermediaryJar
|
|
|
|
inputJar = intermediaryJar
|
|
|
|
packageName = "net/minecraft/unused/packageinfo/"
|
|
|
|
outputDir = file("mappings/net/minecraft/unused/packageinfo")
|
|
|
|
}
|
|
|
|
|
2021-04-13 07:59:43 -04:00
|
|
|
javadocLint {
|
|
|
|
group = "javadoc generation"
|
|
|
|
mappingDirectory = file("mappings")
|
|
|
|
}
|
|
|
|
|
|
|
|
check.dependsOn javadocLint
|
|
|
|
|
2018-10-30 07:29:43 -04:00
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
maven(MavenPublication) {
|
|
|
|
groupId 'net.fabricmc'
|
2018-12-09 16:14:34 -05:00
|
|
|
artifactId "yarn"
|
|
|
|
version yarnVersion
|
2018-10-30 07:29:43 -04:00
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
artifact(compressTiny.output) {
|
2018-10-30 07:29:43 -04:00
|
|
|
classifier "tiny"
|
2018-11-15 11:57:32 -05:00
|
|
|
builtBy compressTiny
|
2018-10-30 07:29:43 -04:00
|
|
|
}
|
2019-11-07 06:38:33 -05:00
|
|
|
artifact(tinyJar)
|
|
|
|
artifact(v2UnmergedYarnJar) {
|
|
|
|
classifier "v2"
|
|
|
|
}
|
2020-03-09 15:28:16 -04:00
|
|
|
artifact(v2MergedYarnJar) {
|
|
|
|
classifier "mergedv2"
|
|
|
|
}
|
2021-03-24 16:04:48 -04:00
|
|
|
artifact(constantsJar) {
|
|
|
|
classifier "constants"
|
|
|
|
}
|
|
|
|
artifact sourcesJar
|
2020-04-07 16:13:29 -04:00
|
|
|
artifact javadocJar
|
2018-10-30 07:29:43 -04:00
|
|
|
}
|
2019-11-07 06:38:33 -05:00
|
|
|
|
2018-10-30 07:29:43 -04:00
|
|
|
}
|
|
|
|
repositories {
|
2020-11-06 18:33:17 -05:00
|
|
|
if (ENV.MAVEN_URL) {
|
|
|
|
maven {
|
|
|
|
url ENV.MAVEN_URL
|
2018-10-30 07:29:43 -04:00
|
|
|
credentials {
|
2020-11-06 18:33:17 -05:00
|
|
|
username ENV.MAVEN_USERNAME
|
|
|
|
password ENV.MAVEN_PASSWORD
|
2018-10-30 07:29:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-28 14:42:32 -04:00
|
|
|
// A task to ensure that the version being released has not already been released.
|
|
|
|
task checkVersion {
|
|
|
|
doFirst {
|
|
|
|
def xml = new URL("https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml").text
|
|
|
|
def metadata = new XmlSlurper().parseText(xml)
|
|
|
|
def versions = metadata.versioning.versions.version*.text();
|
|
|
|
if (versions.contains(version)) {
|
|
|
|
throw new RuntimeException("${version} has already been released!")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
publish.mustRunAfter checkVersion
|
|
|
|
|
2021-02-23 10:40:14 -05:00
|
|
|
void mapJar(File output, File input, File mappings, File libraries, String from, String to,
|
|
|
|
Action<TinyRemapper.Builder> action = { }) {
|
2019-01-09 15:28:08 -05:00
|
|
|
if (output.exists()) {
|
|
|
|
output.delete()
|
|
|
|
}
|
|
|
|
|
2021-02-23 10:40:14 -05:00
|
|
|
def remapperBuilder = TinyRemapper.newRemapper()
|
2019-11-07 06:38:33 -05:00
|
|
|
.withMappings(TinyUtils.createTinyMappingProvider(mappings.toPath(), from, to))
|
|
|
|
.renameInvalidLocals(true)
|
|
|
|
.rebuildSourceFilenames(true)
|
2021-09-16 16:03:56 -04:00
|
|
|
.invalidLvNamePattern(~/\$\$\d+/)
|
2021-10-14 12:02:56 -04:00
|
|
|
.inferNameFromSameLvIndex(true)
|
|
|
|
|
2021-02-23 10:40:14 -05:00
|
|
|
action.execute(remapperBuilder)
|
|
|
|
def remapper = remapperBuilder
|
2019-11-07 06:38:33 -05:00
|
|
|
.build()
|
|
|
|
|
2019-01-09 15:28:08 -05:00
|
|
|
try {
|
2021-09-20 08:00:25 -04:00
|
|
|
def outputConsumerBuilder = new OutputConsumerPath.Builder(output.toPath())
|
|
|
|
// expose output consumer builder to function if there is need in the future
|
|
|
|
def outputConsumer = outputConsumerBuilder.build()
|
2019-01-09 15:28:08 -05:00
|
|
|
outputConsumer.addNonClassFiles(input.toPath())
|
2019-04-15 10:39:14 -04:00
|
|
|
remapper.readInputs(input.toPath())
|
2019-01-09 15:28:08 -05:00
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
libraries.eachFileRecurse(FileType.FILES) { file ->
|
2019-04-15 10:39:14 -04:00
|
|
|
remapper.readClassPath(file.toPath())
|
2019-01-09 15:28:08 -05:00
|
|
|
}
|
2019-04-15 10:39:14 -04:00
|
|
|
remapper.apply(outputConsumer)
|
2019-01-09 15:28:08 -05:00
|
|
|
outputConsumer.close()
|
2019-01-16 13:37:56 -05:00
|
|
|
remapper.finish()
|
2019-01-09 15:28:08 -05:00
|
|
|
} catch (Exception e) {
|
2019-01-16 13:37:56 -05:00
|
|
|
remapper.finish()
|
2019-05-12 21:45:52 -04:00
|
|
|
throw new RuntimeException("Failed to remap jar", e)
|
2019-01-09 15:28:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-30 07:29:43 -04:00
|
|
|
class FileOutput extends DefaultTask {
|
2019-11-07 06:38:33 -05:00
|
|
|
@OutputFile
|
|
|
|
File output
|
2018-10-31 12:54:00 -04:00
|
|
|
}
|
2019-11-07 06:38:33 -05:00
|
|
|
|
2021-03-24 16:04:48 -04:00
|
|
|
class FileOutputInput extends DefaultTask {
|
|
|
|
@InputFile
|
|
|
|
File input
|
|
|
|
|
|
|
|
@OutputFile
|
|
|
|
File output
|
|
|
|
}
|
|
|
|
|
2019-11-07 06:38:33 -05:00
|
|
|
class WithV2FileOutput extends DefaultTask {
|
|
|
|
@OutputFile
|
|
|
|
File v1Output
|
|
|
|
@OutputFile
|
|
|
|
File v2Output
|
2020-03-20 18:57:01 -04:00
|
|
|
}
|
2022-05-27 07:06:56 -04:00
|
|
|
|
|
|
|
abstract class EnigmaTask extends JavaExec {
|
|
|
|
@Input
|
|
|
|
abstract Property<File> getJar()
|
|
|
|
|
|
|
|
@Input
|
|
|
|
abstract Property<File> getMappings()
|
|
|
|
|
|
|
|
EnigmaTask() {
|
|
|
|
classpath = project.configurations.enigmaRuntime
|
|
|
|
mainClass.set('cuchaz.enigma.gui.Main')
|
|
|
|
}
|
|
|
|
|
|
|
|
@TaskAction
|
|
|
|
void exec() {
|
|
|
|
args '-jar'
|
|
|
|
args jar.get().absolutePath
|
|
|
|
args '-mappings'
|
|
|
|
args mappings.get().absolutePath
|
|
|
|
args '-profile'
|
|
|
|
args 'enigma_profile.json'
|
|
|
|
jvmArgs "-Xmx2048m"
|
|
|
|
super.exec()
|
|
|
|
}
|
|
|
|
}
|