Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ public void enable(Project project, LegacyForgeModdingSettings settings, LegacyF
artifactNamingStrategy,
configurations.getByName(DataFileCollections.CONFIGURATION_ACCESS_TRANSFORMERS),
configurations.getByName(DataFileCollections.CONFIGURATION_INTERFACE_INJECTION_DATA),
versionCapabilities);
versionCapabilities,
false
);

var runs = ModDevRunWorkflow.create(
project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public abstract class ModdingVersionSettings {

private Set<SourceSet> enabledSourceSets = new HashSet<>();

private boolean binaryPatches = false;

@Inject
public ModdingVersionSettings(Project project) {
// By default, enable modding deps only for the main source set
Expand Down Expand Up @@ -60,4 +62,12 @@ public Set<SourceSet> getEnabledSourceSets() {
public void setEnabledSourceSets(Set<SourceSet> enabledSourceSets) {
this.enabledSourceSets = enabledSourceSets;
}

public boolean isBinaryPatches() {
return binaryPatches;
}

public void setBinaryPatches(boolean binaryPatches) {
this.binaryPatches = binaryPatches;
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public void enable(
artifactNamingStrategy,
configurations.getByName(DataFileCollections.CONFIGURATION_ACCESS_TRANSFORMERS),
configurations.getByName(DataFileCollections.CONFIGURATION_INTERFACE_INJECTION_DATA),
versionCapabilities);
versionCapabilities,
settings.isBinaryPatches());

ModDevRunWorkflow.create(
project,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package net.neoforged.moddevgradle.internal;

import java.io.File;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import net.neoforged.minecraftdependencies.MinecraftDistribution;
import net.neoforged.moddevgradle.dsl.InternalModelHelper;
import net.neoforged.moddevgradle.dsl.ModModel;
Expand Down Expand Up @@ -40,6 +33,15 @@
import org.jetbrains.annotations.Nullable;
import org.slf4j.event.Level;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

/**
* After modding has been enabled, this will be attached as an extension to the project.
*/
Expand Down Expand Up @@ -69,14 +71,14 @@ public class ModDevRunWorkflow {
* (apiElements vs. runtimeElements).
*/
private ModDevRunWorkflow(Project project,
Branding branding,
ModDevArtifactsWorkflow artifactsWorkflow,
@Nullable ModuleDependency modulePathDependency,
@Nullable ModuleDependency runTypesConfigDependency,
@Nullable ModuleDependency testFixturesDependency,
ModuleDependency gameLibrariesDependency,
DomainObjectCollection<RunModel> runs,
VersionCapabilitiesInternal versionCapabilities) {
Branding branding,
ModDevArtifactsWorkflow artifactsWorkflow,
@Nullable ModuleDependency modulePathDependency,
@Nullable ModuleDependency runTypesConfigDependency,
@Nullable ModuleDependency testFixturesDependency,
ModuleDependency gameLibrariesDependency,
DomainObjectCollection<RunModel> runs,
VersionCapabilitiesInternal versionCapabilities) {
this.project = project;
this.branding = branding;
this.modulePathDependency = modulePathDependency;
Expand Down Expand Up @@ -107,7 +109,7 @@ private ModDevRunWorkflow(Project project,
if (!versionCapabilities.modLocatorRework()) {
// Forge expects to find the Forge and client-extra jar on the legacy classpath
// Newer FML versions also search for it on the java.class.path.
spec.getDependencies().addLater(artifactsWorkflow.minecraftClassesDependency());
artifactsWorkflow.minecraftRuntimeDependencies().forEach(spec.getDependencies()::addLater);
}
});

Expand Down Expand Up @@ -136,9 +138,9 @@ public static ModDevRunWorkflow get(Project project) {
}

public static ModDevRunWorkflow create(Project project,
Branding branding,
ModDevArtifactsWorkflow artifactsWorkflow,
DomainObjectCollection<RunModel> runs) {
Branding branding,
ModDevArtifactsWorkflow artifactsWorkflow,
DomainObjectCollection<RunModel> runs) {
var dependencies = artifactsWorkflow.dependencies();
var versionCapabilites = artifactsWorkflow.versionCapabilities();

Expand Down Expand Up @@ -203,10 +205,17 @@ public void configureTesting(Provider<ModModel> testedMod, Provider<Set<ModModel
}

// FML searches for client resources on the legacy classpath
private static void addClientResources(Project project, Configuration spec, TaskProvider<CreateMinecraftArtifacts> createArtifacts) {
private static void addClientResources(Project project, Configuration spec, TaskProvider<? extends Task> createArtifacts) {
spec.getDependencies().add(
project.getDependencyFactory().create(
project.files(createArtifacts.flatMap(CreateMinecraftArtifacts::getResourcesArtifact))));
project.files(createArtifacts.flatMap(task -> {
if (task instanceof CreateMinecraftArtifacts createMinecraftArtifacts) {
return createMinecraftArtifacts.getResourcesArtifact();
} else {
return project.provider(() -> project.files());
}
})))
);
}

public static void setupRuns(
Expand Down Expand Up @@ -397,15 +406,15 @@ private static TaskProvider<PrepareRun> setupRunInGradle(
* @see #setupRunInGradle for a description of the parameters
*/
static void setupTestTask(Project project,
Branding branding,
Object runTemplatesSourceFile,
TaskProvider<Test> testTask,
Provider<Set<ModModel>> loadedMods,
Provider<ModModel> testedMod,
Provider<Directory> argFileDir,
Consumer<Configuration> configureModulePath,
Consumer<Configuration> configureLegacyClasspath,
Provider<RegularFile> assetPropertiesFile) {
Branding branding,
Object runTemplatesSourceFile,
TaskProvider<Test> testTask,
Provider<Set<ModModel>> loadedMods,
Provider<ModModel> testedMod,
Provider<Directory> argFileDir,
Consumer<Configuration> configureModulePath,
Consumer<Configuration> configureLegacyClasspath,
Provider<RegularFile> assetPropertiesFile) {
var gameDirectory = new File(project.getProjectDir(), JUNIT_GAME_DIR);

var ideIntegration = IdeIntegration.of(project, branding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private UserDevConfig getSimulatedUserDevConfigForVanilla() {
true, "net.minecraft.data.Main", commonArgs, List.of(), Map.of(), Map.of()));
}

return new UserDevConfig(runTypes);
return new UserDevConfig(runTypes, null);
}

private void writeJvmArguments(UserDevRunType runConfig, Map<String, String> additionalProperties) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private void applyRepositories(RepositoryHandler repositories) {
repo.setName("NeoForged Releases");
repo.setUrl(URI.create("https://maven.neoforged.net/releases/"));
});
repositories.mavenLocal();
}

private static void sortFirst(RepositoryHandler repositories, MavenArtifactRepository repo) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package net.neoforged.moddevgradle.internal;

import com.google.gson.Gson;
import org.gradle.api.GradleException;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Map;
import java.util.zip.ZipFile;

/**
* Sourced from the userdev config json. The run templates are the only thing that we use.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment needs an update. :P

*/
public record UserDevConfig(Map<String, UserDevRunType> runs) implements Serializable {
public record UserDevConfig(Map<String, UserDevRunType> runs, String binpatches) implements Serializable {
public static UserDevConfig from(InputStream in) {
return new Gson().fromJson(new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)), UserDevConfig.class);
}
Expand Down
Loading
Loading