fix a few bugs, make use of gradle extensions, add froglib convenience method
All checks were successful
Publish to snapshot maven / build (push) Successful in 17s
All checks were successful
Publish to snapshot maven / build (push) Successful in 17s
This commit is contained in:
parent
a52b695590
commit
707424242c
|
@ -8,6 +8,8 @@ import com.electronwill.nightconfig.toml.TomlWriter
|
|||
import net.fabricmc.fernflower.api.IFabricJavadocProvider
|
||||
import dev.frogmc.phytotelma.accesswidener.AccessWidener
|
||||
import dev.frogmc.phytotelma.common.Env
|
||||
import dev.frogmc.phytotelma.ext.PhytotelmaGradleExtension
|
||||
import dev.frogmc.phytotelma.ext.PhytotelmaGradleExtensionImpl
|
||||
import dev.frogmc.phytotelma.nest.Nester
|
||||
import dev.frogmc.phytotelma.run.AssetDownloader
|
||||
import dev.frogmc.phytotelma.run.RunConfigGenerator
|
||||
|
@ -46,6 +48,10 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
}
|
||||
|
||||
project.repositories.apply {
|
||||
maven {
|
||||
it.name = "Minecraft/Local"
|
||||
it.url = globalCacheDir.toUri()
|
||||
}
|
||||
maven {
|
||||
it.name = "FrogMC Releases"
|
||||
it.url = URI.create("https://maven.frogmc.dev/releases")
|
||||
|
@ -54,16 +60,14 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
it.name = "FrogMC Snapshots"
|
||||
it.url = URI.create("https://maven.frogmc.dev/snapshots")
|
||||
}
|
||||
maven {
|
||||
it.name = "Minecraft/Local"
|
||||
it.url = project.gradle.gradleUserHomeDir.resolve("caches/phytotelma/").toURI()
|
||||
}
|
||||
maven {
|
||||
it.name = "Minecraft Libraries"
|
||||
it.url = URI.create("https://libraries.minecraft.net/")
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
project.repositories.mavenCentral()
|
||||
|
||||
project.extensions.create(PhytotelmaGradleExtension::class.java, "phytotelma", PhytotelmaGradleExtensionImpl::class.java)
|
||||
|
||||
project.task("genSources").apply {
|
||||
group = taskGroup
|
||||
|
@ -85,8 +89,7 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
val parchment = ParchmentProvider.getParchment(
|
||||
minecraftVersion,
|
||||
parchmentVersion,
|
||||
project.gradle.gradleUserHomeDir.resolve("phytotelma/org/parchmentmc/parchment/$minecraftVersion/$parchmentVersion/")
|
||||
.toPath()
|
||||
globalCacheDir.resolve("org/parchmentmc/parchment/$minecraftVersion/$parchmentVersion/")
|
||||
)
|
||||
options[IFabricJavadocProvider.PROPERTY_NAME] = ParchmentJavadocProvider(parchment)
|
||||
|
||||
|
|
|
@ -85,11 +85,11 @@ object AccessWidener {
|
|||
|
||||
fun apply(project: Project, input: Path) {
|
||||
val startTime = System.currentTimeMillis()
|
||||
val classNames: MutableSet<String> = ConcurrentSkipListSet()
|
||||
val classMap: MutableMap<String, Entry> = ConcurrentHashMap()
|
||||
val methods: MutableMap<String, MutableMap<String, Entry>> = ConcurrentHashMap()
|
||||
val fields: MutableMap<String, MutableMap<String, Entry>> = ConcurrentHashMap()
|
||||
val mutations: MutableMap<String, MutableMap<String, Entry>> = ConcurrentHashMap()
|
||||
val classNames: MutableSet<String> = mutableSetOf()
|
||||
val classMap: MutableMap<String, Entry> = mutableMapOf()
|
||||
val methods: MutableMap<String, MutableMap<String, Entry>> = mutableMapOf()
|
||||
val fields: MutableMap<String, MutableMap<String, Entry>> = mutableMapOf()
|
||||
val mutations: MutableMap<String, MutableMap<String, Entry>> = mutableMapOf()
|
||||
val entries = readAllAWs(project)
|
||||
entries.forEach { e ->
|
||||
classNames.add(e.className)
|
||||
|
@ -167,15 +167,15 @@ data class Entry(
|
|||
val type: AccessType,
|
||||
val targetType: String,
|
||||
val className: String,
|
||||
val name: String,
|
||||
val descriptor: String
|
||||
val name: String?,
|
||||
val descriptor: String?
|
||||
) {
|
||||
constructor(line: List<String>) : this(
|
||||
AccessType.of(line[0]),
|
||||
line[1],
|
||||
line[2],
|
||||
line[3],
|
||||
line[4]
|
||||
line.getOrElse(3) {_ -> null},
|
||||
line.getOrElse(4) {_ -> null},
|
||||
)
|
||||
|
||||
fun isAccessGreaterThan(other: Entry): Boolean {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package dev.frogmc.phytotelma.ext
|
||||
|
||||
import org.gradle.api.provider.Provider
|
||||
|
||||
@Suppress("unused")
|
||||
interface PhytotelmaGradleExtension {
|
||||
|
||||
fun minecraft(version: String, parchmentVersion: String? = null)
|
||||
|
||||
fun minecraft(version: Provider<String>, parchmentVersion: Provider<String>? = null) {
|
||||
minecraft(version.get(), parchmentVersion?.get())
|
||||
}
|
||||
|
||||
fun loader(version: String)
|
||||
|
||||
fun loader(version: Provider<String>) {
|
||||
loader(version.get())
|
||||
}
|
||||
|
||||
fun froglib(version: String)
|
||||
|
||||
fun froglib(version: Provider<String>) {
|
||||
froglib(version.get())
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package dev.frogmc.phytotelma.ext
|
||||
|
||||
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
||||
import dev.frogmc.phytotelma.VersionChecker
|
||||
import dev.frogmc.phytotelma.accesswidener.AccessWidener
|
||||
import dev.frogmc.phytotelma.run.RunConfigGenerator
|
||||
import dev.frogmc.thyroxine.Thyroxine
|
||||
import dev.frogmc.thyroxine.parser.ProguardParser
|
||||
import dev.frogmc.thyroxine.provider.MojmapProvider
|
||||
import dev.frogmc.thyroxine.provider.ParchmentProvider
|
||||
import org.gradle.api.Project
|
||||
import javax.inject.Inject
|
||||
import kotlin.io.path.notExists
|
||||
|
||||
abstract class PhytotelmaGradleExtensionImpl: PhytotelmaGradleExtension {
|
||||
|
||||
@Inject
|
||||
abstract fun getProject(): Project
|
||||
|
||||
override fun minecraft(version: String, parchmentVersion: String?) {
|
||||
if (VersionChecker.validateVersion(version)) {
|
||||
println("Setting up Minecraft...")
|
||||
val parchment = parchmentVersion ?: kotlin.runCatching { ParchmentProvider.findForMinecraftVersion(version) }
|
||||
.getOrDefault("")
|
||||
PhytotelmaPlugin.minecraftVersion = version
|
||||
PhytotelmaPlugin.parchmentVersion = parchment
|
||||
println("Valid version! $version")
|
||||
val clientJar = VersionChecker.downloadClient(version)
|
||||
val remappedJar = clientJar.resolveSibling("client-$version-remapped.jar")
|
||||
PhytotelmaPlugin.remappedGameJarPath = remappedJar
|
||||
println("Time to setup Minecraft!")
|
||||
val applyAW = AccessWidener.needsUpdate(getProject())
|
||||
if (remappedJar.notExists() || applyAW) {
|
||||
println("Remapping the game...")
|
||||
val data = kotlin.runCatching {
|
||||
ProguardParser.read(
|
||||
MojmapProvider.get(
|
||||
version,
|
||||
clientJar.resolveSibling("client-$version.txt")
|
||||
).orElseThrow()
|
||||
).reverse()
|
||||
}.getOrNull()
|
||||
val paramMappings = if (parchment.isNotEmpty()) kotlin.runCatching {
|
||||
ParchmentProvider.getParchment(
|
||||
version, parchment,
|
||||
PhytotelmaPlugin.globalCacheDir.resolve("org/parchmentmc/parchment/$version/$parchment")
|
||||
)
|
||||
}.getOrNull() else {
|
||||
println("Parameter mappings will not be present as no parchment version was found. It may be possible to declare it manually.")
|
||||
null
|
||||
}
|
||||
if (paramMappings == null && parchment.isNotEmpty()) {
|
||||
println("Parameter mappings will not be present as the version $parchmentVersion for minecraft version $version could not be found")
|
||||
}
|
||||
if (data != null) {
|
||||
Thyroxine.remap(data, clientJar, remappedJar, true, paramMappings)
|
||||
} else {
|
||||
error("Failed to remap the game as no mojmap version was found for game version $version. Other mapping formats may be implemented in the future.")
|
||||
}
|
||||
}
|
||||
println("Adding dependencies...")
|
||||
getProject().dependencies.add("implementation", "net.minecrell:terminalconsoleappender:1.2.0")
|
||||
VersionChecker.getDependencies(version) {
|
||||
getProject().dependencies.add("implementation", it)
|
||||
}
|
||||
getProject().dependencies.add("implementation", "net.minecraft:client:$version:remapped")
|
||||
|
||||
println("Generating run configurations...")
|
||||
RunConfigGenerator.generate(getProject())
|
||||
|
||||
if (applyAW) {
|
||||
println("Applying AccessWideners..")
|
||||
AccessWidener.apply(getProject(), remappedJar)
|
||||
}
|
||||
|
||||
println("Done!")
|
||||
} else {
|
||||
println("Invalid version! $version")
|
||||
error("Invalid minecraft version provided: $version")
|
||||
}
|
||||
}
|
||||
|
||||
override fun loader(version: String) {
|
||||
getProject().dependencies.add("implementation", "dev.frogmc:frogloader:$version")
|
||||
}
|
||||
|
||||
override fun froglib(version: String) {
|
||||
getProject().dependencies.add("implementation", "dev.frogmc:froglib:$version")
|
||||
}
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
package dev.frogmc.phytotelma.ext
|
||||
|
||||
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
||||
import dev.frogmc.phytotelma.VersionChecker
|
||||
import dev.frogmc.phytotelma.accesswidener.AccessWidener
|
||||
import dev.frogmc.phytotelma.run.RunConfigGenerator
|
||||
import dev.frogmc.thyroxine.Thyroxine
|
||||
import dev.frogmc.thyroxine.parser.ProguardParser
|
||||
import dev.frogmc.thyroxine.provider.MojmapProvider
|
||||
import dev.frogmc.thyroxine.provider.ParchmentProvider
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Provider
|
||||
import kotlin.io.path.notExists
|
||||
|
||||
fun Project.minecraft(
|
||||
version: String,
|
||||
parchmentVersion: String? = null
|
||||
): Project { // return self to allow for chaining
|
||||
if (VersionChecker.validateVersion(version)) {
|
||||
println("Setting up Minecraft...")
|
||||
val parchment = parchmentVersion ?: kotlin.runCatching { ParchmentProvider.findForMinecraftVersion(version) }
|
||||
.getOrDefault("")
|
||||
PhytotelmaPlugin.minecraftVersion = version
|
||||
PhytotelmaPlugin.parchmentVersion = parchment
|
||||
println("Valid version! $version")
|
||||
val clientJar = VersionChecker.downloadClient(version)
|
||||
val remappedJar = clientJar.resolveSibling("client-$version-remapped.jar")
|
||||
PhytotelmaPlugin.remappedGameJarPath = remappedJar
|
||||
println("Time to setup Minecraft!")
|
||||
val applyAW = AccessWidener.needsUpdate(this)
|
||||
if (remappedJar.notExists() || applyAW) {
|
||||
println("Remapping the game...")
|
||||
val data = kotlin.runCatching {
|
||||
ProguardParser.read(
|
||||
MojmapProvider.get(
|
||||
version,
|
||||
clientJar.resolveSibling("client-$version.txt")
|
||||
).orElseThrow()
|
||||
).reverse()
|
||||
}.getOrNull()
|
||||
val paramMappings = if (parchment.isNotEmpty()) kotlin.runCatching {
|
||||
ParchmentProvider.getParchment(
|
||||
version, parchment,
|
||||
PhytotelmaPlugin.globalCacheDir.resolve("org/parchmentmc/parchment/$version/$parchment")
|
||||
)
|
||||
}.getOrNull() else {
|
||||
println("Parameter mappings will not be present as no parchment version was found. It may be possible to declare it manually.")
|
||||
null
|
||||
}
|
||||
if (paramMappings == null && parchment.isNotEmpty()) {
|
||||
println("Parameter mappings will not be present as the version $parchmentVersion for minecraft version $version could not be found")
|
||||
}
|
||||
if (data != null) {
|
||||
Thyroxine.remap(data, clientJar, remappedJar, true, paramMappings)
|
||||
} else {
|
||||
error("Failed to remap the game as no mojmap version was found for game version $version. Other mapping formats may be implemented in the future.")
|
||||
}
|
||||
}
|
||||
println("Adding dependencies...")
|
||||
dependencies.add("implementation", "net.minecrell:terminalconsoleappender:1.2.0")
|
||||
VersionChecker.getDependencies(version) {
|
||||
dependencies.add("implementation", it)
|
||||
}
|
||||
dependencies.add("implementation", "net.minecraft:client:$version:remapped")
|
||||
|
||||
println("Generating run configurations...")
|
||||
RunConfigGenerator.generate(this)
|
||||
|
||||
if (applyAW) {
|
||||
project.afterEvaluate {
|
||||
println("Applying AccessWideners..")
|
||||
AccessWidener.apply(this, remappedJar)
|
||||
}
|
||||
}
|
||||
|
||||
println("Done!")
|
||||
} else {
|
||||
println("Invalid version! $version")
|
||||
error("Invalid minecraft version provided: $version")
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
fun Project.minecraft(
|
||||
version: Provider<String>,
|
||||
parchmentVersion: Provider<String> = provider { null }
|
||||
): Project {
|
||||
return minecraft(version.get(), parchmentVersion.orNull)
|
||||
}
|
||||
|
||||
fun Project.loader(version: String) {
|
||||
dependencies.add("implementation", "dev.frogmc:frogloader:$version")
|
||||
}
|
||||
|
||||
fun Project.loader(version: Provider<String>) {
|
||||
return loader(version.get())
|
||||
}
|
Loading…
Reference in a new issue