Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,6 @@ abstract class PaperweightCoreExtension @Inject constructor(objects: ObjectFacto
fun updatingMinecraft(action: Action<UpdatingMinecraftExtension>) {
action.execute(updatingMinecraft)
}

val validateAts: Property<Boolean> = objects.property<Boolean>().convention(false)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it'd be good for this to be on by default?

}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class CoreTasks(
atFile.set(mergePaperATs.flatMap { it.outputFile })
ats.jstClasspath.from(project.configurations.named(MACHE_MINECRAFT_LIBRARIES_CONFIG))
ats.jst.from(project.configurations.named(JST_CONFIG))
validateAts.set(project.coreExt.validateAts)
}

val extractMacheSources by tasks.registering(ExtractMinecraftSources::class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import io.papermc.paperweight.core.tasks.patching.ApplyFilePatches
import io.papermc.paperweight.core.tasks.patching.ApplyFilePatchesFuzzy
import io.papermc.paperweight.core.tasks.patching.FixupFilePatches
import io.papermc.paperweight.core.tasks.patching.RebuildFilePatches
import io.papermc.paperweight.core.util.coreExt
import io.papermc.paperweight.tasks.*
import io.papermc.paperweight.util.*
import io.papermc.paperweight.util.constants.*
Expand Down Expand Up @@ -171,6 +172,7 @@ class MinecraftPatchingTasks(
atFile.set(mergeCollectedAts.flatMap { it.outputFile })
ats.jst.from(project.configurations.named(JST_CONFIG))
ats.jstClasspath.from(project.configurations.named(MACHE_MINECRAFT_LIBRARIES_CONFIG))
validateAts.set(project.coreExt.validateAts)
}

applySourcePatches.configure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ abstract class SetupForkMinecraftSources : JavaLauncherTask() {
@get:Optional
abstract val atFile: RegularFileProperty

@get:Input
abstract val validateAts: Property<Boolean>

@get:Optional
@get:InputDirectory
abstract val libraryImports: DirectoryProperty
Expand Down Expand Up @@ -86,6 +89,7 @@ abstract class SetupForkMinecraftSources : JavaLauncherTask() {
outputDir.path,
atFile.path,
atWorkingDir.path,
validate = validateAts.get(),
)
commitAndTag(git, "ATs", "${identifier.get()} ATs")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ abstract class SetupMinecraftSources : JavaLauncherZippedTask() {
@get:Input
abstract val oldPaperCommit: Property<String>

@get:Optional
@get:Input
abstract val validateAts: Property<Boolean>

@get:Nested
val ats: ApplySourceATs = objects.newInstance()

Expand Down Expand Up @@ -182,6 +186,7 @@ abstract class SetupMinecraftSources : JavaLauncherZippedTask() {
outputPath,
atFile.path,
atWorkingDir.path,
validate = validateAts.get(),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is guaranteed not to fail as this piece of code won't run if there is no at file specified and right now if the at file gets specified, this property also gets set.

The property was marked as optional due to the setupMacheResources task which uses the same task but doesn't specify ATs and i saw no point in wiring the validation property to it if no ats are gonna be applied anyway.

)
if (!oldPaperCommit.isPresent) {
commitAndTag(git, "ATs", "paper ATs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ abstract class RebuildFilePatches : JavaLauncherTask() {
at,
temporaryDir.toPath().resolve("jst_work"),
singleFile = true,
validate = false,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be made to always validate? the new AT lines should never be inapplicable but if such a situation were to happen it would be nice for it to blow up during saving them instead of failing during apply

)
println("NEW: " + decomp.readText())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ abstract class ApplySourceATs {
atFile: Path,
workDir: Path,
singleFile: Boolean = false,
validate: Boolean,
) {
workDir.deleteRecursive()
workDir.createDirectories()
Expand All @@ -61,7 +62,7 @@ abstract class ApplySourceATs {
workDir,
workDir.resolve("log.txt"),
jvmArgs = listOf("-Xmx${memory.get()}"),
args = jstArgs(input, output, atFile, singleFile).toTypedArray()
args = jstArgs(input, output, atFile, singleFile, validate).toTypedArray()
)
}

Expand All @@ -70,16 +71,18 @@ abstract class ApplySourceATs {
outputDir: Path,
atFile: Path,
singleFile: Boolean = false,
validate: Boolean,
): List<String> {
val format = if (singleFile) "FILE" else "FOLDER"
val validation = if (validate) "ERROR" else "LOG"
return listOf(
"--in-format=$format",
"--out-format=$format",
"--enable-accesstransformers",
"--access-transformer=$atFile",
"--access-transformer-inherit-method=true",
"--hidden-prefix=.git",
// "--access-transformer-validation=ERROR",
"--access-transformer-validation=$validation",
*jstClasspath.files.map { "--classpath=${it.absolutePath}" }.toTypedArray(),
inputDir.absolutePathString(),
outputDir.absolutePathString(),
Expand Down
Loading