Skip to content
Dmodoom Sirius edited this page Jun 29, 2020 · 33 revisions

Set up your Gradle build script

You can integrate and automatically download JEI for your mod project using Gradle.
Just add the following to your build script (build.gradle):

Repositories

repositories {
  maven {
    // location of the maven that hosts JEI files
    name = "Progwml6 maven"
    url = "https://dvs1.progwml6.com/files/maven/"
  }
  maven {
    // location of a maven mirror for JEI files, as a fallback
    name = "ModMaven"
    url = "https://modmaven.k-4u.nl"
  }
}

Dependencies using FG3 (Minecraft 1.13.2+)

dependencies {
  /* minecraft dependency is here */

  // compile against the JEI API but do not include it at runtime
  compileOnly fg.deobf("mezz.jei:jei_${mc_version}:${jei_version}:api")
  // at runtime, use the full JEI jar
  runtimeOnly fg.deobf("mezz.jei:jei_${mc_version}:${jei_version}")
}

Dependencies using FG2 (Minecraft 1.8 to 1.12.2)

dependencies {
  // compile against the JEI API but do not include it at runtime
  deobfProvided "mezz.jei:jei_${mc_version}:${jei_version}:api"
  // at runtime, use the full JEI jar
  runtime "mezz.jei:jei_${mc_version}:${jei_version}"
}

Note that this repositories section belongs outside the buildscript area, do not edit anything inside buildscript.

FG2 (Minecraft 1.8 to 1.12.2) Rerun the Gradle Commands

e.g. gradlew setupDecompWorkspace or gradlew eclipse Then refresh your project in your IDE.

Choose a Version

${mc_version} gets replaced by the current Minecraft version. (i.e. 1.10.2)
${jei_version} gets replaced by the version of JEI you want to use (i.e 3.13.0.330)

For a list of available JEI versions, see CurseForge or the maven listing.

These properties can be set in a file named gradle.properties, placed in the same directory as your build.gradle file.

For this example, your gradle.properties would look like this:

mc_version=1.10.2
jei_version=3.13.0.330

Examples of working build.gradle

You can see the Forestry build.gradle for an example of this being used.
There are many more examples from mods in the List of Plugin Implementations.

Troubleshooting

If you have not set up a project with gradle before, or are having issues with it in general, I recommend cpw's videos on how to set up Minecraft Forge projects in IntelliJ Idea.

TIP: I've watched these videos like 20 times, and only recently understand it.
There is no shame in having your hand held through the horrors of a broken build.gradle.

If you're still stuck and getting frustrated, check out the #ForgeGradle channel on IRC, ask for help, show them your build.gradle on gist, and wait for someone to reply. If you haven't used IRC before, know that sometimes it's busy and sometimes it takes a long while to get a reply. Make sure you ask your question right away, be patient, and wait around long enough for the reply.

Why compile against the API?

The example script only compiles against the API, which is very stable. When you run your mod (runtime), the full JEI will run as well so that you can still test with it in development.

If you make the mistake of compiling against the full mod jar and then use classes from JEI that are not in the API, your mod could break any time JEI updates.

If you find that you need a feature that is not in the API, be sure to ask on the issue tracker.

Clone this wiki locally