Skip to content

feat: allow for specifying ATs for upstream sources#377

Open
Toffikk wants to merge 10 commits intoPaperMC:mainfrom
CraftCanvasMC:feat/ats-for-upstream-sources
Open

feat: allow for specifying ATs for upstream sources#377
Toffikk wants to merge 10 commits intoPaperMC:mainfrom
CraftCanvasMC:feat/ats-for-upstream-sources

Conversation

@Toffikk
Copy link
Contributor

@Toffikk Toffikk commented Jan 25, 2026

These changes provide fork developers with a way to specify an AT file (or have it detected automatically) for upstream sources, such as paper-server and paper-api for a fork of Paper. This allows fork developers to benefit from using ATs while modifying these sources without needing to clutter patches, with lots of manual access transforms, and as such this greatly improves the overall comfort of making more involving changes, in the sources. It also allows for fork devs to be able to organize ATs in one place which makes it easier to review later.

The implementation proposed in this commit works as follows:

  1. Derive the location of the build-data dir from the output dir specified in the PatchRepo/Directory's config.
    • This sounds like it should be ideally derived from either the Project instance or Layout by injecting, however we cannot do it this way, as the upstream server projects are set up in the fork’s server project, not as part of the upstream setup like API is, meaning they either can’t access their ATs or other issues appear. The layout approach has even more downsides as it inherits the downsides of the aforementioned approach and the build-data dir would be forced to appear in the server project.
    • Therefore, I believe using the outputDir to calculate the possible root project is the best way to make it work, as it works on fork setups and doesn’t cause issues, and we can also safely assume that it will work for everyone as every fork and fork template is following the convention of specifying their outputDir’s in a subfolder of the root project, and regardless it can be overrode like the minecraft AT file currently can be so this is correct in practice.
  2. Search for an AT file, by the name of the patch repo/directory as specified.
  3. Apply them before applying source patches.

The locations in steps 1 and 2 can be overriden per patch repo/directory by just overriding the val.

In order to achieve this change, we introduce a new task, with its implementation sitting in SetupForkUpstreamSources which applies those ATs. Everything else not explained here or even explained should follow the behaviour of AT application for minecraft sources.

The change has been tested in production in an organisation fork of paperweight for over 6 months with both a nested fork project that uses them heavily and then fork projects depending on the nested fork project, and no issues have been reported or arose, so i'm confident that this implementation will work properly.

For additional reference:

  • weaver -> where this impl was implemented first and tested
  • Baguette -> an example fork using this feature

These changes provide fork developers with a way to specify an AT file (or have it detected automatically) for upstream sources,
such as `paper-server` and `paper-api` for a fork of Paper.
This allows fork developers to benefit from using ATs while modifying these sources without needing to clutter patches,
with lots of manual access transforms, and as such this greatly improves the overall comfort of making more involving changes,
in the sources. It also allows for fork devs to be able to organize ATs in one place which makes it easier to review later.

The implementation proposed in this commit works as follows:
1. Derive the location of the build-data dir from the output dir specified in the PatchRepo/Directory's config.
2. Search for an AT file, by the name of the patch repo/directory as specified.
3. Apply them before applying source patches.

The locations in steps 1 and 2 can be overriden per patch repo/directory by just overriding the val.

In order to achieve this change, we introduce a new task, with its implementation sitting in SetupForkUpstreamSources which applies those ATs.
Everything else not explained here or even explained should follow the behaviour of AT application for minecraft sources.

The change has been tested in production in an organisation fork of paperweight for over 6 months with both a nested fork project that uses them heavily and then fork projects depending on the nested fork project,
and no issues have been reported or arose, so i'm confident that this implementation will work properly.
@Toffikk Toffikk force-pushed the feat/ats-for-upstream-sources branch from 342d27d to 3665104 Compare January 26, 2026 00:02
@Toffikk
Copy link
Contributor Author

Toffikk commented Jan 26, 2026

note: if #376 gets merged before this, this pr needs to be updated,
however if this gets merged first, then the other pr needs to be updated.
(i already have the proper changes on my local fork)

@Toffikk Toffikk force-pushed the feat/ats-for-upstream-sources branch from 8cc10ea to 55d76c0 Compare January 26, 2026 13:03
@Toffikk Toffikk force-pushed the feat/ats-for-upstream-sources branch from 310f23a to 4f1edf1 Compare February 3, 2026 17:27
@Toffikk Toffikk force-pushed the feat/ats-for-upstream-sources branch from 9f01971 to 617e64b Compare February 3, 2026 17:31
This is needed for being fully able to represent types in API projects as they are resolved from the root project and not nested, meaning the compile classpath passed is null as its from the root project.
fixes more binary representation issues
…minecraft ATs

This fixes some issues with JST and forks as there are custom types from the API imported by paper, which arent contained in the mache libraries config and that causes JST to fail to create binary representations for some methods/classes thus not allowing to AT them, this fixes it
@Toffikk Toffikk force-pushed the feat/ats-for-upstream-sources branch from 951a35a to 09cce04 Compare February 3, 2026 19:33
…ath for minecraft ATs"

This reverts commit 09cce04.

seems to fail the tests for some reason, a dev can take a look at this, although the output of the log file is correct locally
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant