mirror of
https://github.com/architectury/architectury-plugin.git
synced 2026-03-28 04:07:01 -05:00
Fix architectury/architectury-loom#72 (#25)
This commit is contained in:
@@ -30,6 +30,8 @@ class LoomInterface010(private val project: Project) : LoomInterface {
|
||||
extension.setGenerateSrgTiny(value)
|
||||
}
|
||||
|
||||
override val generateTransformerPropertiesInTask = false
|
||||
|
||||
override fun settingsPostEdit(action: (config: LoomInterface.LoomRunConfig) -> Unit) {
|
||||
extension.settingsPostEdit.add(Consumer { c -> action(LoomRunConfigImpl(c)) })
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ class LoomInterface010Legacy(private val project: Project) : LoomInterface {
|
||||
extension.setGenerateSrgTiny(value)
|
||||
}
|
||||
|
||||
override val generateTransformerPropertiesInTask = false
|
||||
|
||||
override fun settingsPostEdit(action: (config: LoomInterface.LoomRunConfig) -> Unit) {
|
||||
extension.settingsPostEdit.add(Consumer { c -> action(LoomRunConfigImpl(c)) })
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ class LoomInterface011(private val project: Project) : LoomInterface {
|
||||
extension.setGenerateSrgTiny(value)
|
||||
}
|
||||
|
||||
override val generateTransformerPropertiesInTask = true
|
||||
|
||||
override fun settingsPostEdit(action: (config: LoomInterface.LoomRunConfig) -> Unit) {
|
||||
extension.settingsPostEdit.add(Consumer { c -> action(LoomRunConfigImpl(c)) })
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ class LoomInterface06(private val project: Project) : LoomInterface {
|
||||
extension.generateSrgTiny = value
|
||||
}
|
||||
|
||||
override val generateTransformerPropertiesInTask = false
|
||||
|
||||
override fun settingsPostEdit(action: (config: LoomInterface.LoomRunConfig) -> Unit) {
|
||||
extension.settingsPostEdit.add(Consumer { c -> action(LoomRunConfigImpl(c)) })
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ class LoomInterface09(private val project: Project) : LoomInterface {
|
||||
extension.setGenerateSrgTiny(value)
|
||||
}
|
||||
|
||||
override val generateTransformerPropertiesInTask = false
|
||||
|
||||
override fun settingsPostEdit(action: (config: LoomInterface.LoomRunConfig) -> Unit) {
|
||||
extension.settingsPostEdit.add(Consumer { c -> action(LoomRunConfigImpl(c)) })
|
||||
}
|
||||
|
||||
@@ -91,6 +91,39 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
|
||||
init {
|
||||
project.afterEvaluate {
|
||||
if (loom.generateTransformerPropertiesInTask) {
|
||||
// Only apply if this project has the configureLaunch task.
|
||||
// This is needed because arch plugin can also apply to the root project
|
||||
// where the task doesn't exist and our task isn't needed either.
|
||||
if ("configureLaunch" in project.tasks.names) {
|
||||
val task = project.tasks.register(
|
||||
"prepareArchitecturyTransformer",
|
||||
PrepareArchitecturyTransformer::class.java
|
||||
)
|
||||
project.tasks.named("configureLaunch") {
|
||||
it.dependsOn(task)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
prepareTransformer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun properties(platform: String): Map<String, String> {
|
||||
return mutableMapOf(
|
||||
BuiltinProperties.MIXIN_MAPPINGS to loom.allMixinMappings.joinToString(File.pathSeparator),
|
||||
BuiltinProperties.INJECT_INJECTABLES to injectInjectables.toString(),
|
||||
BuiltinProperties.UNIQUE_IDENTIFIER to project.projectUniqueIdentifier(),
|
||||
BuiltinProperties.COMPILE_CLASSPATH to getCompileClasspath().joinToString(File.pathSeparator),
|
||||
BuiltinProperties.MAPPINGS_WITH_SRG to loom.tinyMappingsWithSrg.toString(),
|
||||
"architectury.platform.name" to platform,
|
||||
BuiltinProperties.REFMAP_NAME to loom.refmapName,
|
||||
BuiltinProperties.MCMETA_VERSION to "4"
|
||||
)
|
||||
}
|
||||
|
||||
fun prepareTransformer() {
|
||||
if (transforms.isNotEmpty()) {
|
||||
StringWriter().also { strWriter ->
|
||||
TransformersWriter(strWriter).use { writer ->
|
||||
@@ -107,6 +140,7 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
runtimeTransformerFile.writeText(strWriter.toString())
|
||||
}
|
||||
|
||||
|
||||
val properties = Properties()
|
||||
properties(transforms.keys.first()).forEach { (key, value) ->
|
||||
properties.setProperty(key, value)
|
||||
@@ -116,20 +150,6 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun properties(platform: String): Map<String, String> {
|
||||
return mutableMapOf(
|
||||
BuiltinProperties.MIXIN_MAPPINGS to loom.allMixinMappings.joinToString(File.pathSeparator),
|
||||
BuiltinProperties.INJECT_INJECTABLES to injectInjectables.toString(),
|
||||
BuiltinProperties.UNIQUE_IDENTIFIER to project.projectUniqueIdentifier(),
|
||||
BuiltinProperties.COMPILE_CLASSPATH to getCompileClasspath().joinToString(File.pathSeparator),
|
||||
BuiltinProperties.MAPPINGS_WITH_SRG to loom.tinyMappingsWithSrg.toString(),
|
||||
"architectury.platform.name" to platform,
|
||||
BuiltinProperties.REFMAP_NAME to loom.refmapName,
|
||||
BuiltinProperties.MCMETA_VERSION to "4"
|
||||
)
|
||||
}
|
||||
|
||||
private fun getCompileClasspath(): Iterable<File> {
|
||||
return project.configurations.findByName("architecturyTransformerClasspath")
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package dev.architectury.plugin
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
|
||||
open class PrepareArchitecturyTransformer : DefaultTask() {
|
||||
@TaskAction
|
||||
fun run() {
|
||||
project.extensions.getByType(ArchitectPluginExtension::class.java).prepareTransformer()
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,16 @@ interface LoomInterface {
|
||||
val refmapName: String
|
||||
var generateSrgTiny: Boolean
|
||||
|
||||
/**
|
||||
* Loom 0.11+ has to generate the runtime transformer properties file
|
||||
* in a separate hook that is guaranteed to run after mod dep processing.
|
||||
* (Which is a task hooked to `configureLaunch`.)
|
||||
* This is just unfortunate `afterEvaluate` ordering, sadly.
|
||||
*
|
||||
* See [architectury-loom#72](https://github.com/architectury/architectury-loom/issues/72)
|
||||
*/
|
||||
val generateTransformerPropertiesInTask: Boolean
|
||||
|
||||
fun settingsPostEdit(action: (config: LoomRunConfig) -> Unit)
|
||||
fun setIdeConfigGenerated()
|
||||
fun setRemapJarInput(task: Jar, archiveFile: Provider<RegularFile>)
|
||||
|
||||
Reference in New Issue
Block a user