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

Stop recommending that mods depend on an optional dependency via runtimeOnly #48

Merged
merged 3 commits into from
Apr 28, 2024

Conversation

lukebemish
Copy link

@lukebemish lukebemish commented Apr 21, 2024

Currently, the MDK has an example dependency, commented out, on JEI using compileOnly and runtimeOnly. It is implied that this is an optional dependency, both as JEI is normally an optional dependency and because implementation is not used. However, the use of runtimeOnly does not create an optional dependency; runtimeOnly adds a dependency to both runtimeClasspath (what gets used in dev to run the game) and runtimeElements (the dependencies you publish, in a pom or module metadata, as "I need these at runtime"). This means that any mod depending on a mod that depends on JEI this way will attempt to pull in JEI at runtime as a transitive dependency! This was not an issue with old forgegradle, as fg.deobf stripped all transitive dependencies, but it is an issue now and the MDK should recommend good practice. As an optional dependency, it should be added only to runtimeClasspath, which must be done through another configuration as runtimeClasspath cannot have dependencies directly declared. This PR solves this in the correct way.

@lukebemish
Copy link
Author

Note: this really is something where the MDK ought to display good practice, as I have seen mods out in the wild copying what the MDK does for this type of dependency and so publishing bad transitive runtime dependencies which get pulled in by anything trying to depend on them.

@marchermans
Copy link

What are we actually trying to achieve here?
As far as I understand it, the optional dependencies should not really be exposed on publication anyway correct?

As such I think adding them as a run dependency, instead of a configuration is the better approach. Is it not?

@Matyrobbrt
Copy link
Member

Matyrobbrt commented Apr 21, 2024

Mods cannot be declared as run dependencies, as that sets them up on the wrong layer. And runtimeOnly is transitive for consumers of your artifact.

@lukebemish
Copy link
Author

What maty said; plus, run-specific dependencies are confusing when people are used to dependencies in the dependencies block, and runtime-local dependencies should not be an "advanced" thing by any means. The run-specific dependency block seems primarily meant for being fed into the task that generated the minecraft classpath; that's not the issue here, the issue is preventing publishing of something where depending on it normally is just fine.

@marchermans
Copy link

What maty said; plus, run-specific dependencies are confusing when people are used to dependencies in the dependencies block, and runtime-local dependencies should not be an "advanced" thing by any means. The run-specific dependency block seems primarily meant for being fed into the task that generated the minecraft classpath; that's not the issue here, the issue is preventing publishing of something where depending on it normally is just fine.

Yes and I agree that this is the correct solution.
However, the simplest thing for runtime-local dependencies, is the mods folder. Don't you agree?

@lukebemish
Copy link
Author

lukebemish commented Apr 21, 2024

No, I don't agree. These aren't "I want this in dev for convenience" dependencies, these are "I'm compiling against this and need to test with it" dependencies. If you're declaring a gradle dep on it to compile against it, you want to be able to use gradle for the testing dependency too. Beyond that -- you can't/shouldn't commit the mods folder to git. People want their optional dependencies on git so that if they clone the repo fresh, it's good to go

@shartte
Copy link

shartte commented Apr 21, 2024

However, the simplest thing for runtime-local dependencies, is the mods folder. Don't you agree?

I hope you are not suggesting that I download JEI, EMI, Curios and REI by hand and place them there 👀

@Shadows-of-Fire Shadows-of-Fire merged commit a780f58 into neoforged:main Apr 28, 2024
1 check passed
@lukebemish lukebemish deleted the local-runtime-fix branch April 28, 2024 05:50
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.

6 participants