mirror of
https://github.com/architectury/architectury-plugin.git
synced 2026-03-28 04:07:01 -05:00
Primitive untested support for Loom 0.11.0
Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
11
build.gradle
11
build.gradle
@@ -68,6 +68,14 @@ sourceSets {
|
||||
runtimeClasspath += main.output
|
||||
}
|
||||
}
|
||||
loom011 {
|
||||
java {
|
||||
compileClasspath += main.compileClasspath
|
||||
runtimeClasspath += main.runtimeClasspath
|
||||
compileClasspath += main.output
|
||||
runtimeClasspath += main.output
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -80,6 +88,7 @@ dependencies {
|
||||
loom09CompileOnly "dev.architectury:architectury-loom:$loom_version_09"
|
||||
loom010LegacyCompileOnly "dev.architectury:architectury-loom:$loom_version_010Legacy"
|
||||
loom010CompileOnly "dev.architectury:architectury-loom:$loom_version_010"
|
||||
loom011CompileOnly "dev.architectury:architectury-loom:$loom_version_011"
|
||||
implementation "dev.architectury:tiny-remapper:1.1.0"
|
||||
implementation "com.google.code.gson:gson:2.8.5"
|
||||
}
|
||||
@@ -96,7 +105,7 @@ jar {
|
||||
attributes 'Implementation-Version': project.version
|
||||
}
|
||||
|
||||
from sourceSets.loom06.output + sourceSets.loom09.output + sourceSets.loom010Legacy.output + sourceSets.loom010.output
|
||||
from sourceSets.loom06.output + sourceSets.loom09.output + sourceSets.loom010Legacy.output + sourceSets.loom010.output + sourceSets.loom011.output
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
|
||||
@@ -3,5 +3,6 @@ loom_version_06=0.6.96
|
||||
loom_version_09=0.9.0.158
|
||||
loom_version_010Legacy=0.10.0.171
|
||||
loom_version_010=0.10.0.188
|
||||
loom_version_011=0.11.0.217
|
||||
transformer_version=5.1.59
|
||||
base_version=3.4
|
||||
@@ -0,0 +1,73 @@
|
||||
package dev.architectury.plugin.loom
|
||||
|
||||
import net.fabricmc.loom.LoomGradleExtension
|
||||
import net.fabricmc.loom.configuration.ide.RunConfig
|
||||
import net.fabricmc.loom.task.RemapJarTask
|
||||
import net.fabricmc.loom.task.service.MixinMappingsService
|
||||
import net.fabricmc.loom.util.service.SharedServiceManager
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.RegularFile
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import java.util.function.Consumer
|
||||
|
||||
class LoomInterface011(private val project: Project) : LoomInterface {
|
||||
private val extension: LoomGradleExtension
|
||||
get() = LoomGradleExtension.get(project)
|
||||
|
||||
override val allMixinMappings: Collection<File>
|
||||
get() = extractMixinMappings(getMixinService(SharedServiceManager.get(project)))
|
||||
|
||||
private fun getMixinService(serviceManager: SharedServiceManager): MixinMappingsService {
|
||||
return MixinMappingsService::class.java.getDeclaredMethod("getService", SharedServiceManager::class.java).also {
|
||||
it.isAccessible = true
|
||||
}.invoke(null, serviceManager) as MixinMappingsService
|
||||
}
|
||||
|
||||
private fun extractMixinMappings(service: MixinMappingsService): Collection<File> {
|
||||
return MixinMappingsService::class.java.getDeclaredField("mixinMappings").also {
|
||||
it.isAccessible = true
|
||||
}.get(service) as HashSet<File>
|
||||
}
|
||||
|
||||
override val tinyMappingsWithSrg: Path
|
||||
get() = extension.mappingsProvider.tinyMappingsWithSrg
|
||||
|
||||
override val refmapName: String
|
||||
get() = extension.mixin.defaultRefmapName.get()
|
||||
|
||||
override var generateSrgTiny: Boolean
|
||||
get() = extension.shouldGenerateSrgTiny()
|
||||
set(value) {
|
||||
extension.setGenerateSrgTiny(value)
|
||||
}
|
||||
|
||||
override fun settingsPostEdit(action: (config: LoomInterface.LoomRunConfig) -> Unit) {
|
||||
extension.settingsPostEdit.add(Consumer { c -> action(LoomRunConfigImpl(c)) })
|
||||
}
|
||||
|
||||
override fun setIdeConfigGenerated() {
|
||||
extension.runConfigs.forEach { it.isIdeConfigGenerated = true }
|
||||
extension.runConfigs.whenObjectAdded { it.isIdeConfigGenerated = true }
|
||||
extension.addTaskBeforeRun("\$PROJECT_DIR\$/${project.name}:classes")
|
||||
}
|
||||
|
||||
override fun setRemapJarInput(task: Jar, archiveFile: Provider<RegularFile>) {
|
||||
task as RemapJarTask
|
||||
task.input.set(archiveFile)
|
||||
}
|
||||
|
||||
class LoomRunConfigImpl(private val config: RunConfig) : LoomInterface.LoomRunConfig {
|
||||
override var mainClass: String
|
||||
get() = config.mainClass
|
||||
set(value) {
|
||||
config.mainClass = value
|
||||
}
|
||||
|
||||
override fun addVmArg(vmArg: String) {
|
||||
config.vmArgs.add(vmArg)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,9 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
|
||||
private val loom: LoomInterface by lazy {
|
||||
useIfFound(
|
||||
"net.fabricmc.loom.util.service.SharedServiceManager",
|
||||
"dev.architectury.plugin.loom.LoomInterface011" // 0.11.0
|
||||
) ?: useIfFound(
|
||||
"net.fabricmc.loom.util.ZipUtils",
|
||||
"dev.architectury.plugin.loom.LoomInterface010" // >0.10.0.188
|
||||
) ?: useIfFound(
|
||||
|
||||
Reference in New Issue
Block a user