plugins { id 'java' id 'maven-publish' id 'com.gradleup.shadow' version '8.3.0' id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.8" } // TauMC fork of neoforged/NeoFormRuntime. Upstream derives its version from git tags via the // gradleutils plugin and publishes to the NeoForged maven; this fork sets the version by hand // (see gradle.properties) and publishes to maven.taumc.org. group = 'org.taumc' version = nfrt_version base { archivesName = "neoform-runtime" } ext.forkRepo = 'https://github.com/TauMC/NeoFormRuntime' repositories { mavenCentral() exclusiveContent { forRepository { maven { name = "Fabric" url = "https://maven.fabricmc.net/" } } filter { includeModule("net.fabricmc", "fabric-loom-native") } } exclusiveContent { forRepository { maven { name = "MinecraftForge" url = "https://maven.minecraftforge.net/" } } filter { includeModule("net.minecraftforge", "mergetool") } } // TauMC JST fork (see tools.properties); mavenLocal allows testing unpublished JST builds exclusiveContent { forRepositories( maven { name = "TauMC" url = "https://maven.taumc.org/releases/" }, mavenLocal() ) filter { includeGroup("org.taumc.jst") } } } java { withSourcesJar() toolchain { languageVersion = JavaLanguageVersion.of(21) } } tasks.withType(JavaCompile).configureEach() { options.encoding = "UTF-8" } tasks.withType(Test).configureEach() { // Keep test output stable, including output from Java processes launched by integration tests. environment "_JAVA_OPTIONS", "-Duser.language=en -Duser.country=US" } def mainClassName = 'net.neoforged.neoform.runtime.cli.Main' jar { manifest { attributes 'Main-Class': mainClassName } } sourceSets { integrationTest } configurations { externalTools { canBeConsumed = true canBeResolved = false // NFRT generally ignores transitive dependencies when downloading tools, so we should too transitive = false attributes { attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY)) attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME)) } outgoing { capability "org.taumc:neoform-runtime-external-tools:${project.version}" } components.java.addVariantsFromConfiguration(it) {} } integrationTestJavaSourceTransformer { canBeConsumed = false canBeResolved = true transitive = false } integrationTestDiffPatch { canBeConsumed = false canBeResolved = true transitive = false } integrationTestInstallerTools { canBeConsumed = false canBeResolved = true transitive = false } integrationTestSideAnnotationStripper { canBeConsumed = false canBeResolved = true transitive = false } integrationTestImplementation.extendsFrom(testImplementation) integrationTestRuntimeOnly.extendsFrom(testRuntimeOnly) } def toolVersions = new java.util.Properties() file("src/main/resources/tools.properties").withInputStream { toolVersions.load(it) } dependencies { compileOnly 'org.jetbrains:annotations:26.0.2' implementation 'info.picocli:picocli:4.7.6' implementation 'com.google.code.gson:gson:2.10.1' implementation 'org.eclipse.jdt:ecj:3.42.0' implementation 'net.fabricmc:fabric-loom-native:0.2.1' implementation 'net.neoforged:srgutils:1.0.10' implementation 'net.neoforged.installertools:problems-api:3.0.3' annotationProcessor 'info.picocli:picocli-codegen:4.7.6' testImplementation platform('org.junit:junit-bom:5.13.2') testImplementation platform('org.mockito:mockito-bom:5.18.0') testImplementation platform('org.assertj:assertj-bom:3.27.3') testImplementation 'org.junit.jupiter:junit-jupiter' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' testImplementation 'org.junit.jupiter:junit-jupiter-params' testImplementation 'org.mockito:mockito-junit-jupiter' testImplementation 'org.assertj:assertj-core' integrationTestCompileOnly sourceSets.main.output integrationTestJavaSourceTransformer toolVersions.getProperty("JAVA_SOURCE_TRANSFORMER") integrationTestDiffPatch toolVersions.getProperty("DIFF_PATCH") integrationTestInstallerTools toolVersions.getProperty("INSTALLER_TOOLS") integrationTestSideAnnotationStripper toolVersions.getProperty("MCF_SIDE_ANNOTATION_STRIPPER") } // Add dependencies to external tools for (var toolDependency : toolVersions.values()) { dependencies { externalTools(toolDependency) } } test { useJUnitPlatform() } final integrationTest = tasks.register("integrationTest", Test) { description = "Runs tests against the packaged NFRT command line" group = "verification" testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath useJUnitPlatform() dependsOn shadowJar inputs.file(shadowJar.archiveFile) inputs.files( configurations.integrationTestJavaSourceTransformer, configurations.integrationTestDiffPatch, configurations.integrationTestInstallerTools, configurations.integrationTestSideAnnotationStripper ) inputs.property("javaSourceTransformerCoordinate", toolVersions.getProperty("JAVA_SOURCE_TRANSFORMER")) inputs.property("diffPatchCoordinate", toolVersions.getProperty("DIFF_PATCH")) inputs.property("installerToolsCoordinate", toolVersions.getProperty("INSTALLER_TOOLS")) inputs.property("sideAnnotationStripperCoordinate", toolVersions.getProperty("MCF_SIDE_ANNOTATION_STRIPPER")) doFirst { systemProperty "nfrt.test.executable-jar", shadowJar.archiveFile.get().asFile.absolutePath systemProperty "nfrt.test.java-source-transformer-coordinate", toolVersions.getProperty("JAVA_SOURCE_TRANSFORMER") systemProperty "nfrt.test.java-source-transformer-jar", configurations.integrationTestJavaSourceTransformer.singleFile.absolutePath systemProperty "nfrt.test.diff-patch-coordinate", toolVersions.getProperty("DIFF_PATCH") systemProperty "nfrt.test.diff-patch-jar", configurations.integrationTestDiffPatch.singleFile.absolutePath systemProperty "nfrt.test.installer-tools-coordinate", toolVersions.getProperty("INSTALLER_TOOLS") systemProperty "nfrt.test.installer-tools-jar", configurations.integrationTestInstallerTools.singleFile.absolutePath systemProperty "nfrt.test.side-annotation-stripper-coordinate", toolVersions.getProperty("MCF_SIDE_ANNOTATION_STRIPPER") systemProperty "nfrt.test.side-annotation-stripper-jar", configurations.integrationTestSideAnnotationStripper.singleFile.absolutePath } } tasks.named("check") { dependsOn integrationTest } publishing { publications { mavenJava(MavenPublication) { from components.java pom { name = 'NeoFormRuntime' description = 'Standalone CLI tool to create artifacts used to compile mods against Minecraft' url = forkRepo licenses { license { name = 'LGPL-2.1-only' url = 'https://spdx.org/licenses/LGPL-2.1-only' } } developers { developer { id = 'taumc' name = 'TauMC' url = 'https://github.com/TauMC' } } scm { url = forkRepo connection = "scm:git:${forkRepo}.git" developerConnection = "scm:git:git@github.com:TauMC/NeoFormRuntime.git" } issueManagement { system = 'github' url = "${forkRepo}/issues" } } } } repositories { maven { name = 'taumcRepository' url = uri('https://maven.taumc.org/releases') credentials { username = System.getenv('MAVEN_USERNAME') password = System.getenv('MAVEN_SECRET') } } } } /** * Convenience IDE runs for IntelliJ for testing purposes. */ import org.jetbrains.gradle.ext.Application; idea { project { settings { runConfigurations { "Show Help"(Application) { mainClass = mainClassName programParameters = "--help" moduleRef(project, sourceSets.main) } "Run Neoforge 1.21.6 (joined) + Parchment"(Application) { mainClass = mainClassName programParameters = "run --dist joined --neoforge net.neoforged:neoforge:21.6.1-beta:userdev --add-repository=https://maven.parchmentmc.org --parchment-data=org.parchmentmc.data:parchment-1.21.5:2025.06.15@zip --parchment-conflict-prefix=p_ --write-result=gameJar:build/minecraft-1.21.6.jar --write-result=clientResources:build/client-extra-1.21.6.jar --write-result=gameSources:build/minecraft-sources-1.21.6.jar" moduleRef(project, sourceSets.main) } "Run Neoforge 1.21 (joined) + Parchment"(Application) { mainClass = mainClassName programParameters = "run --dist joined --neoforge net.neoforged:neoforge:21.0.0-beta:userdev --add-repository=https://maven.parchmentmc.org --parchment-data=org.parchmentmc.data:parchment-1.21:2024.06.23@zip --parchment-conflict-prefix=p_ --write-result=gameJar:build/minecraft-1.21.jar --write-result=clientResources:build/client-extra-1.21.jar --write-result=gameSources:build/minecraft-sources-1.21.jar" moduleRef(project, sourceSets.main) } "Run Neoforge 1.21 (joined)"(Application) { mainClass = mainClassName programParameters = "run --dist joined --neoforge net.neoforged:neoforge:21.0.0-beta:userdev --write-result=gameJar:build/minecraft.jar --write-result=clientResources:build/client-extra.jar --write-result=gameSources:build/minecraft-sources.jar" moduleRef(project, sourceSets.main) } "Run Neoforge 1.21 (joined, no recomp)"(Application) { mainClass = mainClassName programParameters = "run --dist joined --neoforge net.neoforged:neoforge:21.0.0-beta:userdev --write-result=gameJarNoRecomp:build/minecraft.jar --write-result=gameJarNoRecompWithNeoForge:build/minecraft-and-neoforge.jar --write-result=clientResources:build/client-extra.jar" moduleRef(project, sourceSets.main) } "Run Neoform 1.21 (joined)"(Application) { mainClass = mainClassName programParameters = "run --dist joined --neoform net.neoforged:neoform:1.21-20240613.152323@zip --write-result=gameJar:build/minecraft.jar --write-result=clientResources:build/client-extra.jar --write-result=gameSources:build/minecraft-sources.jar" moduleRef(project, sourceSets.main) } "Run Neoforge 1.20.6 (joined) + Parchment"(Application) { mainClass = mainClassName programParameters = "run --dist joined --neoforge net.neoforged:neoforge:20.6.72-beta:userdev --add-repository=https://maven.parchmentmc.org --parchment-data=org.parchmentmc.data:parchment-1.20.6:2024.05.01:checked@zip --write-result=gameJar:build/minecraft.jar --write-result=clientResources:build/client-extra.jar --write-result=gameSources:build/minecraft-sources.jar" moduleRef(project, sourceSets.main) } "Run Neoforge 1.20.6 (joined)"(Application) { mainClass = mainClassName programParameters = "run --dist joined --neoforge net.neoforged:neoforge:20.6.72-beta:userdev --write-result=gameJar:build/minecraft.jar --write-result=clientResources:build/client-extra.jar --write-result=gameSources:build/minecraft-sources.jar" moduleRef(project, sourceSets.main) } "Run Neoform 1.20.6 (joined)"(Application) { mainClass = mainClassName programParameters = "run --dist joined --neoform net.neoforged:neoform:1.20.6-20240429.153634@zip --write-result=gameJar:build/minecraft.jar --write-result=clientResources:build/client-extra.jar --write-result=gameSources:build/minecraft-sources.jar" moduleRef(project, sourceSets.main) } "Run NeoForge 1.20.1 (joined)"(Application) { mainClass = mainClassName programParameters = "run --dist joined --neoforge net.neoforged:forge:1.20.1-47.1.54:userdev --parchment-data=org.parchmentmc.data:parchment-1.20.1:2023.09.03@zip --parchment-conflict-prefix=p_ --write-result=namedToIntermediaryMapping:build/1.20.1.tsrg --write-result=gameJarWithNeoForge:build/1.20.1-minecraft.jar --write-result=clientResources:build/1.20.1-client-extra.jar --write-result=gameSourcesWithNeoForge:build/1.20.1-minecraft-sources.jar --problems-report=build/1.20.1-problems.json" moduleRef(project, sourceSets.main) } "Run Forge 1.17.1 (joined)"(Application) { mainClass = mainClassName programParameters = "run --dist joined --add-repository https://maven.minecraftforge.net --neoforge net.minecraftforge:forge:1.17.1-37.1.1:userdev --write-result=gameJarWithNeoForge:build/1.17.1-minecraft.jar --write-result=clientResources:build/1.17.1-client-extra.jar --write-result=gameSourcesWithNeoForge:build/1.17.1-minecraft-sources.jar" moduleRef(project, sourceSets.main) } "Run Forge 1.16.5 (joined)"(Application) { mainClass = mainClassName programParameters = "run --dist joined --add-repository https://maven.minecraftforge.net --neoforge net.minecraftforge:forge:1.16.5-36.2.39:userdev --write-result=gameJarWithNeoForge:build/1.16.5-minecraft.jar --write-result=clientResources:build/1.16.5-client-extra.jar --write-result=gameSourcesWithNeoForge:build/1.16.5-minecraft-sources.jar --use-mojmap-class-names --java-home /usr/lib/jvm/java-8-openjdk --java-executable /usr/lib/jvm/java-8-openjdk/bin/java" moduleRef(project, sourceSets.main) } "Run Neoform 1.19.2 (joined)"(Application) { mainClass = mainClassName programParameters = "run --dist joined --neoform de.oceanlabs.mcp:mcp_config:1.19.2@zip --write-result=gameJar:build/minecraft.jar --write-result=clientResources:build/client-extra.jar --write-result=gameSources:build/minecraft-sources.jar" moduleRef(project, sourceSets.main) } "Run Neoform 1.19.2 (joined, no recomp)"(Application) { mainClass = mainClassName programParameters = "run --dist joined --neoform de.oceanlabs.mcp:mcp_config:1.19.2@zip --write-result=gameJarNoRecomp:build/minecraft.jar --write-result=clientResources:build/client-extra.jar" moduleRef(project, sourceSets.main) } "Run clean-cache"(Application) { mainClass = mainClassName programParameters = "clean-cache --verbose" moduleRef(project, sourceSets.main) } "Run cache-maintenance"(Application) { mainClass = mainClassName programParameters = "cache-maintenance --verbose" moduleRef(project, sourceSets.main) } "Download assets 1.20.6"(Application) { mainClass = mainClassName programParameters = "download-assets --neoforge net.neoforged:neoforge:20.6.72-beta:userdev --write-properties build/assets.properties --write-json build/assets.json" moduleRef(project, sourceSets.main) } "Download artifacts 1.21.11"(Application) { mainClass = mainClassName programParameters = "download-artifacts --minecraft-version=1.21.11 --write-artifact=client:build/vanilla-client-1.21.11.jar --write-artifact=server:build/vanilla-server-1.21.11.jar --write-version-manifest=build/vanilla-manifest-1.21.11.json" moduleRef(project, sourceSets.main) } } } } }