mirror of https://github.com/FabricMC/yarn.git
Migrate build-logic to filament (#2303)
* Migrate build-logic to filament * Fix * Cleanup
This commit is contained in:
parent
f42f7bb2ed
commit
6304e347f3
|
@ -10,6 +10,8 @@ To use yarn-deobfuscated Minecraft for Minecraft modding or as a dependency in a
|
|||
|
||||
To obtain a deobfuscated Minecraft jar, [`./gradlew mapNamedJar`](#mapNamedJar) will generate a jar named like `<minecraft version>-named.jar`, which can be sent to a decompiler for deobfuscated code.
|
||||
|
||||
Please note to run the yarn build script **Java 11** or higher is required!
|
||||
|
||||
## Contributing
|
||||
|
||||
Please remember that copying and pasting mappings from alternate projects under more restrictive licenses (such as MCP, Spigot's or Mojang's obfuscation maps)
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
plugins {
|
||||
id 'groovy-gradle-plugin'
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name "Fabric Repository"
|
||||
url 'https://maven.fabricmc.net'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api "org.ow2.asm:asm:9.1"
|
||||
api "org.ow2.asm:asm-tree:9.1"
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
rootProject.name = 'build-logic'
|
|
@ -1,3 +0,0 @@
|
|||
import net.fabricmc.yarn.buildlogic.task.*
|
||||
|
||||
task generatePackageInfoMappings(type: GeneratePackageInfoMappingsTask)
|
|
@ -1,80 +0,0 @@
|
|||
package net.fabricmc.yarn.buildlogic.task
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.objectweb.asm.ClassReader
|
||||
import org.objectweb.asm.Opcodes
|
||||
import org.objectweb.asm.tree.ClassNode
|
||||
|
||||
import java.util.zip.ZipFile
|
||||
|
||||
@CompileStatic
|
||||
class GeneratePackageInfoMappingsTask extends DefaultTask {
|
||||
@InputFile
|
||||
final RegularFileProperty inputJar = project.objects.fileProperty()
|
||||
@OutputDirectory
|
||||
final Property<String> packageName = project.objects.property(String.class)
|
||||
@OutputDirectory
|
||||
final DirectoryProperty outputDir = project.objects.directoryProperty()
|
||||
|
||||
@TaskAction
|
||||
def run() {
|
||||
project.logger.lifecycle("Scanning ${inputJar.get().asFile} for package-info classes")
|
||||
|
||||
outputDir.get().asFile.deleteDir()
|
||||
|
||||
new ZipFile(inputJar.get().asFile).withCloseable {zipFile ->
|
||||
zipFile.entries().iterator().forEachRemaining({ entry ->
|
||||
if (entry.name.endsWith(".class")) {
|
||||
zipFile.getInputStream(entry).withCloseable {is ->
|
||||
processEntry(entry.name, is)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private void processEntry(String name, InputStream inputStream) {
|
||||
name = name.replace(".class", "")
|
||||
|
||||
if (name.contains("\$")) {
|
||||
// Dont care about inner classes
|
||||
return
|
||||
}
|
||||
|
||||
ClassReader classReader = new ClassReader(inputStream)
|
||||
ClassNode classNode = new ClassNode()
|
||||
classReader.accept(classNode, 0)
|
||||
|
||||
if (classNode.access != (Opcodes.ACC_ABSTRACT | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_INTERFACE )) {
|
||||
// We only care about abstract synthetic interfaces, hopefully this is specific enough
|
||||
return
|
||||
}
|
||||
|
||||
if (classNode.methods.size() > 0 || classNode.fields.size() > 0 || classNode.interfaces.size() > 0) {
|
||||
// Nope cannot be a package-info
|
||||
return
|
||||
}
|
||||
|
||||
generateMapping(name)
|
||||
}
|
||||
|
||||
private void generateMapping(String name) {
|
||||
String inputName = name.substring(name.lastIndexOf("/") + 1)
|
||||
String className = "PackageInfo" + name.substring(name.lastIndexOf("_") + 1)
|
||||
String fullName = packageName.get() + className;
|
||||
File mappingsFile = new File(outputDir.get().asFile, "${className}.mapping")
|
||||
|
||||
mappingsFile.parentFile.mkdirs()
|
||||
|
||||
mappingsFile.text = """\
|
||||
CLASS net/minecraft/$inputName $fullName
|
||||
""".stripIndent()
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ plugins {
|
|||
id 'maven-publish'
|
||||
id 'java' // for jd gen
|
||||
id 'org.cadixdev.licenser' version '0.5.1'
|
||||
id 'build-logic'
|
||||
id 'net.fabricmc.filament' version '0.1.0'
|
||||
}
|
||||
|
||||
def minecraft_version = "21w14a"
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
// This check is done here before any plugins that may require java 11 are able to load.
|
||||
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
|
||||
throw new UnsupportedOperationException("Yarn's buildscript requires Java 11 or higher.")
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
gradlePluginPortal()
|
||||
mavenLocal()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "yarn"
|
||||
// This check is done here before any plugins that may require java 11 are able to load.
|
||||
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
|
||||
throw new UnsupportedOperationException("Yarn's buildscript requires Java 11 or higher.")
|
||||
}
|
||||
|
||||
includeBuild 'build-logic'
|
||||
rootProject.name = "yarn"
|
Loading…
Reference in New Issue