mirror of
https://github.com/architectury/architectury-plugin.git
synced 2026-03-28 04:07:01 -05:00
Use forgified loom
This commit is contained in:
@@ -9,7 +9,7 @@ plugins {
|
||||
}
|
||||
|
||||
group "me.shedaniel"
|
||||
version = "1.1." + (System.getenv("GITHUB_RUN_NUMBER") == null ? (((short) new Random().nextInt()).abs() + 1000).toString() : System.getenv("GITHUB_RUN_NUMBER"))
|
||||
version = "1.2." + (System.getenv("GITHUB_RUN_NUMBER") == null ? (((short) new Random().nextInt()).abs() + 1000).toString() : System.getenv("GITHUB_RUN_NUMBER"))
|
||||
|
||||
logger.lifecycle(":building architect plugin v${version}")
|
||||
|
||||
@@ -18,6 +18,8 @@ sourceCompatibility = targetCompatibility = 1.8
|
||||
repositories {
|
||||
jcenter()
|
||||
maven { url "https://maven.fabricmc.net/" }
|
||||
maven { url "https://files.minecraftforge.net/maven/" }
|
||||
maven { url "https://dl.bintray.com/shedaniel/cloth/" }
|
||||
}
|
||||
|
||||
apply plugin: 'java-gradle-plugin'
|
||||
@@ -26,8 +28,8 @@ dependencies {
|
||||
implementation gradleApi()
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72"
|
||||
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.72"
|
||||
implementation "net.fabricmc:fabric-loom:0.5.42"
|
||||
runtime "net.fabricmc:fabric-loom:0.5.42"
|
||||
implementation "me.shedaniel:forgified-fabric-loom:0.5.2"
|
||||
runtime "me.shedaniel:forgified-fabric-loom:0.5.2"
|
||||
implementation "net.fabricmc:tiny-remapper:0.3.0.70"
|
||||
implementation "net.fabricmc:tiny-mappings-parser:0.2.2.14"
|
||||
implementation "org.ow2.asm:asm:8.0"
|
||||
|
||||
@@ -35,6 +35,17 @@ class ArchitectPlugin : Plugin<Project> {
|
||||
it.group = "Architect"
|
||||
}
|
||||
|
||||
project.tasks.register("transformForge", RemapMCPTask::class.java) {
|
||||
it.remapMcp = false
|
||||
it.group = "Architect"
|
||||
}
|
||||
|
||||
project.tasks.register("transformForgeFakeMod", RemapMCPTask::class.java) {
|
||||
it.fakeMod = true
|
||||
it.remapMcp = false
|
||||
it.group = "Architect"
|
||||
}
|
||||
|
||||
project.tasks.register("transformArchitectJar", TransformTask::class.java) {
|
||||
it.group = "Architect"
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
if (forgeEnabled) {
|
||||
project.configurations.create("mcp")
|
||||
project.configurations.create("mcpGenerateMod")
|
||||
project.configurations.create("transformForge")
|
||||
project.configurations.create("transformForgeFakeMod")
|
||||
}
|
||||
project.configurations.create("transformed")
|
||||
|
||||
@@ -68,6 +70,26 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
it.outputs.upToDateWhen { false }
|
||||
} as RemapMCPTask
|
||||
|
||||
val transformForgeTask = project.tasks.getByName("transformForge") {
|
||||
it as RemapMCPTask
|
||||
|
||||
it.input.set(transformArchitectJarTask.archiveFile.get())
|
||||
it.archiveClassifier.set("transformForge")
|
||||
it.dependsOn(transformArchitectJarTask)
|
||||
buildTask.dependsOn(it)
|
||||
it.outputs.upToDateWhen { false }
|
||||
} as RemapMCPTask
|
||||
|
||||
val transformForgeFakeModTask = project.tasks.getByName("transformForgeFakeMod") {
|
||||
it as RemapMCPTask
|
||||
|
||||
it.input.set(transformArchitectJarTask.archiveFile.get())
|
||||
it.archiveClassifier.set("transformForgeFakeMod")
|
||||
it.dependsOn(transformArchitectJarTask)
|
||||
buildTask.dependsOn(it)
|
||||
it.outputs.upToDateWhen { false }
|
||||
} as RemapMCPTask
|
||||
|
||||
project.artifacts {
|
||||
it.add(
|
||||
"mcp", mapOf(
|
||||
@@ -83,6 +105,20 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
"builtBy" to remapMCPFakeModTask
|
||||
)
|
||||
)
|
||||
it.add(
|
||||
"transformForge", mapOf(
|
||||
"file" to transformForgeTask.archiveFile.get().asFile,
|
||||
"type" to "jar",
|
||||
"builtBy" to transformForgeTask
|
||||
)
|
||||
)
|
||||
it.add(
|
||||
"transformForgeFakeMod", mapOf(
|
||||
"file" to transformForgeFakeModTask.archiveFile.get().asFile,
|
||||
"type" to "jar",
|
||||
"builtBy" to transformForgeFakeModTask
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import kotlin.collections.LinkedHashSet
|
||||
open class RemapMCPTask : Jar() {
|
||||
private val fromM: String = "named"
|
||||
private val toM: String = "official"
|
||||
var remapMcp = true
|
||||
var fakeMod = false
|
||||
val input: RegularFileProperty = GradleSupport.getFileProperty(project)
|
||||
private val environmentClass = "net/fabricmc/api/Environment"
|
||||
@@ -76,7 +77,6 @@ open class RemapMCPTask : Jar() {
|
||||
}
|
||||
}
|
||||
|
||||
val remapperBuilder: TinyRemapper.Builder = TinyRemapper.newRemapper()
|
||||
|
||||
val classpathFiles: Set<File> = LinkedHashSet(
|
||||
project.configurations.getByName("compileClasspath").files
|
||||
@@ -84,16 +84,21 @@ open class RemapMCPTask : Jar() {
|
||||
val classpath = classpathFiles.asSequence().map { obj: File -> obj.toPath() }
|
||||
.filter { p: Path -> input != p && Files.exists(p) }.toList().toTypedArray()
|
||||
|
||||
val mappings = getMappings()
|
||||
val mojmapToMcpClass = createMojmapToMcpClass(mappings)
|
||||
remapperBuilder.withMappings(
|
||||
remapToMcp(
|
||||
TinyRemapperMappingsHelper.create(mappings, fromM, fromM, false),
|
||||
mojmapToMcpClass
|
||||
val remapperBuilder: TinyRemapper.Builder = TinyRemapper.newRemapper()
|
||||
if (remapMcp) {
|
||||
val mappings = getMappings()
|
||||
val mojmapToMcpClass: Map<String, String> = createMojmapToMcpClass(mappings)
|
||||
remapperBuilder.withMappings(
|
||||
remapToMcp(
|
||||
TinyRemapperMappingsHelper.create(mappings, fromM, fromM, false),
|
||||
mojmapToMcpClass
|
||||
)
|
||||
)
|
||||
)
|
||||
remapperBuilder.ignoreFieldDesc(true)
|
||||
remapperBuilder.skipLocalVariableMapping(true)
|
||||
remapperBuilder.skipLocalVariableMapping(true)
|
||||
} else {
|
||||
remapperBuilder.withMappings(remapToMcp(null, null))
|
||||
remapperBuilder.skipLocalVariableMapping(true)
|
||||
}
|
||||
|
||||
project.logger.lifecycle(":remapping " + input.fileName)
|
||||
|
||||
@@ -165,7 +170,7 @@ modId = "$fakeModId"
|
||||
}
|
||||
}
|
||||
|
||||
private fun remapToMcp(parent: IMappingProvider, mojmapToMcpClass: Map<String, String>): IMappingProvider =
|
||||
private fun remapToMcp(parent: IMappingProvider?, mojmapToMcpClass: Map<String, String>?): IMappingProvider =
|
||||
IMappingProvider {
|
||||
it.acceptClass("net/fabricmc/api/Environment", "net/minecraftforge/api/distmarker/OnlyIn")
|
||||
it.acceptClass("net/fabricmc/api/EnvType", "net/minecraftforge/api/distmarker/Dist")
|
||||
@@ -174,9 +179,9 @@ modId = "$fakeModId"
|
||||
"DEDICATED_SERVER"
|
||||
)
|
||||
|
||||
parent.load(object : IMappingProvider.MappingAcceptor {
|
||||
parent?.load(object : IMappingProvider.MappingAcceptor {
|
||||
override fun acceptClass(srcName: String?, dstName: String?) {
|
||||
it.acceptClass(srcName, mojmapToMcpClass[srcName] ?: srcName)
|
||||
it.acceptClass(srcName, mojmapToMcpClass!![srcName] ?: srcName)
|
||||
}
|
||||
|
||||
override fun acceptMethod(method: IMappingProvider.Member?, dstName: String?) {
|
||||
@@ -259,7 +264,7 @@ modId = "$fakeModId"
|
||||
}
|
||||
}
|
||||
}
|
||||
node.signature?.let {
|
||||
node.signature?.let {
|
||||
node.signature = it.substringBeforeLast('L') + "Lnet/minecraftforge/eventbus/api/Event;"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user