Skip to content

Refactor process configuration ownership - #131

Open
mezz wants to merge 1 commit into
neoforged:mainfrom
mezz:refactor/compiler-config
Open

mezz wants to merge 1 commit into
neoforged:mainfrom
mezz:refactor/compiler-config

Conversation

@mezz

@mezz mezz commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

This PR is a small refactor that aims to create some stronger invariants (eliminate the possibility for invalid intermediate states).

BuildOptions, ProcessGeneration, and classpath configurations are now constructed with final values.

ExtensibleClasspath is replaced by ClasspathConfiguration, which centralizes whether we include the Minecraftlibrary, the dependency precedence, resolution, and cache-key generation in one place. This new class is immutable, and reduces the number of possible states, which simplifies reasoning about it.

@neoforged-pr-publishing

Copy link
Copy Markdown
  • Publish PR to GitHub Packages

Comment on lines -226 to -235
// Add NeoForge libraries to the list of libraries
engine.applyTransform(new ModifyAction<>(
"recompile",
RecompileSourcesAction.class,
action -> {
action.getClasspath().addMavenLibraries(neoforgeConfig.libraries());
action.getClasspath().addPaths(List.of(neoforgeClasses));
}
));

@mezz mezz Sep 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The recompile action is now constructed with the complete classpath instead of being mutated afterward

@sciwhiz12 sciwhiz12 added the enhancement New feature or request label Sep 5, 2026
Comment on lines +191 to +211
final ClasspathConfiguration neoFormClasspathConfig;
final ClasspathConfiguration compileClasspathConfig;

var overriddenCompileClasspath = buildOptions.getOverriddenCompileClasspath();
if (overriddenCompileClasspath != null) {
neoFormClasspathConfig = ClasspathConfiguration.of(overriddenCompileClasspath);
compileClasspathConfig = neoFormClasspathConfig;
} else {
var neoFormClasspathEntries = new ArrayList<ClasspathItem>();
for (var library : distConfig.libraries()) {
neoFormClasspathEntries.add(ClasspathItem.of(library));
}
neoFormClasspathConfig = ClasspathConfiguration.ofMinecraftAnd(neoFormClasspathEntries);
if (additionalCompileClasspath.isEmpty()) {
compileClasspathConfig = neoFormClasspathConfig;
} else {
var compileClasspathEntries = new ArrayList<>(neoFormClasspathEntries);
compileClasspathEntries.addAll(additionalCompileClasspath);
compileClasspathConfig = ClasspathConfiguration.ofMinecraftAnd(compileClasspathEntries);
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this section demonstrates the strength of passing around ClasspathConfiguration, there are only a few possible configurations to reason about and they're all decided in one place here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants