Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3665104
feat: allow for specifying ATs for upstream sources
Toffikk Jan 25, 2026
55d76c0
chore: remove unnecessary this@PatchingTasks specifier
Toffikk Jan 26, 2026
3ddbc21
chore: cleanup tagging logic
Toffikk Jan 27, 2026
4f1edf1
fix: provide compile classpath for JST
Toffikk Feb 3, 2026
617e64b
chore: indent
Toffikk Feb 3, 2026
aca60da
fix: provide the classpaths of subprojects
Toffikk Feb 3, 2026
6fd4a2a
fix: append the mache minecraft jar to JST's classpath
Toffikk Feb 3, 2026
575a6a0
format
Toffikk Feb 3, 2026
09cce04
fix(normal AT logic/paperweight issue): append compile classpath for …
Toffikk Feb 3, 2026
d6b74bf
Revert "fix(normal AT logic/paperweight issue): append compile classp…
Toffikk Feb 3, 2026
d7015e4
chore: cleanup impl
Toffikk Feb 24, 2026
81c147d
fix: resolve gradle errors while running upstream setup
Toffikk Feb 24, 2026
a20d4ac
fix: workaround the latest review
Toffikk Feb 24, 2026
9b14741
chore: format
Toffikk Feb 24, 2026
209e911
Update Gradle wrapper
jpenilla Feb 27, 2026
be36f8d
fix(deps): update junit-framework monorepo to v6.0.3
renovate[bot] Feb 15, 2026
213a301
chore(deps): update mikepenz/action-junit-report action to v6
renovate[bot] Dec 15, 2025
8236b2b
fix(deps): update asm to v9.9.1
renovate[bot] Feb 27, 2026
d964e87
Prepare for 26.1 (#382)
jpenilla Mar 6, 2026
c58fb68
fix(deps): update dependency com.gradleup.shadow:com.gradleup.shadow.…
renovate[bot] Feb 28, 2026
0af45d0
fix(deps): update dependency io.mockk:mockk to v1.14.9
renovate[bot] Mar 5, 2026
a2800e4
add back updatingMinecraft prop check for patch roulette tasks
jpenilla Mar 15, 2026
a243362
Initial userdev update for dev bundle v8
jpenilla Apr 3, 2026
f3beb76
Initial userdev update for dev bundle v8
jpenilla Apr 3, 2026
f64b04d
release: Version 2.0.0-beta.20
jpenilla Apr 3, 2026
626c75f
2.0.0-SNAPSHOT
jpenilla Apr 3, 2026
2357a1a
Add missing V7 check in SetupHandler.kt
jpenilla Apr 3, 2026
13ea400
release: Version 2.0.0-beta.21
jpenilla Apr 3, 2026
28cbae3
2.0.0-SNAPSHOT
jpenilla Apr 3, 2026
650c8e3
Set JVM target attribute on reobf variant
jpenilla Apr 4, 2026
ec2dcfb
Introduce a dependency bridge plugin
Toffikk Apr 24, 2026
f2b5b84
Merge remote-tracking branch 'papermc/main' into feat/ats-for-upstrea…
Toffikk Apr 24, 2026
d8881c6
Provide a more comprehensive classpath for MC AT application to decre…
Toffikk Apr 24, 2026
2a976f2
fix: dont trigger compileJava for the API subproject
Toffikk Apr 25, 2026
a0a6d1b
fix: don't fail on clean run
Toffikk Apr 25, 2026
283ee51
actually fix
Toffikk Apr 25, 2026
752b4dc
revert unnecessary changes
Toffikk Apr 25, 2026
3e9d77f
final tweaks
Toffikk Apr 25, 2026
d4fa08c
Dirty workaround for upstream ATs
Toffikk Apr 28, 2026
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
@@ -0,0 +1,42 @@
/*
* paperweight is a Gradle plugin for the PaperMC project.
*
* Copyright (c) 2023 Kyle Wood (DenWav)
* 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

import io.papermc.paperweight.util.constants.JST_CLASSPATH_ATTRIBUTE
import io.papermc.paperweight.util.constants.JST_CLASSPATH_CONFIG
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPlugin

abstract class PaperweightDependencyBridge : Plugin<Project> {
override fun apply(target: Project) {
target.configurations.register(JST_CLASSPATH_CONFIG) {
isCanBeConsumed = true
attributes {
attribute(JST_CLASSPATH_ATTRIBUTE, true)
}
extendsFrom(target.configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME))
}
target.rootProject.dependencies.add(JST_CLASSPATH_CONFIG, target)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ abstract class PaperweightCore : Plugin<Project> {
}
}

target.configurations.register(JST_CLASSPATH_CONFIG) {
attributes {
attribute(JST_CLASSPATH_ATTRIBUTE, true)
}
extendsFrom(
target.configurations.getByName(MACHE_MINECRAFT_CONFIG),
target.configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME)
)
}

// impl extends minecraft
target.configurations.named(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME) {
extendsFrom(macheMinecraftLibrariesConfig.get())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ProviderFactory
import org.gradle.api.provider.SetProperty
import org.gradle.kotlin.dsl.*

Expand Down Expand Up @@ -93,6 +94,7 @@ abstract class UpstreamConfig @Inject constructor(

abstract class DirectoryPatchSet @Inject constructor(
objects: ObjectFactory,
providers: ProviderFactory,
private val setName: String,
) : Named {
override fun getName(): String = setName
Expand All @@ -101,6 +103,8 @@ abstract class UpstreamConfig @Inject constructor(
abstract val excludes: SetProperty<String>

abstract val outputDir: DirectoryProperty
val buildDataDir: DirectoryProperty = objects.directoryProperty().convention(outputDir.dir("../build-data"))
val additionalAts: RegularFileProperty = objects.fileFrom(buildDataDir, providers.provider { "$name.at" })

abstract val patchesDir: DirectoryProperty
val rejectsDir: DirectoryProperty = objects.dirFrom(patchesDir, "rejected")
Expand All @@ -110,8 +114,9 @@ abstract class UpstreamConfig @Inject constructor(

abstract class RepoPatchSet @Inject constructor(
objects: ObjectFactory,
providers: ProviderFactory,
name: String,
) : DirectoryPatchSet(objects, name) {
) : DirectoryPatchSet(objects, providers, name) {
abstract val upstreamRepo: Property<DirectoryPatchSet>

fun Provider<ForkConfig>.patchedRepo(name: String): Provider<DirectoryPatchSet> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class MinecraftPatchingTasks(
libraryImports.set(importLibFiles.flatMap { it.outputDir })
atFile.set(mergeCollectedAts.flatMap { it.outputFile })
ats.jst.from(project.configurations.named(JST_CONFIG))
ats.jstClasspath.from(project.configurations.named(MACHE_MINECRAFT_LIBRARIES_CONFIG))
ats.jstClasspath.from(project.configurations.named(JST_CLASSPATH_CONFIG))
}

applySourcePatches.configure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,23 @@

package io.papermc.paperweight.core.taskcontainers

import io.papermc.paperweight.core.tasks.SetupForkUpstreamSources
import io.papermc.paperweight.core.tasks.patching.ApplyFeaturePatches
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.tasks.*
import io.papermc.paperweight.util.*
import io.papermc.paperweight.util.constants.JST_CLASSPATH_CONFIG
import io.papermc.paperweight.util.constants.JST_CONFIG
import io.papermc.paperweight.util.constants.paperTaskOutput
import java.nio.file.Path
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.file.Directory
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.TaskContainer
import org.gradle.kotlin.dsl.*
Expand All @@ -48,6 +52,7 @@ class PatchingTasks(
private val filePatchDir: DirectoryProperty,
private val rejectsDir: DirectoryProperty,
private val featurePatchDir: DirectoryProperty,
private val additionalAts: RegularFileProperty,
private val baseDir: Provider<Directory>,
private val gitFilePatches: Provider<Boolean>,
private val filterPatches: Provider<Boolean>,
Expand Down Expand Up @@ -110,6 +115,43 @@ class PatchingTasks(
}
}

fun setupUpstream() {
val collectAccessTransform = tasks.register<CollectATsFromPatches>("collect${namePart}ATsFromPatches") {
patchDir.set(featurePatchDir.fileExists())
}

val mergeCollectedAts = tasks.register<MergeAccessTransforms>("merge${namePart}ATs") {
firstFile.set(additionalAts.fileExists())
secondFile.set(collectAccessTransform.flatMap { it.outputFile })
}

val setup = tasks.register<SetupForkUpstreamSources>("run${namePart}Setup") {
description = "Applies $forkName ATs to $namePart sources"

inputDir.set(baseDir)
outputDir.set(layout.cache.resolve(paperTaskOutput()))
identifier.set(namePart)

atFile.set(mergeCollectedAts.flatMap { it.outputFile })
ats.jst.from(project.configurations.named(JST_CONFIG))
ats.jstClasspath.from(project.configurations.named(JST_CLASSPATH_CONFIG))
}

applyFilePatches.configure {
input.set(setup.flatMap { it.outputDir })
}

applyFilePatchesFuzzy.configure {
input.set(setup.flatMap { it.outputDir })
}
val name = "rebuild${namePart}FilePatches"
if (name in tasks.names) {
tasks.named<RebuildFilePatches>(name) {
base.set(setup.flatMap { it.outputDir })
}
}
}

private fun setupWritable() {
listOf(
applyFilePatches,
Expand All @@ -129,6 +171,11 @@ class PatchingTasks(
input.set(outputDir)
patches.set(filePatchDir)
gitFilePatches.set(this@PatchingTasks.gitFilePatches)

ats.jstClasspath.from(project.configurations.named(JST_CLASSPATH_CONFIG))
ats.jst.from(project.configurations.named(JST_CONFIG))
atFile.set(additionalAts.fileExists())
atFileOut.set(additionalAts.fileExists())
}

val fixupFilePatches = tasks.register<FixupFilePatches>(fixupFilePatchesName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class UpstreamConfigTasks(
createBaseFromDirectoryInRepo(cfg)
}

return PatchingTasks(
val tasks = PatchingTasks(
target,
forkName,
cfg.name,
Expand All @@ -127,11 +127,14 @@ class UpstreamConfigTasks(
cfg.filePatchDir,
cfg.rejectsDir,
cfg.featurePatchDir,
cfg.additionalAts,
base,
gitFilePatches,
filterPatches,
cfg.outputDir.path,
)
tasks.setupUpstream()
return tasks
}

private fun createBaseFromRepo(cfg: UpstreamConfig.RepoPatchSet): Provider<Directory> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* paperweight is a Gradle plugin for the PaperMC project.
*
* Copyright (c) 2023 Kyle Wood (DenWav)
* 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.core.tasks

import io.papermc.paperweight.core.util.ApplySourceATs
import io.papermc.paperweight.tasks.*
import io.papermc.paperweight.util.*
import kotlin.io.path.*
import org.eclipse.jgit.api.Git
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Nested
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.*

abstract class SetupForkUpstreamSources : JavaLauncherTask() {

@get:InputDirectory
abstract val inputDir: DirectoryProperty

@get:OutputDirectory
abstract val outputDir: DirectoryProperty

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

@get:InputFile
@get:Optional
abstract val atFile: RegularFileProperty

@get:Input
abstract val identifier: Property<String>

@TaskAction
fun run() {
val out = outputDir.path.cleanDir()
inputDir.path.copyRecursivelyTo(out)

val git = Git.open(outputDir.path.toFile())

if (atFile.isPresent && atFile.path.readText().isNotBlank()) {
println("Applying access transformers...")
ats.run(
launcher.get(),
inputDir.path,
outputDir.path,
atFile.path,
temporaryDir.toPath(),
)
commitAndTag(git, "ATs", "${identifier.get()} ATs")
}
commitAndTag(git, "base")

git.close()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,34 @@ abstract class PaperweightPatcher : Plugin<Project> {
delete(target.layout.cache)
}

target.afterEvaluate { afterEvaluate(patcher) }
target.configurations.register(JST_CONFIG) {
defaultDependencies {
// add(project.dependencies.create("net.neoforged.jst:jst-cli-bundle:${LibraryVersions.JST}"))
add(target.dependencies.create("io.papermc.jst:jst-cli-bundle:${LibraryVersions.JST}"))
}
}

target.configurations.register(JST_CLASSPATH_CONFIG) {
attributes {
attribute(JST_CLASSPATH_ATTRIBUTE, true)
}
}

target.afterEvaluate {
repositories {
maven(patcher.jstRepo) {
name = JST_REPO_NAME
content { onlyForConfigurations(JST_CONFIG) }
}
maven(PAPER_MAVEN_REPO_URL) {
content { onlyForConfigurations(JST_CLASSPATH_CONFIG) }
}
mavenCentral {
content { onlyForConfigurations(JST_CLASSPATH_CONFIG) }
}
}
afterEvaluate(patcher)
}
}

private fun Project.afterEvaluate(patcher: PaperweightPatcherExtension) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package io.papermc.paperweight.patcher.extension

import io.papermc.paperweight.core.extension.UpstreamConfig
import io.papermc.paperweight.util.constants.PAPER_MAVEN_REPO_URL
import javax.inject.Inject
import org.gradle.api.Action
import org.gradle.api.NamedDomainObjectContainer
Expand All @@ -37,6 +38,8 @@ abstract class PaperweightPatcherExtension @Inject constructor(private val objec
val gitFilePatches: Property<Boolean> = objects.property<Boolean>().convention(false)
val filterPatches: Property<Boolean> = objects.property<Boolean>().convention(true)

val jstRepo: Property<String> = objects.property<String>().convention(PAPER_MAVEN_REPO_URL)

val upstreams: NamedDomainObjectContainer<UpstreamConfig> = objects.domainObjectContainer(UpstreamConfig::class) {
objects.newInstance(it, true)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
implementation-class=io.papermc.paperweight.PaperweightDependencyBridge
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package io.papermc.paperweight.util.constants

import org.gradle.api.Task
import org.gradle.api.attributes.Attribute

const val PAPERWEIGHT_EXTENSION = "paperweight"
const val PAPER_CHECKSTYLE_EXTENSION = "paperCheckstyle"
Expand Down Expand Up @@ -53,16 +54,20 @@ const val MACHE_MINECRAFT_LIBRARIES_CONFIG = "macheMinecraftLibraries"
const val MACHE_MINECRAFT_CONFIG = "macheMinecraft"
const val MAPPED_JAR_OUTGOING_CONFIG = "mappedJarOutgoing"
const val JST_CONFIG = "javaSourceTransformer"
const val JST_CLASSPATH_CONFIG = "jstClasspath"
const val DEV_BUNDLE_CONFIG = "paperweightDevelopmentBundle"
const val MOJANG_MAPPED_SERVER_CONFIG = "mojangMappedServer"
const val MOJANG_MAPPED_SERVER_RUNTIME_CONFIG = "mojangMappedServerRuntime"
const val REOBF_CONFIG = "reobf"

val JST_CLASSPATH_ATTRIBUTE = Attribute.of("io.papermc.paperweight.jst-classpath", Boolean::class.javaObjectType)

const val PARAM_MAPPINGS_REPO_NAME = "paperweightParamMappingsRepository"
const val DECOMPILER_REPO_NAME = "paperweightDecompilerRepository"
const val REMAPPER_REPO_NAME = "paperweightRemapperRepository"
const val PLUGIN_REMAPPER_REPO_NAME = "paperweightPluginRemapperRepository"
const val MACHE_REPO_NAME = "paperweightMacheRepository"
const val JST_REPO_NAME = "paperweightJstRepository"

const val CACHE_PATH = "caches"
private const val PAPER_PATH = "paperweight"
Expand Down
Loading