Update to Gradle 7 and Hypo release

This commit is contained in:
Kyle Wood 2021-05-07 17:41:46 -05:00
parent 3ffc238bbb
commit bb83b90c47
No known key found for this signature in database
GPG key ID: 86186EDFECC585CB
13 changed files with 86 additions and 47 deletions

View file

@ -7,8 +7,8 @@ plugins {
eclipse
`kotlin-dsl`
`maven-publish`
id("org.cadixdev.licenser") version "0.5.1"
id("com.github.johnrengelman.shadow") version "6.1.0"
id("org.cadixdev.licenser") version "0.6.0"
id("com.github.johnrengelman.shadow") version "7.0.0"
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
}
@ -42,22 +42,12 @@ repositories {
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots/") {
mavenContent {
includeGroup("org.cadixdev")
includeModule("org.cadixdev", "mercury")
}
}
maven("https://wav.jfrog.io/artifactory/repo/") {
maven("https://maven.quiltmc.org/repository/release/") {
mavenContent {
includeGroup("org.cadixdev")
}
}
maven("https://maven.fabricmc.net/") {
mavenContent {
includeGroup("net.fabricmc")
}
}
mavenLocal {
mavenContent {
includeGroup("com.demonwav.hypo")
includeGroup("org.quiltmc")
}
}
}
@ -78,12 +68,12 @@ dependencies {
shade("org.ow2.asm:asm")
shade("org.ow2.asm:asm-tree")
shade(platform("com.demonwav.hypo:hypo-bom:0.1.0-SNAPSHOT"))
shade(platform("com.demonwav.hypo:hypo-platform:1.0.0"))
shade("com.demonwav.hypo:hypo-model")
shade("com.demonwav.hypo:hypo-core")
shade("com.demonwav.hypo:hypo-hydrate")
shade("com.demonwav.hypo:hypo-asm")
shade("com.demonwav.hypo:hypo-asm-hydrator")
shade("com.demonwav.hypo:hypo-asm-hydrate")
shade("com.demonwav.hypo:hypo-mappings")
// Cadix
@ -95,7 +85,7 @@ dependencies {
shade("org.cadixdev:at:0.1.0-rc1")
shade("org.cadixdev:mercury:0.1.0-rc2-SNAPSHOT")
shade("net.fabricmc:lorenz-tiny:3.0.0")
shade("org.quiltmc:lorenz-tiny:3.0.0")
shade("io.sigpipe:jbsdiff:1.0")
}
@ -113,7 +103,7 @@ tasks.register("format") {
}
license {
header = file("license/copyright.txt")
header.set(resources.text.fromFile(file("license/copyright.txt")))
include("**/*.kt")
}

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -71,7 +71,7 @@ abstract class AddAdditionalSpigotMappings : BaseTask() {
appendFile?.useLines { seq -> seq.forEach { lines.add(it) } }
lines.sort()
outputFile.bufferedWriter().use { writer ->
lines.forEach { writer.appendln(it) }
lines.forEach { writer.appendLine(it) }
}
}
}

View file

@ -1,3 +1,25 @@
/*
* paperweight is a Gradle plugin for the PaperMC project.
*
* Copyright (c) 2020 Kyle Wood (DemonWav)
* Contributors
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 only, no later versions.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/
package io.papermc.paperweight.tasks
import io.papermc.paperweight.ext.listFilesRecursively

View file

@ -1,3 +1,25 @@
/*
* paperweight is a Gradle plugin for the PaperMC project.
*
* Copyright (c) 2020 Kyle Wood (DemonWav)
* Contributors
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 only, no later versions.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/
package io.papermc.paperweight.tasks
import com.demonwav.hypo.asm.AsmClassDataProvider
@ -7,12 +29,11 @@ import com.demonwav.hypo.core.HypoContext
import com.demonwav.hypo.hydrate.HydrationManager
import com.demonwav.hypo.mappings.ChangeChain
import com.demonwav.hypo.mappings.ChangeRegistry
import com.demonwav.hypo.mappings.LorenzUtil
import com.demonwav.hypo.mappings.MappingsCompletionManager
import com.demonwav.hypo.mappings.MappingsUtil
import com.demonwav.hypo.mappings.MergeResult
import com.demonwav.hypo.mappings.MergeableMappingsChange
import com.demonwav.hypo.mappings.UnableToMergeException
import com.demonwav.hypo.mappings.changes.AbstractMappingsChange
import com.demonwav.hypo.mappings.changes.LorenzUtil
import com.demonwav.hypo.mappings.changes.MemberReference
import com.demonwav.hypo.mappings.changes.RemoveMappingChange
import com.demonwav.hypo.mappings.contributors.ChangeContributor
@ -21,7 +42,7 @@ import com.demonwav.hypo.mappings.contributors.PropagateMappingsUp
import com.demonwav.hypo.mappings.contributors.RemoveUnusedMappings
import com.demonwav.hypo.model.ClassProviderRoot
import com.demonwav.hypo.model.data.ClassData
import com.demonwav.hypo.model.data.types.PrimitiveTypes
import com.demonwav.hypo.model.data.types.PrimitiveType
import io.papermc.paperweight.util.Constants
import io.papermc.paperweight.util.MappingFormats
import io.papermc.paperweight.util.file
@ -95,7 +116,7 @@ abstract class CleanupMappings : DefaultTask() {
}
for (methodMapping in classMapping.methodMappings) {
val method = MappingsUtil.findMethod(currentClass, methodMapping) ?: continue
val method = LorenzUtil.findMethod(currentClass, methodMapping) ?: continue
var methodRef: MemberReference? = null
@ -108,7 +129,7 @@ abstract class CleanupMappings : DefaultTask() {
registry.submitChange(ParamIndexChange(methodRef, lvtIndex, sourceIndex))
}
lvtIndex++
if (param === PrimitiveTypes.LONG || param === PrimitiveTypes.DOUBLE) {
if (param === PrimitiveType.LONG || param === PrimitiveType.DOUBLE) {
lvtIndex++
}
}
@ -129,9 +150,9 @@ abstract class CleanupMappings : DefaultTask() {
indexMap[fromIndex] = toIndex
}
override fun applyChange(input: MappingSet, className: String, name: String, desc: String?) {
val classMapping = input.getOrCreateClassMapping(className)
val methodMapping = classMapping.getOrCreateMethodMapping(name, desc)
override fun applyChange(input: MappingSet, ref: MemberReference) {
val classMapping = input.getOrCreateClassMapping(ref.className())
val methodMapping = classMapping.getOrCreateMethodMapping(ref.name(), ref.desc())
val paramsMap = LorenzUtil.getParamsMap(methodMapping)
val params = paramsMap.values.toList()
@ -142,20 +163,20 @@ abstract class CleanupMappings : DefaultTask() {
}
}
override fun mergeWith(that: ParamIndexChange): ParamIndexChange {
override fun mergeWith(that: ParamIndexChange): MergeResult<ParamIndexChange> {
for (fromIndex in this.indexMap.keys) {
if (that.indexMap.containsKey(fromIndex)) {
throw UnableToMergeException("Cannot merge 2 param mappings changes with matching fromIndexes")
return MergeResult.failure("Cannot merge 2 param mappings changes with matching fromIndexes")
}
}
for (toIndex in this.indexMap.values) {
if (that.indexMap.containsValue(toIndex)) {
throw UnableToMergeException("Cannot merge 2 param mappings changes with matching toIndex")
return MergeResult.failure("Cannot merge 2 param mappings changes with matching toIndex")
}
}
this.indexMap += that.indexMap
return this
return MergeResult.success(this)
}
override fun toString(): String {

View file

@ -116,7 +116,7 @@ abstract class InspectVanillaJar : BaseTask() {
serverLibraries.file.bufferedWriter(Charsets.UTF_8).use { writer ->
serverLibs.map { it.toString() }.sorted().forEach { artifact ->
writer.appendln(artifact)
writer.appendLine(artifact)
}
}
}

View file

@ -70,7 +70,7 @@ abstract class PatchMappings : DefaultTask() {
for (line in lines) {
val newLine = comment.replace(line, "")
if (newLine.isNotBlank()) {
writer.appendln(newLine)
writer.appendLine(newLine)
}
}
}

View file

@ -92,6 +92,6 @@ abstract class RemapJar : BaseTask() {
}
ensureParentExists(logFile)
runJar(remapper, layout.cache, logFile, jvmArgs = listOf("-Xmx512m"), args = *args.toTypedArray())
runJar(remapper, layout.cache, logFile, jvmArgs = listOf("-Xmx512m"), args = args.toTypedArray())
}
}

View file

@ -28,6 +28,11 @@ import io.papermc.paperweight.util.defaultOutput
import io.papermc.paperweight.util.file
import io.papermc.paperweight.util.isLibraryJar
import io.papermc.paperweight.util.runJar
import kotlin.io.path.ExperimentalPathApi
import kotlin.io.path.absolutePathString
import kotlin.io.path.bufferedWriter
import kotlin.io.path.createTempFile
import kotlin.io.path.deleteIfExists
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.Classpath
@ -54,6 +59,7 @@ abstract class RunForgeFlower : BaseTask() {
}
@TaskAction
@ExperimentalPathApi
fun run() {
val out = outputJar.file
val target = out.resolveSibling("${out.name}.dir")
@ -69,7 +75,7 @@ abstract class RunForgeFlower : BaseTask() {
tempFile.bufferedWriter().use { writer ->
for (lib in libs) {
if (lib.isLibraryJar) {
writer.appendln("-e=${lib.absolutePath}")
writer.appendLine("-e=${lib.absolutePath}")
}
}
}
@ -87,7 +93,7 @@ abstract class RunForgeFlower : BaseTask() {
"-iib=1",
"-log=TRACE",
"-cfg",
tempFile.absolutePath,
tempFile.absolutePathString(),
inputJar.file.absolutePath,
target.absolutePath
)
@ -97,13 +103,13 @@ abstract class RunForgeFlower : BaseTask() {
val jvmArgs = listOf("-Xmx4G")
runJar(executable.file, layout.cache, logFile, jvmArgs = jvmArgs, args = *argList.toTypedArray())
runJar(executable.file, layout.cache, logFile, jvmArgs = jvmArgs, args = argList.toTypedArray())
// FernFlower is weird with how it does directory output
target.resolve(inputJar.file.name).renameTo(out)
target.deleteRecursively()
} finally {
tempFile.delete()
tempFile.deleteIfExists()
}
}
}

View file

@ -44,7 +44,7 @@ abstract class SetupMcLibraries : DefaultTask() {
outputFile.file.bufferedWriter().use { writer ->
for (line in list) {
writer.appendln(line)
writer.appendLine(line)
}
}
}

View file

@ -74,7 +74,7 @@ abstract class SpigotDecompileJar : BaseTask() {
val logFile = layout.cache.resolve(paperTaskOutput("log"))
logFile.delete()
runJar(fernFlowerJar, workingDir = layout.cache, logFile = logFile, args = *cmd.toTypedArray())
runJar(fernFlowerJar, workingDir = layout.cache, logFile = logFile, args = cmd.toTypedArray())
ensureDeleted(outputJarFile)
decomp.resolve(inputJarFile.name).renameTo(outputJarFile)

View file

@ -103,7 +103,7 @@ abstract class SpigotRemapJar : BaseTask() {
specialSource2Jar,
workingDir = work,
logFile = logFile,
args = *doReplacements(classMapCommand.get(), inputJarPath, classMappingPath, classJarPath) {
args = doReplacements(classMapCommand.get(), inputJarPath, classMappingPath, classJarPath) {
// ignore excludes, we actually want to map every class
it != "-e"
}
@ -119,7 +119,7 @@ abstract class SpigotRemapJar : BaseTask() {
specialSource2Jar,
workingDir = work,
logFile = logFile,
args = *doReplacements(memberMapCommand.get(), classJarPath, memberMappingsPath, membersJarPath)
args = doReplacements(memberMapCommand.get(), classJarPath, memberMappingsPath, membersJarPath)
)
} catch (e: Exception) {
throw PaperweightException("Failed to apply member mappings", e)
@ -132,7 +132,7 @@ abstract class SpigotRemapJar : BaseTask() {
specialSourceJar,
workingDir = work,
logFile = logFile,
args = *doReplacements(
args = doReplacements(
finalMapCommand.get(),
membersJarPath,
accessTransformersPath,

View file

@ -49,7 +49,7 @@ fun runJar(jar: Any, workingDir: Any, logFile: Any?, jvmArgs: List<String> = lis
).directory(dir)
output.writer().let {
it.appendln("Command: ${processBuilder.command().joinToString(" ")}")
it.appendLine("Command: ${processBuilder.command().joinToString(" ")}")
it.flush()
}