Skip to content

Instantly share code, notes, and snippets.

@ILikePlayingGames
Last active February 24, 2022 20:55
Show Gist options
  • Save ILikePlayingGames/983e91a92c64736f465351fc68a83115 to your computer and use it in GitHub Desktop.
Save ILikePlayingGames/983e91a92c64736f465351fc68a83115 to your computer and use it in GitHub Desktop.
How to Use Gradle Plugins DSL on Forge MDK 39+

How to Use Gradle Plugins DSL on Forge MDK 39+

This guide was created for Forge MDK 39.0.76 but should work for future Forge versions for Minecraft 1.18.x.

  1. Create a new file in the root folder of your project called settings.gradle and add this to it:
pluginManagement {
    repositories {
        gradlePluginPortal()
        maven {
            name 'MinecraftForge Maven'
            url 'https://maven.minecraftforge.net'
        }
        mavenCentral()
    }
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == 'net.minecraftforge.gradle') {
                useModule('net.minecraftforge.gradle:ForgeGradle:5.1.+')
            }
        }
    }
}
  1. Remove the buildscript block below from build.gradle.
buildscript {
    repositories {
        // These repositories are only for Gradle plugins, put any other repositories in the repository block further below
        maven { url = 'https://maven.minecraftforge.net' }
        mavenCentral()
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
    }
}
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
  1. Replace it with this:
plugins {
    id 'net.minecraftforge.gradle'
    id 'eclipse'
    id 'maven-publish'
}

That's it, you're now using the plugins DSL.

Notes

  • The ForgeGradle version cannot be specified in build.gradle since it is a changing version, which is not supported by the DSL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment