### Interface Injection Data File Example Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Example JSON structure for an interface injection data file, mapping Minecraft classes to additional interfaces. ```json { "net/minecraft/world/item/ItemStack": [ "testproject/FunExtensions" ] } ``` -------------------------------- ### Setup JUnit Unit Testing in Gradle Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Configure your build script to enable JUnit support for unit testing mods. This includes adding test dependencies and enabling the JUnit platform in Gradle. ```groovy // Add a test dependency on the test engine JUnit dependencies { testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } // Enable JUnit in Gradle: test { useJUnitPlatform() } neoForge { unitTest { // Enable JUnit support in the moddev plugin enable() // Configure which mod is being tested. // This allows NeoForge to load the test/ classes and resources as belonging to the mod. testedMod = mods. // must match the name in the mods { } block. // Configure which mods are loaded in the test environment, if the default (all declared mods) is not appropriate. // This must contain testedMod, and can include other mods as well. // loadedMods = [mods., mods.] } } ``` -------------------------------- ### Example JUnit Test with Ephemeral Test Server Source: https://github.com/neoforged/moddevgradle/blob/main/README.md An example of a JUnit test class annotated to use the EphemeralTestServerProvider, allowing interaction with a Minecraft server instance during testing. ```java @ExtendWith(EphemeralTestServerProvider.class) public class TestClass { @Test public void testMethod(MinecraftServer server) { // Use server... } } ``` -------------------------------- ### Disable Decompilation and Recompilation in ModDevGradle Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Manually disable the NeoForm decompilation/recompilation pipeline by using the 'enable' block with 'disableRecompilation = true'. This speeds up setup times by skipping the creation of Minecraft sources and compiled game jars. This setting is automatically enabled in CI/CD pipelines if the 'CI' environment variable is true. ```groovy neoForge { enable { version = "..." // or neoFormVersion = "..." disableRecompilation = true } } ``` -------------------------------- ### Configure NeoForm Runtime Settings Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Configure global settings for NeoForm Runtime, including version pinning, cache control, verbose output, compiler selection, cache miss analysis, and launcher manifest URL. ```groovy neoFormRuntime { // Use a specific NFRT version // Gradle Property: neoForge.neoFormRuntime.version version = "1.2.3" // Control use of cache // Gradle Property: neoForge.neoFormRuntime.enableCache enableCache = false // Enable Verbose Output // Gradle Property: neoForge.neoFormRuntime.verbose verbose = true // Use Eclipse Compiler for Minecraft // Gradle Property: neoForge.neoFormRuntime.useEclipseCompiler useEclipseCompiler = true // Print more information when NFRT cannot use a cached result // Gradle Property: neoForge.neoFormRuntime.analyzeCacheMisses analyzeCacheMisses = true // Overrides the launcher manifest URL used by NFRT to look up Minecraft versions // Gradle Property: neoForge.neoFormRuntime.launcherManifestUrl launcherManifestUrl = "https://.../version_manifest_v2.json" } ``` -------------------------------- ### Enable Authenticated Minecraft Account Run Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Configure a client run in the NeoForge plugin to use an authenticated Minecraft account by setting 'devLogin' to true. ```groovy neoForge { runs { // Add a second client run that is authenticated clientAuth { client() devLogin = true } } } ``` -------------------------------- ### Apply ModDevGradle Plugin and Configure NeoForge Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Apply the ModDevGradle plugin and configure NeoForge settings in `build.gradle`. This includes specifying the NeoForge version, enabling access transformer validation, and setting up run configurations. ```groovy plugins { // Apply the plugin. You can find the latest version at https://projects.neoforged.net/neoforged/ModDevGradle id 'net.neoforged.moddev' version '1.0.11' } neoForge { // We currently only support NeoForge versions later than 21.0.x // See https://projects.neoforged.net/neoforged/neoforge for the latest updates version = "21.0.103-beta" // Validate AT files and raise errors when they have invalid targets // This option is false by default, but turning it on is recommended validateAccessTransformers = true runs { client { client() } data { data() } server { server() } } mods { testproject { sourceSet sourceSets.main } } } ``` -------------------------------- ### Enable Vanilla Mode in ModDevGradle Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Use this configuration to enable Vanilla-mode by specifying a NeoForm version instead of a NeoForge version. This mode supports 'client', 'server', and 'data' run types and is suitable for cross-loader projects needing access to base Minecraft classes. ```groovy neoForge { // Look for versions on https://projects.neoforged.net/neoforged/neoform neoFormVersion = "1.21-20240613.152323" runs { client { client() } server { server() } data { data() } } } ``` -------------------------------- ### Configure Run Configurations in ModDevGradle Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Defines various settings for run configurations within the neoForge block. Supports setting run type, working directory, program and JVM arguments, system properties, environment variables, log level, IDE name, disabling IDE runs, source set, loaded mods, and tasks to run before launch. ```groovy neoForge { runs { { // This is the standard syntax: type = "gameTestServer" // Client, data and server runs can use a shorthand instead: // client() // data() // server() // Changes the working directory used for this run. // The default is the 'run' subdirectory of your project gameDirectory = project.file('runs/client') // Add arguments passed to the main method programArguments = ["--arg"] programArgument("--arg") // Add arguments passed to the JVM jvmArguments = ["-XX:+AllowEnhancedClassRedefinition"] jvmArgument("-XX:+AllowEnhancedClassRedefinition") // Add system properties systemProperties = [ "a.b.c": "xyz" ] systemProperty("a.b.c", "xyz") // Set or add environment variables environment = [ "FOO_BAR": "123" ] environment("FOO_BAR", "123") // Optionally set the log-level used by the game logLevel = org.slf4j.event.Level.DEBUG // You can change the name used for this run in your IDE ideName = "Run Game Tests" // You can disable a run configuration being generated for your IDE disableIdeRun() // ... alternatively you can set ideName = "" // Changes the source set whose runtime classpath is used for this run. This defaults to "main" // Eclipse does not support having multiple runtime classpaths per project (except for unit tests). sourceSet = sourceSets.main // Changes which local mods are loaded in this run. // This defaults to all mods declared in this project (inside of mods { ... } ). loadedMods = [mods., mods.] // Allows advanced users to run additional Gradle tasks before each launch of this run // Please note that using this feature will significantly slow down launching the game taskBefore tasks.named("generateSomeCodeTask") } } } ``` -------------------------------- ### Configure Parchment for Minecraft Parameter Names and Javadoc Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Set Parchment versions to obtain community-sourced parameter names and Javadoc for Minecraft source code. This can be done via gradle.properties or directly in the build.gradle file. ```properties neoForge.parchment.minecraftVersion=1.21 neoForge.parchment.mappingsVersion=2024.06.23 ``` -------------------------------- ### Enable Gradle Configuration Cache Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Enable Gradle's configuration cache for faster repeated task runs. This setting is placed in the `gradle.properties` file. ```properties org.gradle.configuration-cache=true ``` -------------------------------- ### Publish Access Transformer in Gradle Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Configure the NeoForge plugin to publish an access transformer file. The classifier depends on whether one or multiple files are published. ```groovy neoForge { accessTransformers { publish file("src/main/resources/META-INF/accesstransformer.cfg") } } ``` -------------------------------- ### Publish Interface Injection Data in Gradle Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Configure the NeoForge plugin to publish interface injection data files. The classifier depends on the number of files published. ```groovy // Publish a file: neoForge { interfaceInjectionData { publish file("interfaces.json") } } ``` -------------------------------- ### Configure Access Transformers in Gradle Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Configure access transformer paths in your Gradle build script. Use 'from' to add a single transformer or '=' to replace the entire list. ```groovy neoForge { // Pulling in an access transformer from the parent project // (Option 1) Add a single access transformer, and keep the default: accessTransformers.from "../src/main/resources/META-INF/accesstransformer.cfg" // (Option 2) Overwrite the whole list of access transformers, removing the default: accessTransformers = ["../src/main/resources/META-INF/accesstransformer.cfg"] } ``` -------------------------------- ### Add Test Framework Dependency for Server Context Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Include the NeoForge test framework dependency to run unit tests within a Minecraft server context. This allows tests to interact with a running server environment. ```groovy dependencies { testImplementation "net.neoforged:testframework:" } ``` -------------------------------- ### Configure Parchment in build.gradle Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Alternatively, configure Parchment versions directly within your build.gradle file for Minecraft parameter names and Javadoc. ```groovy neoForge { // [...] parchment { // Get versions from https://parchmentmc.org/docs/getting-started // Omit the "v"-prefix in mappingsVersion minecraftVersion = "1.20.6" mappingsVersion = "2024.05.01" } } ``` -------------------------------- ### Apply Foojay Resolver Plugin in settings.gradle Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Apply the Gradle toolchains foojay resolver plugin in `settings.gradle`. This plugin helps in automatically downloading arbitrary Java versions for Gradle. ```groovy plugins { // This plugin allows Gradle to automatically download arbitrary versions of Java for you id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' } ``` -------------------------------- ### Centralized Repositories Declaration in settings.gradle Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Apply the 'net.neoforged.moddev.repositories' plugin in settings.gradle to manage repositories centrally. This ensures consistent repository access across projects. ```groovy plugins { id 'net.neoforged.moddev.repositories' version '' } dependencyResolutionManagement { repositories { mavenCentral() } } ``` -------------------------------- ### Configure Isolated Source Sets for Modding Dependencies Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Integrate modding dependencies into custom source sets that do not extend from 'main'. This allows these source sets to access modding-related APIs and configurations. ```groovy sourceSets { anotherSourceSet // example } neoForge { // ... addModdingDependenciesTo sourceSets.anotherSourceSet mods { mymod { sourceSet sourceSets.main // Do not forget to add additional source-sets here! sourceSet sourceSets.anotherSourceSet } } } dependencies { implementation sourceSets.anotherSourceSet.output } ``` -------------------------------- ### Update Mod Loading Configuration in Runs Source: https://github.com/neoforged/moddevgradle/blob/main/BREAKING_CHANGES.md Update the 'mods' property to 'loadedMods' and reference mods using the 'mods.' syntax within the 'neoForge.runs' block. ```gradle neoForge { runs { client { /* ... */ - mods = [neoForge.mods.mod1, neoForge.mods.mod2] + loadedMods = [mods.mod1, mods.mod2] } } } ``` -------------------------------- ### Force Platform Library Version Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Globally override the version of a platform library for development and testing purposes. This is useful for using unreleased versions of NeoForge or its platform libraries. ```groovy configurations.all { resolutionStrategy { force 'cpw.mods:securejarhandler:2.1.43' } } ``` -------------------------------- ### Run Tasks on IDE Project Synchronization Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Configure tasks to be executed automatically when the IDE reloads the Gradle project. This is useful for running code generation tasks during IDE sync. ```groovy neoForge { ideSyncTask tasks.named("generateSomeCodeTask") } ``` -------------------------------- ### Include Local Jar Files with Jar-in-Jar Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Include files built by other tasks, such as jar tasks of other source sets. This is useful for coremods or plugins. The filename is used as the artifact-id and its MD5 hash as the version. ```groovy sourceSets { plugin } neoForge { // ... mods { // ... // To make the plugin load in dev 'plugin' { sourceSet sourceSets.plugin } } } def pluginJar = tasks.register("pluginJar", Jar) { from(sourceSets.plugin.output) archiveClassifier = "plugin" manifest { attributes( 'FMLModType': "LIBRARY", "Automatic-Module-Name": project.name + "-plugin" ) } } dependencies { jarJar files(pluginJar) } ``` -------------------------------- ### Configure External Dependency Version Range for Jar-in-Jar Source: https://github.com/neoforged/moddevgradle/blob/main/README.md When bundling external dependencies, set a supported version range to avoid mod incompatibilities. This ensures a single copy of the dependency is selected, even if bundled by multiple mods. The version range uses the Maven format. ```groovy dependencies { jarJar(implementation("org.commonmark:commonmark")) { version { // The version range your mod is actually compatible with. // Note that you may receive a *lower* version than your preferred if another // Mod is only compatible up to 1.7.24, for example, your mod might get 1.7.24 at runtime. strictly '[0.1, 1.0)' prefer '0.21.0' // The version actually used in your dev workspace } } } ``` -------------------------------- ### Request Additional Minecraft Artifacts Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Request intermediate results from the NeoForm process to be written to specific output files. The available artifacts depend on the NeoForm/NeoForge and NFRT versions used. ```groovy neoForge { // Request NFRT to write additional results to the given locations // This happens alongside the creation of the normal Minecraft jar additionalMinecraftArtifacts.put('vanillaDeobfuscated', project.file('vanilla.jar')) } ``` -------------------------------- ### Set Log Level to Debug in ModDevGradle Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Configures the system property 'forge.logging.console.level' to 'debug' for all runs within the neoForge block, useful for detailed logging during development. ```groovy neoForge { runs { configureEach { systemProperty 'forge.logging.console.level', 'debug' } } } ``` -------------------------------- ### Add External Dependencies to Runtime Classpath Source: https://github.com/neoforged/moddevgradle/blob/main/README.md For Minecraft versions 1.21.8 and older, external libraries not recognized as mods need to be explicitly added to the runtime classpath. This ensures they are available during execution. ```groovy dependencies { // This is still required to add the library in your jar and at compile time. jarJar(implementation("org.commonmark:commonmark")) { /* ... */ } // This adds the library to all the runs. additionalRuntimeClasspath "org.commonmark:commonmark:0.21.0" } ``` -------------------------------- ### Configure Interface Injection Data in Gradle Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Configure the 'interfaceInjectionData' property in your Gradle build script to specify the location of interface injection data files. ```groovy neoForge { interfaceInjectionData.from "interfaces.json" } ``` -------------------------------- ### Consume Interface Injection Data Dependency Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Add interface injection data as a dependency in your project's dependencies block to consume it. ```groovy dependencies { interfaceInjectionData "::" } ``` -------------------------------- ### Consume Access Transformer Dependency Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Add an access transformer as a dependency in your project's dependencies block to consume it. ```groovy dependencies { accessTransformers "::" } ``` -------------------------------- ### Embed Subproject Jar with Jar-in-Jar Source: https://github.com/neoforged/moddevgradle/blob/main/README.md Embed a jar file from a subproject. For subprojects, the group ID is the root project name, and the artifact ID is the subproject name. The Java module name must also be unique. ```groovy dependencies { jarJar project(":coremod") } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.