Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add system for publishing and consuming ATs #146

Merged
merged 8 commits into from
May 13, 2024

Conversation

lukebemish
Copy link
Contributor

@lukebemish lukebemish commented Apr 17, 2024

Currently, a limit of access transformers is that, if you wish to use a vanilla class you've ATed in a mod's API, every dependent must independently apply the AT in question. This PR offers a solution to this, that does not have the worries associated with it of "transitive ATs" or similar concepts, and is no less safe in terms of modders forgetting a mods.toml dependency than existing implementation dependencies are.

Goals

  • allow mods built as multi-project systems to easily share ATs between subprojects
  • allow mods to publish AT files in a consumable fashion
  • allow mods to consume specifically published ATs of specific modules

Non-goals

  • automatic detection of ATs from dependencies -- depending on an AT requires an explicit dependency on the ATs of the module, avoiding any sort of automatic detection, mitigating the chances of a modder depending on an AT of an optional dependency that is not present in production.
  • Any sort of discovery from dependency jars -- fg.deobf sucked and we don't want it back.

To expose an AT file, a mod would do the following:

accessTransformers {
    expose project.file("src/main/resources/META-INF/accesstransformers.cfg")
}

This publishes the AT file as a new variant of the project with the accesstransformer category.

To consume the AT of a module requires an additional dependency on it beyond the normal implementation or the like:

dependencies {
    implementation "org.example:somemod:0.1.0"
    implementation "org.example:anothermod:0.2.0"
}

accessTransformers {
    consume "org.example:somemod:0.1.0" // pulls in the published AT file of org.example:somemod
    consumeApi "org.example:anothermod:0.2.0" // pulls in the published AT file of org.example:anothermod, and additionally exposes it transitively in accessTransformerElements
}

Note that the explicit need to declare a dependency on the access transformers of the module makes this no less safe, in terms of forgetting to declare a mods.toml dependency, than a normal implementation dependency on a mod and the use of its classes would; a mod cannot "accidentally" consume a foreign AT file.

@neoforged-pr-publishing
Copy link

  • Publish PR to GitHub Packages

@sciwhiz12 sciwhiz12 added the enhancement New feature or request label Apr 18, 2024
@Technici4n
Copy link
Member

I don't like this feature for the simple reason that it is niche and requires advanced Gradle knowledge to use or understand. If we add many such features the code will become unmaintainable.

@lukebemish
Copy link
Contributor Author

What advanced knowledge does this require to use? It was built expressly to require very little gradle knowledge to use.

@marchermans marchermans merged commit 8faf299 into neoforged:NG_7.0 May 13, 2024
24 of 26 checks passed
@lukebemish lukebemish deleted the at-publishing branch May 13, 2024 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants