Skip to content
New issue

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

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

Already on GitHub? # to your account

Dependency implementation problem on fabric #49

Closed
starobot opened this issue Nov 7, 2024 · 6 comments
Closed

Dependency implementation problem on fabric #49

starobot opened this issue Nov 7, 2024 · 6 comments

Comments

@starobot
Copy link

starobot commented Nov 7, 2024

Could you please provide the necessary dependencies for the fabric mod? Can’t get the library to work outside of IDE upon building the mod.

@RaphiMC
Copy link
Owner

RaphiMC commented Nov 7, 2024

This library is not dependent on any Minecraft version, so there should be no problem integrating it into any Minecraft version. Describe your issue with more detail. What does not work?

@starobot
Copy link
Author

starobot commented Nov 7, 2024

Well, I noticed that the library does not get built within the mod unless the “implementation group:name:version” is changed to “include group:name:version”. Before it used to crash with the exception saying that the classes from the library are missing, but now with the “include” the classes that use the library just don’t work.
For example, the provided in the README method of getting the javaSession works perfectly inside IDE, but fails immediately as a built mod

@RaphiMC
Copy link
Owner

RaphiMC commented Nov 7, 2024

The way you include the dependency in fabric differs from the regular java/gradle project setup. Thats why you need to use include instead of implementation. The missing class error is most likely caused by fabric not including transitive dependencies in the built mod (You can read more about that here: https://fabricmc.net/wiki/documentation:fabric_loom). To fix that you need to manually include the transitive dependencies (See https://github.com/RaphiMC/MinecraftAuth/blob/98805b690618140890d9c4c1b2eba16994f1403e/build.gradle#L30-L36C20). Fabric does this to encourage mod devs to not blindly include dependencies which are already in Minecraft. In this case you would need to not include gson and slf4j-api.

Recently I added the option to use MinecraftAuth without the JWT dependency (Which means you would only need to additionally include net.lenni0451.commons:httpclient:1.6.1). This version of MinecraftAuth isn't published on maven central yet, so you would need to add a custom maven server (https://maven.lenni0451.net/#/snapshots/net/raphimc/MinecraftAuth/4.1.2-SNAPSHOT) if you want to use that.

@RaphiMC
Copy link
Owner

RaphiMC commented Nov 7, 2024

There seems to be a way to include transitive dependencies in fabric which is explained here: https://gist.github.com/jakobkmar/3c7e68ff57957d647a37ed568e5068c7

You need to pay special attention to exclude the dependencies which are already in Minecraft

@starobot
Copy link
Author

starobot commented Nov 7, 2024

Well, apparently, it's all fixed by using:

includeInternal 'net.raphimc:MinecraftAuth:4.1.1'

Thanks , for the help!
I think you should add this info somewhere because potentially I might not be the only one having that issue with the fabric dependency.

@RaphiMC
Copy link
Owner

RaphiMC commented Nov 7, 2024

Interesting. Seems like loom has transitive include internally all along. I will pin the issue, so its easy to find

@RaphiMC RaphiMC closed this as completed Nov 7, 2024
@RaphiMC RaphiMC pinned this issue Nov 7, 2024
@RaphiMC RaphiMC changed the title Dependecy implementation problem on fabric Dependency implementation problem on fabric Nov 7, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants