Skip to content

Commit c156df8

Browse files
committed
feat: expose configuration to fail on invalid ATs, closes #344
1 parent 3a4e5d7 commit c156df8

7 files changed

Lines changed: 19 additions & 2 deletions

File tree

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/extension/PaperweightCoreExtension.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,6 @@ abstract class PaperweightCoreExtension @Inject constructor(objects: ObjectFacto
7979
fun updatingMinecraft(action: Action<UpdatingMinecraftExtension>) {
8080
action.execute(updatingMinecraft)
8181
}
82+
83+
val validateAts: Property<Boolean> = objects.property<Boolean>().convention(false)
8284
}

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/CoreTasks.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class CoreTasks(
101101
oldPaperCommit.convention(project.coreExt.updatingMinecraft.oldPaperCommit)
102102
inputFile.set(macheDecompileJar.flatMap { it.outputJar })
103103
predicate.set { Files.isRegularFile(it) && it.toString().endsWith(".java") }
104+
validateAts.set(project.coreExt.validateAts)
104105
}
105106

106107
val setupMacheSources by tasks.registering(SetupMinecraftSources::class) {

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/MinecraftPatchingTasks.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import io.papermc.paperweight.core.tasks.patching.ApplyFilePatches
3030
import io.papermc.paperweight.core.tasks.patching.ApplyFilePatchesFuzzy
3131
import io.papermc.paperweight.core.tasks.patching.FixupFilePatches
3232
import io.papermc.paperweight.core.tasks.patching.RebuildFilePatches
33+
import io.papermc.paperweight.core.util.coreExt
3334
import io.papermc.paperweight.tasks.*
3435
import io.papermc.paperweight.util.*
3536
import io.papermc.paperweight.util.constants.*
@@ -171,6 +172,7 @@ class MinecraftPatchingTasks(
171172
atFile.set(mergeCollectedAts.flatMap { it.outputFile })
172173
ats.jst.from(project.configurations.named(JST_CONFIG))
173174
ats.jstClasspath.from(project.configurations.named(MACHE_MINECRAFT_LIBRARIES_CONFIG))
175+
validateAts.set(project.coreExt.validateAts)
174176
}
175177

176178
applySourcePatches.configure {

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/SetupForkMinecraftSources.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ abstract class SetupForkMinecraftSources : JavaLauncherTask() {
5959
@get:Optional
6060
abstract val atFile: RegularFileProperty
6161

62+
@get:Input
63+
abstract val validateAts: Property<Boolean>
64+
6265
@get:Optional
6366
@get:InputDirectory
6467
abstract val libraryImports: DirectoryProperty
@@ -86,6 +89,7 @@ abstract class SetupForkMinecraftSources : JavaLauncherTask() {
8689
outputDir.path,
8790
atFile.path,
8891
atWorkingDir.path,
92+
validate = validateAts.get(),
8993
)
9094
commitAndTag(git, "ATs", "${identifier.get()} ATs")
9195
}

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/SetupMinecraftSources.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ abstract class SetupMinecraftSources : JavaLauncherZippedTask() {
6969
@get:Input
7070
abstract val oldPaperCommit: Property<String>
7171

72+
@get:Input
73+
abstract val validateAts: Property<Boolean>
74+
7275
@get:Nested
7376
val ats: ApplySourceATs = objects.newInstance()
7477

@@ -182,6 +185,7 @@ abstract class SetupMinecraftSources : JavaLauncherZippedTask() {
182185
outputPath,
183186
atFile.path,
184187
atWorkingDir.path,
188+
validate = validateAts.get(),
185189
)
186190
if (!oldPaperCommit.isPresent) {
187191
commitAndTag(git, "ATs", "paper ATs")

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/RebuildFilePatches.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ abstract class RebuildFilePatches : JavaLauncherTask() {
258258
at,
259259
temporaryDir.toPath().resolve("jst_work"),
260260
singleFile = true,
261+
validate = false,
261262
)
262263
println("NEW: " + decomp.readText())
263264
}

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/util/ApplySourceATs.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ abstract class ApplySourceATs {
5353
atFile: Path,
5454
workDir: Path,
5555
singleFile: Boolean = false,
56+
validate: Boolean,
5657
) {
5758
workDir.deleteRecursive()
5859
workDir.createDirectories()
@@ -61,7 +62,7 @@ abstract class ApplySourceATs {
6162
workDir,
6263
workDir.resolve("log.txt"),
6364
jvmArgs = listOf("-Xmx${memory.get()}"),
64-
args = jstArgs(input, output, atFile, singleFile).toTypedArray()
65+
args = jstArgs(input, output, atFile, singleFile, validate).toTypedArray()
6566
)
6667
}
6768

@@ -70,16 +71,18 @@ abstract class ApplySourceATs {
7071
outputDir: Path,
7172
atFile: Path,
7273
singleFile: Boolean = false,
74+
validate: Boolean,
7375
): List<String> {
7476
val format = if (singleFile) "FILE" else "FOLDER"
77+
val validation = if (validate) "ERROR" else "LOG"
7578
return listOf(
7679
"--in-format=$format",
7780
"--out-format=$format",
7881
"--enable-accesstransformers",
7982
"--access-transformer=$atFile",
8083
"--access-transformer-inherit-method=true",
8184
"--hidden-prefix=.git",
82-
// "--access-transformer-validation=ERROR",
85+
"--access-transformer-validation=$validation",
8386
*jstClasspath.files.map { "--classpath=${it.absolutePath}" }.toTypedArray(),
8487
inputDir.absolutePathString(),
8588
outputDir.absolutePathString(),

0 commit comments

Comments
 (0)