Jump to content

[1.18.1][SOLVED] Importing files from Github as a depedency


Newek97

Recommended Posts

I'm kind of new to minecraft modding, and didn't used Gradle or any repository before, so I'm pretty confused with all this stuff. I've been struggling for a few days now to import any mod API in my dev environment through my build.gradle, and finally managed to suceed with JEI. But I'm now attempting to import Baubles : Reborn? API from Github, and followed indications from an old thread. But since they were given for ForgeGradle 4, the method compile doesn't exist anymore in 5.1 it seems. I tried the following instead :

repository { maven { url 'https://jitpack.io' } }
depedencies { compileOnly files('com.github.lazyMods:baubles:1.18:api') }

And if it doesn't throw any error upon rebuilding, it doesn't seem to work either. My question is : how do I import files as a compile and/or runtime depedency from a given repository (including a local repo, say projectDir/libs) ? Here is my full build.gradle file. Thanks !

Edited by Newek97
Added repository declaration for more clarity
Link to comment
Share on other sites

Thanks, I'll try to investigate a bit more with the implementation method, but for now it throws me error because it can't find .pom or .jar files, which is still an improvement !

Now how do I specify on which configuration I want to use this depedency ? Do I simply add compileOnly before the implementation method like before ? I'd want to try out soft depedency with Baubles, and as such I need to make the mod avaible or not during runtime.

Link to comment
Share on other sites

  Ok, so I did some investigations and after a lot of trial and error, I finally came up with a solution. I will try to explain what I did, and why, for anyone who might need it.

From what I understood, implementation will add a depedency for both compiling and runtime (pretty sure it will only include API files for compiling if there are, but I'm not 100% sure), and will resolve any nested depedencies aswell, so its kinda neat if one's mod permenently depends on other's mod or API ! Though I need to control whether a mod is included during runtime or not, so I need to specify the scope of my depedencies.

I did some searches, and it turned out that Gradle will consume either jars or source folders regardless, so there is not a specific way to deal with one or the other it seems. I then tried the following and it worked like a charm (modified the commit branch / tags so its pointing to a permanent commit, more info here) !

depedencies {
  compileOnly 'com.github.lazyMods:baubles:1.10.0.0-1.18:api'
  runtimeOnly 'com.github.lazyMods:baubles:1.10.0.0-1.18'
}

But, whenever I try to run, the game crashes with a NoSuchMethod exception, pointing towards a method MenuScreens::m_96206_ called within the Baubles main class during ClientSetup (which is the unmapped name of MenuScreens::register) ; which is clearly a mapping issue. It confused me at first, but now that I think of it it's quite obvious : trying to run the game with uncompiled source files will cause all sorts of issues. And even if Jitpack seems to compile on the go those files, it will lack any metadata expected by Forge or ForgeGradle, so it's no use anyway.

The only two solutions I can think of are :

  1. Download the mod jar, put it in a libs folder inside your workingDir that you can settup as a local repository, then add that jar as a runtime depedency
  2. Use CurseMaven as a repository (as @diesieben07 suggested), and add the correct mod jar as a depedency (more info here)

I chose the latter, so now I have the following in my build.gradle file, and it works perfectly (one can even remove the ":api" from the baubles depedency to show the entire mod source files in Eclipse) :

repositories {
  	maven { url "https://cursemaven.com" content { includeGroup "curse.maven" } }
  	maven { url "https://jitpack.io" }
}

depedencies {
 	compileOnly "com.github.lazyMods:baubles:1.10.0.0-1.18:api"
  	runtimeOnly fg.deobf("curse.maven:baubles-366844:3576950") // Points toward Baubles: Reborn? v1.10.0.1-1.18.1 on curseforge.com
}

I couldn't use CurseMaven straight up as lazynessmind didn't provide a source jar or an api jar on curse forge just yet, so I had to use its Github instead to get the API, hence the struggle. I could have added the mod jar itself as an API, but then I would have to manualy add the source files for Eclipse, which then makes this whole "manage your depedencies solely with Gradle" obsolete...

 

Thanks for the help, as I could not figure out those things on my own ! I hope that may be usefull to someone some day !

Link to comment
Share on other sites

  • Newek97 changed the title to [1.18.1][SOLVED] Importing files from Github as a depedency

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.