mirror of
https://github.com/architectury/architectury-plugin.git
synced 2026-03-28 04:07:01 -05:00
Add runtime specific artifacts that doesn't include the refmaps
This commit is contained in:
@@ -45,6 +45,11 @@ class ArchitectPlugin : Plugin<Project> {
|
||||
it.group = "Architectury"
|
||||
}
|
||||
|
||||
project.tasks.register("transformArchitectJarRuntime", TransformTask::class.java) {
|
||||
it.group = "Architectury"
|
||||
it.addRefmap = false
|
||||
}
|
||||
|
||||
project.repositories.apply {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
|
||||
@@ -28,6 +28,7 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
project.configurations.create("transformForgeFakeMod")
|
||||
}
|
||||
project.configurations.create("transformed")
|
||||
project.configurations.create("transformedRuntime")
|
||||
|
||||
val buildTask = project.tasks.getByName("build")
|
||||
val jarTask = project.tasks.getByName("jar") {
|
||||
@@ -46,6 +47,17 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
buildTask.dependsOn(it)
|
||||
it.outputs.upToDateWhen { false }
|
||||
} as TransformTask
|
||||
val transformArchitectRuntimeJarTask = project.tasks.getByName("transformArchitectJarRuntime") {
|
||||
it as TransformTask
|
||||
|
||||
it.archiveClassifier.set("transformedRuntime")
|
||||
it.input.set(jarTask.archiveFile.get())
|
||||
|
||||
project.artifacts.add("archives", it)
|
||||
it.dependsOn(jarTask)
|
||||
buildTask.dependsOn(it)
|
||||
it.outputs.upToDateWhen { false }
|
||||
} as TransformTask
|
||||
|
||||
val remapJarTask = project.tasks.getByName("remapJar") {
|
||||
it as RemapJarTask
|
||||
@@ -70,9 +82,9 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
val transformForgeFakeModTask = project.tasks.getByName("transformForgeFakeMod") {
|
||||
it as RemapMCPTask
|
||||
|
||||
it.input.set(transformArchitectJarTask.archiveFile.get())
|
||||
it.input.set(transformArchitectRuntimeJarTask.archiveFile.get())
|
||||
it.archiveClassifier.set("transformedForgeFakeMod")
|
||||
it.dependsOn(transformArchitectJarTask)
|
||||
it.dependsOn(transformArchitectRuntimeJarTask)
|
||||
buildTask.dependsOn(it)
|
||||
it.outputs.upToDateWhen { false }
|
||||
} as RemapMCPTask
|
||||
@@ -105,6 +117,13 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
"builtBy" to transformArchitectJarTask
|
||||
)
|
||||
)
|
||||
it.add(
|
||||
"transformedRuntime", mapOf(
|
||||
"file" to transformArchitectRuntimeJarTask.archiveFile.get().asFile,
|
||||
"type" to "jar",
|
||||
"builtBy" to transformArchitectRuntimeJarTask
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import org.objectweb.asm.Opcodes
|
||||
import org.objectweb.asm.tree.AnnotationNode
|
||||
import org.objectweb.asm.tree.ClassNode
|
||||
import org.objectweb.asm.tree.MethodInsnNode
|
||||
import org.zeroturnaround.zip.ByteSource
|
||||
import org.zeroturnaround.zip.ZipUtil
|
||||
import java.io.*
|
||||
import java.net.URL
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.nio.file.Path
|
||||
|
||||
open class TransformTask : Jar() {
|
||||
val input: RegularFileProperty = GradleSupport.getFileProperty(project)
|
||||
var addRefmap = true
|
||||
|
||||
@TaskAction
|
||||
fun doTask() {
|
||||
@@ -22,9 +23,16 @@ open class TransformTask : Jar() {
|
||||
project.logger.lifecycle(":transforming " + input.fileName + " => " + output.fileName)
|
||||
Transform.transform(input, output, transformExpectPlatform())
|
||||
|
||||
if (addRefmap) {
|
||||
val loomExtension = project.extensions.getByType(LoomGradleExtension::class.java)
|
||||
if (MixinRefmapHelper.addRefmapName(loomExtension.getRefmapName(), loomExtension.mixinJsonVersion, output)) {
|
||||
if (MixinRefmapHelper.addRefmapName(
|
||||
loomExtension.getRefmapName(),
|
||||
loomExtension.mixinJsonVersion,
|
||||
output
|
||||
)
|
||||
) {
|
||||
project.logger.debug("Transformed mixin reference maps in output JAR!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user