Initial userdev update for 1.18
This commit is contained in:
parent
9ff8f17d8b
commit
21bc470c31
8 changed files with 98 additions and 47 deletions
|
@ -76,24 +76,6 @@ class PaperweightCore : Plugin<Project> {
|
|||
val tasks = AllTasks(target)
|
||||
|
||||
val devBundleTasks = DevBundleTasks(target)
|
||||
devBundleTasks.configure(
|
||||
ext.serverProject,
|
||||
ext.minecraftVersion,
|
||||
tasks.extractFromBundler.map { it.serverJar.path },
|
||||
tasks.decompileJar.map { it.outputJar.path },
|
||||
tasks.extractFromBundler.map { it.serverLibrariesTxt.path },
|
||||
tasks.mergeAdditionalAts.map { it.outputFile.path }
|
||||
) {
|
||||
vanillaJarIncludes.set(ext.vanillaJarIncludes)
|
||||
reobfMappingsFile.set(tasks.patchReobfMappings.flatMap { it.outputMappings })
|
||||
|
||||
paramMappingsCoordinates.set(
|
||||
target.provider {
|
||||
determineArtifactCoordinates(target.configurations.getByName(PARAM_MAPPINGS_CONFIG)).single()
|
||||
}
|
||||
)
|
||||
paramMappingsUrl.set(ext.paramMappingsRepo)
|
||||
}
|
||||
|
||||
val bundlerJarTasks = BundlerJarTasks(
|
||||
target,
|
||||
|
@ -172,6 +154,29 @@ class PaperweightCore : Plugin<Project> {
|
|||
tasks.patchReobfMappings.flatMap { it.outputMappings }
|
||||
) ?: return@afterEvaluate
|
||||
|
||||
devBundleTasks.configure(
|
||||
ext.bundlerJarName.get(),
|
||||
ext.mainClass,
|
||||
ext.serverProject,
|
||||
ext.minecraftVersion,
|
||||
tasks.decompileJar.map { it.outputJar.path },
|
||||
tasks.extractFromBundler.map { it.serverLibrariesTxt.path },
|
||||
tasks.extractFromBundler.map { it.serverLibrariesList.path },
|
||||
tasks.downloadServerJar.map { it.outputJar.path },
|
||||
tasks.mergeAdditionalAts.map { it.outputFile.path },
|
||||
tasks.extractFromBundler.map { it.versionJson.path }
|
||||
) {
|
||||
vanillaJarIncludes.set(ext.vanillaJarIncludes)
|
||||
reobfMappingsFile.set(tasks.patchReobfMappings.flatMap { it.outputMappings })
|
||||
|
||||
paramMappingsCoordinates.set(
|
||||
target.provider {
|
||||
determineArtifactCoordinates(target.configurations.getByName(PARAM_MAPPINGS_CONFIG)).single()
|
||||
}
|
||||
)
|
||||
paramMappingsUrl.set(ext.paramMappingsRepo)
|
||||
}
|
||||
|
||||
bundlerJarTasks.configureBundlerTasks(
|
||||
tasks.extractFromBundler,
|
||||
tasks.downloadServerJar,
|
||||
|
|
|
@ -26,6 +26,8 @@ import com.google.gson.JsonObject
|
|||
import io.papermc.paperweight.tasks.*
|
||||
import io.papermc.paperweight.util.*
|
||||
import io.papermc.paperweight.util.constants.*
|
||||
import java.nio.file.Path
|
||||
import org.gradle.api.NamedDomainObjectContainer
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.RegularFile
|
||||
import org.gradle.api.plugins.JavaPlugin
|
||||
|
@ -93,10 +95,22 @@ class BundlerJarTasks(
|
|||
vanillaBundlerJar.set(downloadServerJar.flatMap { it.outputJar })
|
||||
|
||||
versionArtifacts {
|
||||
register(bundlerJarName.get()) {
|
||||
id.set(extractFromBundler.flatMap { it.versionJson }.map { gson.fromJson<JsonObject>(it)["id"].asString })
|
||||
file.set(serverJar)
|
||||
}
|
||||
registerVersionArtifact(
|
||||
bundlerJarName.get(),
|
||||
extractFromBundler.map { it.versionJson.path },
|
||||
serverJar
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun NamedDomainObjectContainer<CreateBundlerJar.VersionArtifact>.registerVersionArtifact(
|
||||
name: String,
|
||||
versionJson: Provider<Path>,
|
||||
serverJar: Provider<RegularFile>
|
||||
) = register(name) {
|
||||
id.set(versionJson.map { gson.fromJson<JsonObject>(it)["id"].asString })
|
||||
file.set(serverJar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
package io.papermc.paperweight.taskcontainers
|
||||
|
||||
import io.papermc.paperweight.extension.RelocationExtension
|
||||
import io.papermc.paperweight.taskcontainers.BundlerJarTasks.Companion.registerVersionArtifact
|
||||
import io.papermc.paperweight.tasks.*
|
||||
import io.papermc.paperweight.util.*
|
||||
import io.papermc.paperweight.util.constants.*
|
||||
|
@ -30,20 +31,17 @@ import java.nio.file.Path
|
|||
import kotlin.io.path.*
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.TaskContainer
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.kotlin.dsl.*
|
||||
|
||||
class DevBundleTasks(
|
||||
private val project: Project,
|
||||
tasks: TaskContainer = project.tasks,
|
||||
) {
|
||||
val generateMojangMappedPaperclipPatch by tasks.registering<GeneratePaperclipPatch>()
|
||||
|
||||
val mojangMappedPaperclipJar by tasks.registering<Jar> {
|
||||
archiveClassifier.set("mojang-mapped-paperclip")
|
||||
configurePaperclipJar(project, generateMojangMappedPaperclipPatch)
|
||||
val serverBundlerForDevBundle by tasks.registering<CreateBundlerJar> {
|
||||
paperclip.from(project.configurations.named(PAPERCLIP_CONFIG))
|
||||
}
|
||||
|
||||
val generateDevelopmentBundle by tasks.registering<GenerateDevBundle> {
|
||||
|
@ -56,25 +54,37 @@ class DevBundleTasks(
|
|||
}
|
||||
|
||||
fun configure(
|
||||
bundlerJarName: String,
|
||||
mainClassName: Property<String>,
|
||||
serverProj: Provider<Project>,
|
||||
minecraftVer: Provider<String>,
|
||||
vanillaJar: Provider<Path?>,
|
||||
decompileJar: Provider<Path?>,
|
||||
serverLibrariesTxt: Provider<Path?>,
|
||||
serverLibrariesListFile: Provider<Path?>,
|
||||
vanillaBundlerJarFile: Provider<Path?>,
|
||||
accessTransformFile: Provider<Path?>,
|
||||
versionJsonFile: Provider<Path>,
|
||||
devBundleConfiguration: GenerateDevBundle.() -> Unit
|
||||
) {
|
||||
generateMojangMappedPaperclipPatch {
|
||||
// FIXME
|
||||
// originalJar.pathProvider(vanillaJar)
|
||||
// patchedJar.set(serverProj.flatMap { proj -> proj.tasks.named<FixJarForReobf>("fixJarForReobf").flatMap { it.inputJar } })
|
||||
mcVersion.set(minecraftVer)
|
||||
serverBundlerForDevBundle {
|
||||
mainClass.set(mainClassName)
|
||||
serverLibrariesList.pathProvider(serverLibrariesListFile)
|
||||
vanillaBundlerJar.pathProvider(vanillaBundlerJarFile)
|
||||
versionArtifacts {
|
||||
registerVersionArtifact(
|
||||
bundlerJarName,
|
||||
versionJsonFile,
|
||||
serverProj.flatMap { proj ->
|
||||
proj.tasks.named<FixJarForReobf>("fixJarForReobf").flatMap { it.inputJar }
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
generateDevelopmentBundle {
|
||||
sourceDir.set(serverProj.map { it.layout.projectDirectory.dir("src/main/java") })
|
||||
minecraftVersion.set(minecraftVer)
|
||||
mojangMappedPaperclipFile.set(mojangMappedPaperclipJar.flatMap { it.archiveFile })
|
||||
mojangMappedPaperclipFile.set(serverBundlerForDevBundle.flatMap { it.outputZip })
|
||||
vanillaServerLibraries.set(
|
||||
serverLibrariesTxt.map { txt ->
|
||||
txt.readLines(Charsets.UTF_8).filter { it.isNotBlank() }
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.gradle.api.tasks.Classpath
|
|||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.Nested
|
||||
import org.gradle.api.tasks.Optional
|
||||
import org.gradle.kotlin.dsl.*
|
||||
|
||||
abstract class CreateBundlerJar : ZippedTask() {
|
||||
|
@ -63,6 +64,7 @@ abstract class CreateBundlerJar : ZippedTask() {
|
|||
val versionArtifacts: NamedDomainObjectContainer<VersionArtifact> = createVersionArtifactContainer()
|
||||
|
||||
@get:Classpath
|
||||
@get:Optional
|
||||
abstract val libraryArtifacts: Property<Configuration>
|
||||
|
||||
@get:InputFile
|
||||
|
@ -110,7 +112,7 @@ abstract class CreateBundlerJar : ZippedTask() {
|
|||
val libraries = mutableListOf<FileEntry<ModuleId>>()
|
||||
val changedLibraries = mutableListOf<LibraryChange>()
|
||||
|
||||
val serverLibraryEntries = FileEntry.parse(serverLibrariesList.path, ModuleId.Companion::parse)
|
||||
val serverLibraryEntries = FileEntry.parse(serverLibrariesList.path, ModuleId::parse)
|
||||
|
||||
val outputDir = rootDir.resolve("META-INF/libraries")
|
||||
|
||||
|
@ -169,10 +171,12 @@ abstract class CreateBundlerJar : ZippedTask() {
|
|||
}
|
||||
|
||||
private fun collectDependencies(): Set<ResolvedArtifactResult> {
|
||||
return libraryArtifacts.get().incoming.artifacts.artifacts.filterTo(HashSet()) {
|
||||
val id = it.id.componentIdentifier
|
||||
id is ModuleComponentIdentifier || id is ProjectComponentIdentifier
|
||||
}
|
||||
return libraryArtifacts.map { config ->
|
||||
config.incoming.artifacts.artifacts.filterTo(HashSet()) {
|
||||
val id = it.id.componentIdentifier
|
||||
id is ModuleComponentIdentifier || id is ProjectComponentIdentifier
|
||||
}
|
||||
}.getOrElse(hashSetOf<ResolvedArtifactResult>())
|
||||
}
|
||||
|
||||
private fun ResolvedArtifactResult.copyTo(path: Path): Path {
|
||||
|
|
|
@ -295,7 +295,7 @@ abstract class GenerateDevBundle : DefaultTask() {
|
|||
}
|
||||
|
||||
private fun createCoordinatesFor(project: Project): String =
|
||||
sequenceOf(project.group, project.name.toLowerCase(Locale.ENGLISH), project.version).joinToString(":")
|
||||
sequenceOf(project.group, project.name.toLowerCase(Locale.ENGLISH), "userdev-" + project.version).joinToString(":")
|
||||
|
||||
private fun relocations(): List<Relocation> = gson.fromJson(relocations.get())
|
||||
|
||||
|
|
|
@ -165,6 +165,7 @@ class PaperweightPatcher : Plugin<Project> {
|
|||
reobfMappings.set(target.layout.cache.resolve(REOBF_MOJANG_SPIGOT_MAPPINGS))
|
||||
}
|
||||
|
||||
/* FIXME
|
||||
devBundleTasks.configure(
|
||||
patcher.serverProject,
|
||||
upstreamData.map { it.mcVersion },
|
||||
|
@ -179,6 +180,7 @@ class PaperweightPatcher : Plugin<Project> {
|
|||
paramMappingsCoordinates.set(upstreamData.map { it.paramMappings.coordinates.single() })
|
||||
paramMappingsUrl.set(upstreamData.map { it.paramMappings.url })
|
||||
}
|
||||
*/
|
||||
|
||||
val (_, reobfJar) = serverProj.setupServerProject(
|
||||
target,
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package io.papermc.paperweight.userdev.internal.setup
|
||||
|
||||
import com.google.gson.JsonObject
|
||||
import io.papermc.paperweight.util.*
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.*
|
||||
|
@ -44,8 +45,18 @@ fun patchPaperclip(
|
|||
jvmArgs = listOf("-Dpaperclip.patchonly=true"),
|
||||
args = arrayOf()
|
||||
)
|
||||
val patched = work.resolve("cache").listDirectoryEntries()
|
||||
.find { it.name.startsWith("patched") } ?: error("Can't find patched jar!")
|
||||
patched.copyTo(outputJar, overwrite = true)
|
||||
paperclip.openZip().use { fs ->
|
||||
val root = fs.rootDirectories.single()
|
||||
|
||||
val serverVersionJson = root.resolve("version.json")
|
||||
val versionId = gson.fromJson<JsonObject>(serverVersionJson)["id"].asString
|
||||
val versions = root.resolve("/META-INF/versions.list").readLines()
|
||||
.map { it.split('\t') }
|
||||
.associate { it[1] to it[2] }
|
||||
|
||||
val serverJarPath = work.resolve("versions/${versions[versionId]}")
|
||||
outputJar.parent.createDirectories()
|
||||
serverJarPath.copyTo(outputJar, overwrite = true)
|
||||
}
|
||||
work.deleteRecursively()
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ abstract class UserdevSetup : BuildService<UserdevSetup.Parameters> {
|
|||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
null,
|
||||
)
|
||||
hashFunction.writeHash(hashFile)
|
||||
}
|
||||
|
@ -352,6 +352,7 @@ abstract class UserdevSetup : BuildService<UserdevSetup.Parameters> {
|
|||
hashFile.writeText(hash())
|
||||
}
|
||||
|
||||
/*
|
||||
private val filteredMojangMappedPaperJar: Path = cache.resolve(paperSetupOutput("filteredMojangMappedPaperJar", "jar"))
|
||||
private fun filterMojangMappedPaperJar(context: Context) {
|
||||
patchDecompiledSources(context)
|
||||
|
@ -370,6 +371,7 @@ abstract class UserdevSetup : BuildService<UserdevSetup.Parameters> {
|
|||
hashFile.parent.createDirectories()
|
||||
hashFile.writeText(hash())
|
||||
}
|
||||
*/
|
||||
|
||||
private var setupCompleted = false
|
||||
|
||||
|
@ -379,7 +381,10 @@ abstract class UserdevSetup : BuildService<UserdevSetup.Parameters> {
|
|||
return
|
||||
}
|
||||
|
||||
filterMojangMappedPaperJar(context)
|
||||
patchDecompiledSources(context)
|
||||
applyMojangMappedPaperclipPatch(context)
|
||||
|
||||
// filterMojangMappedPaperJar(context)
|
||||
|
||||
val didInstall = installToIvyRepo(
|
||||
cache.resolve(IVY_REPOSITORY),
|
||||
|
@ -388,7 +393,7 @@ abstract class UserdevSetup : BuildService<UserdevSetup.Parameters> {
|
|||
devBundleConfig.apiCoordinates +
|
||||
devBundleConfig.mojangApiCoordinates,
|
||||
patchedSourcesJar,
|
||||
filteredMojangMappedPaperJar
|
||||
mojangMappedPaperJar
|
||||
)
|
||||
if (didInstall) {
|
||||
LOGGER.lifecycle(":installed server artifacts to cache")
|
||||
|
|
Loading…
Reference in a new issue