diff --git a/buildSrc/src/main/groovy/neoforge.formatting-conventions.gradle b/buildSrc/src/main/groovy/neoforge.formatting-conventions.gradle index 0a26b947823..636b93be93c 100644 --- a/buildSrc/src/main/groovy/neoforge.formatting-conventions.gradle +++ b/buildSrc/src/main/groovy/neoforge.formatting-conventions.gradle @@ -49,7 +49,6 @@ immaculate { config = rootProject.file('codeformat/formatter-config.xml') } - // courtesy of diffplug/spotless#240 // https://github.com/diffplug/spotless/issues/240#issuecomment-385206606 custom 'noWildcardImports', { String fileContents -> diff --git a/buildSrc/src/main/java/net/neoforged/neodev/CreateUserDevConfig.java b/buildSrc/src/main/java/net/neoforged/neodev/CreateUserDevConfig.java index ab24c91d4d8..dc4c575f24a 100644 --- a/buildSrc/src/main/java/net/neoforged/neodev/CreateUserDevConfig.java +++ b/buildSrc/src/main/java/net/neoforged/neodev/CreateUserDevConfig.java @@ -53,6 +53,9 @@ public CreateUserDevConfig() {} @Input abstract ListProperty getModules(); + @Input + abstract ListProperty getJavaAgents(); + @Input abstract ListProperty getTestLibraries(); @@ -68,7 +71,7 @@ public CreateUserDevConfig() {} @TaskAction public void writeUserDevConfig() throws IOException { var config = new UserDevConfig( - 2, + 3, "net.neoforged:neoform:%s-%s@zip".formatted(getMinecraftVersion().get(), getRawNeoFormVersion().get()), "ats/", "joined.lzma", @@ -81,30 +84,27 @@ public void writeUserDevConfig() throws IOException { getLibraries().get(), getTestLibraries().get(), new LinkedHashMap<>(), - getModules().get()); + getModules().get(), + getJavaAgents().get() + ); for (var runType : RunType.values()) { - var launchTarget = switch (runType) { - case CLIENT -> "forgeclient"; - case DATA -> "forgedata"; - case GAME_TEST_SERVER, SERVER -> "forgeserver"; - case JUNIT -> "forgejunit"; - } + (getForNeoDev().get() ? "dev" : "userdev"); + var mainClass = switch (runType) { + case CLIENT -> "net.neoforged.fml.startup.Client"; + case DATA -> "net.neoforged.fml.startup.Data"; + case GAME_TEST_SERVER, SERVER -> "net.neoforged.fml.startup.Server"; + case JUNIT -> null; + }; List args = new ArrayList<>(); - Collections.addAll(args, - "--launchTarget", launchTarget); - if (runType == RunType.CLIENT || runType == RunType.JUNIT) { + if (runType == RunType.CLIENT) { // TODO: this is copied from NG but shouldn't it be the MC version? - Collections.addAll(args, - "--version", getNeoForgeVersion().get()); + Collections.addAll(args, "--version", getNeoForgeVersion().get()); } - if (runType == RunType.CLIENT || runType == RunType.DATA || runType == RunType.JUNIT) { - Collections.addAll(args, - "--assetIndex", "{asset_index}", - "--assetsDir", "{assets_root}"); + if (runType == RunType.CLIENT || runType == RunType.DATA) { + Collections.addAll(args, "--assetIndex", "{asset_index}", "--assetsDir", "{assets_root}"); } Collections.addAll(args, @@ -116,8 +116,6 @@ public void writeUserDevConfig() throws IOException { Map systemProperties = new LinkedHashMap<>(); systemProperties.put("java.net.preferIPv6Addresses", "system"); - systemProperties.put("ignoreList", String.join(",", getIgnoreList().get())); - systemProperties.put("legacyClassPath.file", "{minecraft_classpath_file}"); if (runType == RunType.CLIENT || runType == RunType.GAME_TEST_SERVER) { systemProperties.put("neoforge.enableGameTest", "true"); @@ -129,22 +127,19 @@ public void writeUserDevConfig() throws IOException { config.runs().put(runType.jsonName, new UserDevRunType( runType != RunType.JUNIT, - "cpw.mods.bootstraplauncher.BootstrapLauncher", + mainClass, args, List.of( - "-p", "{modules}", - "--add-modules", "ALL-MODULE-PATH", - "--add-opens", "java.base/java.util.jar=cpw.mods.securejarhandler", - "--add-opens", "java.base/java.lang.invoke=cpw.mods.securejarhandler", - "--add-exports", "java.base/sun.security.util=cpw.mods.securejarhandler", + "--add-opens", "java.base/java.util.jar=ALL-UNNAMED", + "--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED", + "--add-exports", "java.base/sun.security.util=ALL-UNNAMED", "--add-exports", "jdk.naming.dns/com.sun.jndi.dns=java.naming"), runType == RunType.CLIENT || runType == RunType.JUNIT, runType == RunType.GAME_TEST_SERVER || runType == RunType.SERVER, runType == RunType.DATA, runType == RunType.CLIENT || runType == RunType.GAME_TEST_SERVER, runType == RunType.JUNIT, - Map.of( - "MOD_CLASSES", "{source_roots}"), + Map.of("MOD_CLASSES", "{source_roots}"), systemProperties )); } @@ -183,7 +178,10 @@ record UserDevConfig( List libraries, List testLibraries, Map runs, - List modules) {} + List modules, + List javaAgents +) { +} record BinpatcherConfig( String version, diff --git a/buildSrc/src/main/java/net/neoforged/neodev/NeoDevConfigurations.java b/buildSrc/src/main/java/net/neoforged/neodev/NeoDevConfigurations.java index 35eb5b570df..65223de8019 100644 --- a/buildSrc/src/main/java/net/neoforged/neodev/NeoDevConfigurations.java +++ b/buildSrc/src/main/java/net/neoforged/neodev/NeoDevConfigurations.java @@ -44,6 +44,10 @@ static NeoDevConfigurations createAndSetup(Project project) { * (i.e. BootstrapLauncher and its dependencies). */ final Configuration moduleLibraries; + /** + * The Java Agents to attach to the running JVM when running the game. + */ + final Configuration javaAgents; /** * Libraries that should be accessible in mod development environments at compilation time only. * Currently, this is only used for MixinExtras, which is already available at runtime via JiJ in the NeoForge universal jar. @@ -73,6 +77,10 @@ static NeoDevConfigurations createAndSetup(Project project) { * Resolvable {@link #moduleLibraries}. */ final Configuration modulePath; + /** + * Resolvable {@link #javaAgents}. + */ + final Configuration javaAgentsClasspath; /** * Userdev dependencies (written to a json file in the userdev jar). * This should contain all of NeoForge's additional dependencies for userdev, @@ -125,12 +133,14 @@ private NeoDevConfigurations(Project project) { neoFormDependencies = dependencyScope(configurations, "neoFormDependencies"); libraries = dependencyScope(configurations, "libraries"); moduleLibraries = dependencyScope(configurations, "moduleLibraries"); + javaAgents = dependencyScope(configurations, "javaAgents"); userdevCompileOnly = dependencyScope(configurations, "userdevCompileOnly"); userdevTestFixtures = dependencyScope(configurations, "userdevTestFixtures"); neoFormDataOnly = resolvable(configurations, "neoFormDataOnly"); neoFormClasspath = resolvable(configurations, "neoFormClasspath"); modulePath = resolvable(configurations, "modulePath"); + javaAgentsClasspath = resolvable(configurations, "javaAgentsClasspath"); userdevClasspath = resolvable(configurations, "userdevClasspath"); userdevCompileOnlyClasspath = resolvable(configurations, "userdevCompileOnlyClasspath"); userdevTestClasspath = resolvable(configurations, "userdevTestClasspath"); @@ -152,6 +162,9 @@ private NeoDevConfigurations(Project project) { modulePath.extendsFrom(moduleLibraries); modulePath.shouldResolveConsistentlyWith(runtimeClasspath); + javaAgentsClasspath.extendsFrom(javaAgents); + javaAgentsClasspath.shouldResolveConsistentlyWith(runtimeClasspath); + userdevClasspath.extendsFrom(libraries, moduleLibraries, userdevCompileOnly); userdevClasspath.shouldResolveConsistentlyWith(runtimeClasspath); diff --git a/buildSrc/src/main/java/net/neoforged/neodev/NeoDevPlugin.java b/buildSrc/src/main/java/net/neoforged/neodev/NeoDevPlugin.java index 8b12aadd44d..82944ed2b80 100644 --- a/buildSrc/src/main/java/net/neoforged/neodev/NeoDevPlugin.java +++ b/buildSrc/src/main/java/net/neoforged/neodev/NeoDevPlugin.java @@ -112,15 +112,15 @@ public void apply(Project project) { task.getRawNeoFormVersion().set(rawNeoFormVersion); task.getLibraries().addAll(DependencyUtils.configurationToGavList(configurations.userdevClasspath)); task.getModules().addAll(DependencyUtils.configurationToGavList(configurations.modulePath)); - task.getTestLibraries().addAll(DependencyUtils.configurationToGavList(configurations.userdevTestClasspath)); - task.getTestLibraries().add(neoForgeVersion.map(v -> "net.neoforged:testframework:" + v)); - task.getIgnoreList().addAll(configurations.userdevCompileOnlyClasspath.getIncoming().getArtifacts().getResolvedArtifacts().map(results -> { - return results.stream().map(r -> r.getFile().getName()).toList(); - })); - task.getIgnoreList().addAll("client-extra", "neoforge-"); - task.getBinpatcherGav().set(Tools.BINPATCHER.asGav(project)); - }); - } + task.getJavaAgents().addAll(DependencyUtils.configurationToGavList(configurations.javaAgentsClasspath)); + task.getTestLibraries().addAll(DependencyUtils.configurationToGavList(configurations.userdevTestClasspath)); + task.getTestLibraries().add(neoForgeVersion.map(v -> "net.neoforged:testframework:" + v)); + task.getIgnoreList().addAll(configurations.userdevCompileOnlyClasspath.getIncoming().getArtifacts().getResolvedArtifacts().map(results -> { + return results.stream().map(r -> r.getFile().getName()).toList(); + })); + task.getIgnoreList().addAll("client-extra", "neoforge-"); + task.getBinpatcherGav().set(Tools.BINPATCHER.asGav(project)); + });} // 2. Task to download assets. var downloadAssets = tasks.register("downloadAssets", DownloadAssets.class, task -> { @@ -246,6 +246,7 @@ public void apply(Project project) { // ${version_name}.jar will be filled out by the launcher. It corresponds to the raw SRG Minecraft client jar. task.getIgnoreList().addAll("client-extra", "${version_name}.jar"); task.setModules(configurations.modulePath); + task.setJavaAgents(configurations.javaAgentsClasspath); task.getLauncherProfile().set(neoDevBuildDir.map(dir -> dir.file("launcher-profile.json"))); }); @@ -277,11 +278,11 @@ public void apply(Project project) { }); var createWindowsServerArgsFile = tasks.register("createWindowsServerArgsFile", CreateArgsFile.class, task -> { - task.setLibraries(";", configurations.launcherProfileClasspath, configurations.modulePath); + task.getPathSeparator().set(";"); task.getArgsFile().set(neoDevBuildDir.map(dir -> dir.file("windows-server-args.txt"))); }); var createUnixServerArgsFile = tasks.register("createUnixServerArgsFile", CreateArgsFile.class, task -> { - task.setLibraries(":", configurations.launcherProfileClasspath, configurations.modulePath); + task.getPathSeparator().set(":"); task.getArgsFile().set(neoDevBuildDir.map(dir -> dir.file("unix-server-args.txt"))); }); @@ -300,6 +301,7 @@ public void apply(Project project) { return results.stream().map(r -> r.getFile().getName()).toList(); })); task.getRawServerJar().set(createCleanArtifacts.flatMap(CreateCleanArtifacts::getRawServerJar)); + task.setLibraries(configurations.launcherProfileClasspath, configurations.modulePath, configurations.javaAgentsClasspath); }); } diff --git a/buildSrc/src/main/java/net/neoforged/neodev/installer/CreateArgsFile.java b/buildSrc/src/main/java/net/neoforged/neodev/installer/CreateArgsFile.java index 6b403d5b944..23c9a59f236 100644 --- a/buildSrc/src/main/java/net/neoforged/neodev/installer/CreateArgsFile.java +++ b/buildSrc/src/main/java/net/neoforged/neodev/installer/CreateArgsFile.java @@ -16,6 +16,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.stream.Collectors; @@ -44,21 +45,24 @@ public CreateArgsFile() {} public abstract Property getRawNeoFormVersion(); @Input - protected abstract Property getPathSeparator(); + public abstract Property getPathSeparator(); @Input - protected abstract Property getModules(); + protected abstract ListProperty getModules(); + + @Input + protected abstract ListProperty getJavaAgents(); @Input public abstract ListProperty getIgnoreList(); @Input - protected abstract Property getClasspath(); + protected abstract ListProperty getClasspath(); - public void setLibraries(String separator, Configuration classpath, Configuration modulePath) { - getPathSeparator().set(separator); - getClasspath().set(DependencyUtils.configurationToClasspath(classpath, "libraries/", separator)); - getModules().set(DependencyUtils.configurationToClasspath(modulePath, "libraries/", separator)); + public void setLibraries(Configuration classpath, Configuration modulePath, Configuration javaAgents) { + getClasspath().set(DependencyUtils.configurationToClasspathItems(classpath, "libraries/")); + getModules().set(DependencyUtils.configurationToClasspathItems(modulePath, "libraries/")); + getJavaAgents().set(DependencyUtils.configurationToClasspathItems(javaAgents, "libraries/")); } @InputFile @@ -71,13 +75,17 @@ public void setLibraries(String separator, Configuration classpath, Configuratio protected abstract ArchiveOperations getArchiveOperations(); private String resolveClasspath() throws IOException { - var ourClasspath = getClasspath().get() + getPathSeparator().get() - + "libraries/net/minecraft/server/%s/server-%s-extra.jar".formatted( - getRawNeoFormVersion().get(), getRawNeoFormVersion().get()); + String pathSeparator = getPathSeparator().get(); + var classpathItems = new ArrayList<>(getClasspath().get()); + classpathItems.add("libraries/net/minecraft/server/%s/server-%s-extra.jar".formatted( + getRawNeoFormVersion().get(), getRawNeoFormVersion().get())); + + // Remove any java agents, since they automatically are on the classpath + classpathItems.removeAll(getJavaAgents().get()); // The raw server jar also contains its own classpath. // We want to make sure that our versions of the libraries are used when there is a conflict. - var ourClasspathEntries = Stream.of(ourClasspath.split(getPathSeparator().get())) + var ourClasspathEntries = classpathItems.stream() .map(CreateArgsFile::stripVersionSuffix) .collect(Collectors.toSet()); @@ -89,9 +97,10 @@ private String resolveClasspath() throws IOException { .filter(path -> !ourClasspathEntries.contains(stripVersionSuffix(path))) // Exclude the actual MC server jar, which is under versions/ .filter(path -> path.startsWith("libraries/")) - .collect(Collectors.joining(getPathSeparator().get())); + .collect(Collectors.joining(pathSeparator)); - return ourClasspath + getPathSeparator().get() + filteredServerClasspath; + classpathItems.add(filteredServerClasspath); + return String.join(pathSeparator, classpathItems); } // Example: @@ -104,14 +113,18 @@ private static String stripVersionSuffix(String classpathEntry) { @TaskAction public void createArgsFile() throws IOException { + var pathSeparator = getPathSeparator().get(); + + var jvmOptions = new ArrayList(); + for (var javaAgent : getJavaAgents().get()) { + jvmOptions.add("-javaagent:" + javaAgent); + } + + jvmOptions.add("-cp"); + jvmOptions.add(resolveClasspath()); + var replacements = new HashMap(); - replacements.put("@MODULE_PATH@", getModules().get()); - replacements.put("@MODULES@", "ALL-MODULE-PATH"); - replacements.put("@IGNORE_LIST@", String.join(",", getIgnoreList().get())); - replacements.put("@PLUGIN_LAYER_LIBRARIES@", ""); - replacements.put("@GAME_LAYER_LIBRARIES@", ""); - replacements.put("@CLASS_PATH@", resolveClasspath()); - replacements.put("@TASK@", "forgeserver"); + replacements.put("@JVM_OPTIONS@", String.join("\n", jvmOptions)); replacements.put("@FORGE_VERSION@", getNeoForgeVersion().get()); replacements.put("@FML_VERSION@", getFmlVersion().get()); replacements.put("@MC_VERSION@", getMinecraftVersion().get()); diff --git a/buildSrc/src/main/java/net/neoforged/neodev/installer/CreateLauncherProfile.java b/buildSrc/src/main/java/net/neoforged/neodev/installer/CreateLauncherProfile.java index 59681903043..830834cb43c 100644 --- a/buildSrc/src/main/java/net/neoforged/neodev/installer/CreateLauncherProfile.java +++ b/buildSrc/src/main/java/net/neoforged/neodev/installer/CreateLauncherProfile.java @@ -57,10 +57,17 @@ public void setLibraries(Configuration libraries) { public abstract ListProperty getIgnoreList(); @Input - protected abstract Property getModulePath(); + protected abstract ListProperty getModulePath(); + + @Input + protected abstract ListProperty getJavaAgentsClasspath(); public void setModules(Configuration modules) { - getModulePath().set(DependencyUtils.configurationToClasspath(modules, "${library_directory}/", "${classpath_separator}")); + getModulePath().set(DependencyUtils.configurationToClasspathItems(modules, "${library_directory}/")); + } + + public void setJavaAgents(Configuration javaAgents) { + getJavaAgentsClasspath().set(DependencyUtils.configurationToClasspathItems(javaAgents, "${library_directory}/")); } @OutputFile @@ -82,17 +89,26 @@ public void createLauncherProfile() throws IOException { var jvmArguments = new ArrayList<>(List.of( "-Djava.net.preferIPv6Addresses=system", - "-DignoreList=" + String.join(",", getIgnoreList().get()), "-DlibraryDirectory=${library_directory}")); + if (!getIgnoreList().get().isEmpty()) { + jvmArguments.add("-DignoreList=" + String.join(",", getIgnoreList().get())); + } + + var modulePath = getModulePath().get(); + if (!modulePath.isEmpty()) { + jvmArguments.add("-p"); + jvmArguments.add(String.join("${classpath_separator}", modulePath)); + } - jvmArguments.add("-p"); - jvmArguments.add(getModulePath().get()); + var javaAgents = getJavaAgentsClasspath().get(); + for (var javaAgent : javaAgents) { + jvmArguments.add("-javaagent:" + javaAgent); + } jvmArguments.addAll(List.of( - "--add-modules", "ALL-MODULE-PATH", - "--add-opens", "java.base/java.util.jar=cpw.mods.securejarhandler", - "--add-opens", "java.base/java.lang.invoke=cpw.mods.securejarhandler", - "--add-exports", "java.base/sun.security.util=cpw.mods.securejarhandler", + "--add-opens", "java.base/java.util.jar=ALL-UNNAMED", + "--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED", + "--add-exports", "java.base/sun.security.util=ALL-UNNAMED", "--add-exports", "jdk.naming.dns/com.sun.jndi.dns=java.naming")); var arguments = new LinkedHashMap>(); @@ -104,7 +120,7 @@ public void createLauncherProfile() throws IOException { time, time, "release", - "cpw.mods.bootstraplauncher.BootstrapLauncher", + "net.neoforged.fml.startup.Client", getMinecraftVersion().get(), arguments, libraries diff --git a/buildSrc/src/main/java/net/neoforged/neodev/utils/DependencyUtils.java b/buildSrc/src/main/java/net/neoforged/neodev/utils/DependencyUtils.java index ee1bb651754..cf2da917e32 100644 --- a/buildSrc/src/main/java/net/neoforged/neodev/utils/DependencyUtils.java +++ b/buildSrc/src/main/java/net/neoforged/neodev/utils/DependencyUtils.java @@ -68,17 +68,17 @@ public static Provider> configurationToGavList(Configuration config } /** - * Turns a configuration into a classpath string, + * Turns a configuration into a list of classpath items, * assuming that the contents of the configuration are installed following the Maven directory layout. * * @param prefix string to add in front of each classpath entry - * @param separator separator to add between each classpath entry */ - public static Provider configurationToClasspath(Configuration configuration, String prefix, String separator) { + public static Provider> configurationToClasspathItems(Configuration configuration, String prefix) { return configuration.getIncoming().getArtifacts().getResolvedArtifacts().map( results -> results.stream() .map(artifact -> prefix + guessMavenIdentifier(artifact).repositoryPath()) - .collect(Collectors.joining(separator)) + .distinct() + .toList() ); } } diff --git a/gradle.properties b/gradle.properties index f37ccd95425..cfad1c6b54c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -32,9 +32,6 @@ mergetool_version=2.0.0 accesstransformers_version=10.0.1 coremods_version=6.0.4 eventbus_version=8.0.2 -modlauncher_version=11.0.4 -securejarhandler_version=3.0.8 -bootstraplauncher_version=2.0.2 asm_version=9.7 mixin_version=0.15.2+mixin.0.8.7 terminalconsoleappender_version=1.3.0 @@ -43,7 +40,7 @@ jetbrains_annotations_version=24.0.1 slf4j_api_version=2.0.7 apache_maven_artifact_version=3.8.5 jarjar_version=0.4.1 -fancy_mod_loader_version=4.0.34 +fancy_mod_loader_version=7.0.50-alpha-pr-232-startup-experiments-nomodules mojang_logging_version=1.1.1 log4j_version=2.22.1 guava_version=31.1.2-jre diff --git a/projects/neoforge/build.gradle b/projects/neoforge/build.gradle index 3912a5bd300..b8d436c5ec2 100644 --- a/projects/neoforge/build.gradle +++ b/projects/neoforge/build.gradle @@ -80,9 +80,8 @@ dependencies { endorseStrictVersions() } - moduleLibraries "cpw.mods:securejarhandler:${project.securejarhandler_version}" for (var asmModule : ["org.ow2.asm:asm", "org.ow2.asm:asm-commons", "org.ow2.asm:asm-tree", "org.ow2.asm:asm-util", "org.ow2.asm:asm-analysis"]) { - moduleLibraries(asmModule) { + libraries(asmModule) { // Vanilla ships with ASM 9.3 transitively (via their OpenID connect library dependency), we require // ASM in a more recent version and have to strictly require this to override the strict Minecraft version. version { @@ -90,8 +89,7 @@ dependencies { } } } - moduleLibraries "cpw.mods:bootstraplauncher:${project.bootstraplauncher_version}" - moduleLibraries "net.neoforged:JarJarFileSystems:${project.jarjar_version}" + libraries "net.neoforged:JarJarFileSystems:${project.jarjar_version}" libraries ("net.neoforged.fancymodloader:loader:${project.fancy_mod_loader_version}") { exclude group: 'org.slf4j' @@ -102,10 +100,12 @@ dependencies { exclude group: 'org.slf4j' exclude group: 'net.fabricmc' } + javaAgents ("net.neoforged.fancymodloader:loader:${project.fancy_mod_loader_version}") { + transitive = false + } libraries "net.neoforged:accesstransformers:${project.accesstransformers_version}" libraries "net.neoforged:bus:${project.eventbus_version}" libraries "net.neoforged:coremods:${project.coremods_version}" - libraries "cpw.mods:modlauncher:${project.modlauncher_version}" libraries "net.neoforged:mergetool:${project.mergetool_version}:api" libraries "com.electronwill.night-config:core:${project.nightconfig_version}" libraries "com.electronwill.night-config:toml:${project.nightconfig_version}" @@ -136,6 +136,11 @@ dependencies { implementation(jarJar(project(":neoforge-coremods"))) } +configurations.configureEach { + exclude(group: "cpw.mods", module: "modlauncher") + exclude(group: "cpw.mods", module: "securejarhandler") +} + neoDev { runs { configureEach { @@ -249,7 +254,7 @@ configurations { modDevApiElements { canBeDeclared = false canBeResolved = false - extendsFrom libraries, moduleLibraries, userdevCompileOnly, neoFormDependencies + extendsFrom libraries, userdevCompileOnly, neoFormDependencies attributes { attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY)) attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL)) @@ -263,7 +268,7 @@ configurations { modDevRuntimeElements { canBeDeclared = false canBeResolved = false - extendsFrom libraries, moduleLibraries, neoFormDependencies + extendsFrom libraries, neoFormDependencies attributes { attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY)) attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL)) @@ -277,7 +282,6 @@ configurations { modDevModulePath { canBeDeclared = false canBeResolved = false - extendsFrom moduleLibraries attributes { attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY)) attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL)) diff --git a/server_files/args.txt b/server_files/args.txt index 2d72f2525cf..ad23ee1ffb8 100644 --- a/server_files/args.txt +++ b/server_files/args.txt @@ -1,18 +1,12 @@ --p @MODULE_PATH@ ---add-modules @MODULES@ ---add-opens java.base/java.util.jar=cpw.mods.securejarhandler ---add-opens java.base/java.lang.invoke=cpw.mods.securejarhandler ---add-exports java.base/sun.security.util=cpw.mods.securejarhandler +@JVM_OPTIONS@ +--add-opens java.base/java.util.jar=ALL-UNNAMED +--add-opens java.base/java.lang.invoke=ALL-UNNAMED +--add-exports java.base/sun.security.util=ALL-UNNAMED --add-exports jdk.naming.dns/com.sun.jndi.dns=java.naming -Djava.net.preferIPv6Addresses=system --DignoreList=@IGNORE_LIST@ --Dfml.pluginLayerLibraries=@PLUGIN_LAYER_LIBRARIES@ --Dfml.gameLayerLibraries=@GAME_LAYER_LIBRARIES@ -DlibraryDirectory=libraries --DlegacyClassPath=@CLASS_PATH@ -cpw.mods.bootstraplauncher.BootstrapLauncher ---launchTarget @TASK@ +net.neoforged.fml.startup.Server --fml.neoForgeVersion @FORGE_VERSION@ --fml.fmlVersion @FML_VERSION@ --fml.mcVersion @MC_VERSION@ ---fml.neoFormVersion @MCP_VERSION@ \ No newline at end of file +--fml.neoFormVersion @MCP_VERSION@ diff --git a/settings.gradle b/settings.gradle index 0efa2e7fedf..ecd46551758 100644 --- a/settings.gradle +++ b/settings.gradle @@ -22,6 +22,15 @@ dependencyResolutionManagement { repositories { mavenCentral() mavenLocal() + maven { + name 'Maven for PR #232' // https://github.com/neoforged/FancyModLoader/pull/232 + url 'https://prmaven.neoforged.net/FancyModLoader/pr232' + content { + includeModule('net.neoforged.fancymodloader', 'junit-fml') + includeModule('net.neoforged.fancymodloader', 'loader') + includeModule('net.neoforged.fancymodloader', 'earlydisplay') + } + } } } diff --git a/src/main/java/net/neoforged/neoforge/junit/JUnitBootstrapper.java b/src/main/java/net/neoforged/neoforge/junit/JUnitBootstrapper.java new file mode 100644 index 00000000000..f94f7d937f2 --- /dev/null +++ b/src/main/java/net/neoforged/neoforge/junit/JUnitBootstrapper.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) NeoForged and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.neoforged.neoforge.junit; + +import net.minecraft.SharedConstants; +import net.minecraft.server.Bootstrap; +import net.neoforged.fml.startup.JUnitGameBootstrapper; + +public class JUnitBootstrapper implements JUnitGameBootstrapper { + @Override + public void bootstrap() { + SharedConstants.tryDetectVersion(); + Bootstrap.bootStrap(); + + // Load mods + net.neoforged.neoforge.server.loading.ServerModLoader.load(); + } +} diff --git a/src/main/java/net/neoforged/neoforge/junit/JUnitMain.java b/src/main/java/net/neoforged/neoforge/junit/JUnitMain.java deleted file mode 100644 index 99ce8c327b4..00000000000 --- a/src/main/java/net/neoforged/neoforge/junit/JUnitMain.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) NeoForged and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.neoforged.neoforge.junit; - -import cpw.mods.modlauncher.Launcher; -import net.minecraft.SharedConstants; -import net.minecraft.server.Bootstrap; -import net.neoforged.fml.common.asm.RuntimeDistCleaner; - -public class JUnitMain { - public static void main(String[] args) { - SharedConstants.tryDetectVersion(); - Bootstrap.bootStrap(); - - // Load mods - net.neoforged.neoforge.server.loading.ServerModLoader.load(); - - // We launch as a server, but we want client classes available. - // Passing null disables dist-cleaning. - var distCleaner = (RuntimeDistCleaner) Launcher.INSTANCE.environment().findLaunchPlugin("runtimedistcleaner").orElseThrow(); - distCleaner.setDistribution(null); - } -} diff --git a/src/main/resources/META-INF/services/net.neoforged.fml.startup.JUnitGameBootstrapper b/src/main/resources/META-INF/services/net.neoforged.fml.startup.JUnitGameBootstrapper new file mode 100644 index 00000000000..56783622a8a --- /dev/null +++ b/src/main/resources/META-INF/services/net.neoforged.fml.startup.JUnitGameBootstrapper @@ -0,0 +1 @@ +net.neoforged.neoforge.junit.JUnitBootstrapper \ No newline at end of file