I've searched the forum about this important topic but I couldn't find anything suitable for me.
Using other mod's apis can be done in many ways:
1. Put the api code directly in your own project. This is, imo, the worst way to go. One should never include someone else's api in his own mod. (discussed here: http://www.minecraftforge.net/forum/index.php/topic,5303.msg30648.html#msg30648)
2. Put the api's jar in your project, reference it has a library and don't include it in your mod. That's what I'm using actually. (discussed here: http://www.minecraftforge.net/forum/index.php/topic,20546.msg104049.html#msg104049)
3. Notify gradle about the need for an external api and let it handle everything. That's what I want
The second option is nice but it has some drawbacks. I first have to find the apis. Some are easily obtainable as a jar, some are source code that have to be compiled first. They have to be manually copied into a libs folder and added as a dependency in gradle/eclipse. Handling the different versions and updates of the apis is a pain. The apis being in my libs folder, they are stored on my own repository where they shouldn't be.
Let's take Applied Energistics 2 as an example. On their github page they say:
This is exactly what I need. I can set a variable holding the api's version I want in my build.properties and call the dependency in my gradle.build.
But when I do this, I get some issues that I don't understand.
First, after I run "gradle eclipse", my eclipse project is updated and immediately finds the api. It got downloaded with the previous command and got stored somewhere in ~/.gradle/caches. Eclipse is now happy and displays no error.
But then, when I run "gradle build" the build fails. I get spammed with messages like this:
> Could not resolve api:coloredlightscore:1.
Required by:
(mymod's name):1.7.10-1.2.0 > appeng:appliedenergistics2:rv2-beta-8
> Could not HEAD 'https://libraries.minecraft.net/api/coloredlightscore/1/coloredlightscore-1.pom'. Received status code 403 from server: Forbidden
It puzzles me because it seems that gradle tries to compile the api! Which I don't understand for 2 reasons: the api is already compiled and actually already present in ~/.gradle/caches ; ae2's dependencies have nothing to do with my mod.
From researches on that matter, I've read that I have to include the sub-dependencies (like coloredlightscore in this example) in a gradle repository but that doesn't make any sense to me. I just can't add all the dependencies of all the apis I'm using. That has nothing to do with my own mod. And it would be such a pain that there would be no point using this method.
Another thing that puzzles me is the url given in the logs. Why looking for coloredlightscore (and all other dependencies) at libraries.minecraft.net? Doesn't make any sense to me
What did I do wrong and how can I solve this?