Jump to content

Can APIs be added as dependencies?


perry

Recommended Posts

Yes. Follow this instruction:

1. Assuming you already have your workspace set up, create a new folder named "/lib" in your project directory. That's the directory that contains your /bin, /build, /gradle, and /src folders, and now also has a /lib folder.

 

2. Download Thermal Expansion and place it into /mods folder, that locates in /eclipse folder. Download RF-API source file and place it in the /lib folder you just created.

 

3. In Eclipse, right-click on your project, select "Build Path" and then "Configure Build Path". Click the "Libraries" tab, then "Add External JARs" and find the TE file that you just placed in the /mods folder.

 

4. Open the "Referenced Libraries" tree in your package explorer, find the API binary that you just referenced and right-click on it; go to "Properties" -> "External location" -> "External file" and navigate to the source file in the /lib folder.

Original tutorial by coolAlias. Edited by me. Tip: use search.

Link to comment
Share on other sites

Thank you but I was referring specifically to the gradle build system and dependencies as briefly explained here https://github.com/MinecraftForge/ForgeGradle/wiki/Dpendencies.

The instructions you gave involve cloning the repo, compiling the jar and linking in eclipse (I'm using IntelliJ anyway).

What I'm wondering is if the Gradle build system can do essentially the same thing automatically by listing it as a dependency in the build.gradle file.

 

Link to comment
Share on other sites

TeamCoFH doesn't have maven repo, that's why I didn't talk about Maven Dependency. And yes, I forgot to talk about compiling. You should compile your mod so:

Open build.gradle file, and add the following code:

dependencies {
compile files ("lib/RF-API.jar")
}

P.S in mcmod.info add following code:

"dependencies": ["ThermalExpansion"],
"useDependencyInformation": "true"

P.P.S As far as I know, Redstone Flux API is only used in Thermal Expansion, that's why I printed "ThermalExpansion" (mod ID) in "dependencies" field.

Link to comment
Share on other sites

Ah I'm new to these build systems.

After looking it up it seems you can only depend on Maven and Ivy repositories remotely, can you not depend on a remote repository that uses Gradle to build?

 

The 3 lines you said to add to build.gradle, just to clarify, is that compiling the lib source files into a jar or is it taking an already compiled jar in compilation of my project?

 

Not sure if that's quite right about TE as dependency, many mods use it and you can use those mods without TE installed (such as ExtraUtils and AE2).

 

Thank you

Link to comment
Share on other sites

I understand they are different build systems, in the documentation it has instructions on linking an external Maven or Ivy repository to use as a dependency. Can you not link to an external repository that uses gradle to build, or am I missing something fundamental here?

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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