Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imperative Configuration V2 #200

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Imperative Configuration V2 #200

wants to merge 10 commits into from

Conversation

shartte
Copy link
Collaborator

@shartte shartte commented Dec 10, 2024

No description provided.

@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented Dec 10, 2024

  • Publish PR to GitHub Packages

Last commit published: 2c44516430ba30984829c5d72c5764881a453094.

PR Publishing

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven {
        name 'Maven for PR #200' // https://github.com/neoforged/ModDevGradle/pull/200
        url 'https://prmaven.neoforged.net/ModDevGradle/pr200'
        content {
            includeModule('net.neoforged.moddev.legacyforge', 'net.neoforged.moddev.legacyforge.gradle.plugin')
            includeModule('net.neoforged.moddev', 'net.neoforged.moddev.gradle.plugin')
            includeModule('net.neoforged', 'moddev-gradle')
            includeModule('net.neoforged.moddev.repositories', 'net.neoforged.moddev.repositories.gradle.plugin')
        }
    }
}

@neoforged-automation neoforged-automation bot added the needs rebase This Pull Request needs to be rebased before being merged label Dec 12, 2024
@neoforged-automation
Copy link

@shartte, this pull request has conflicts, please resolve them for this PR to move forward.

@shartte shartte force-pushed the imperative-config-v2 branch 3 times, most recently from aa22bc9 to 2ecd9d7 Compare December 15, 2024 23:25
@neoforged-automation neoforged-automation bot removed the needs rebase This Pull Request needs to be rebased before being merged label Dec 15, 2024
@shartte shartte force-pushed the imperative-config-v2 branch from 2ecd9d7 to f8ff404 Compare December 15, 2024 23:26
@shartte shartte marked this pull request as ready for review December 22, 2024 20:22
* Contains the list of source sets for which access to Minecraft classes should be configured.
* Defaults to the main source set, but can also be set to an empty list.
*/
public abstract ListProperty<SourceSet> getEnabledSourceSets();
Copy link
Member

Choose a reason for hiding this comment

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

Can you not put this in a common settings class?

try {
toolchainSpec.getLanguageVersion().convention(JavaLanguageVersion.of(versionCapabilities.javaVersion()));
} catch (IllegalStateException e) {
// We tried our best
Copy link
Member

Choose a reason for hiding this comment

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

What could error like this?

// We tried our best
}

// Add a filtered parchment repository automatically if enabled
Copy link
Member

Choose a reason for hiding this comment

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

Uh? We're pulling Parchment from our mirror.

Comment on lines +122 to +123
task.getParchmentData().from(parchmentData);
task.getParchmentEnabled().set(parchment.getEnabled());
Copy link
Member

Choose a reason for hiding this comment

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

Instead of these enabled booleans, can we not simply check if the artifact has been configured?

task.getParchmentConflictResolutionPrefix().set(parchment.getConflictResolutionPrefix());

Function<WorkflowArtifact, Provider<RegularFile>> artifactPathStrategy = artifact ->
modDevBuildDir.map(dir -> dir.dir("artifacts").file(artifactNamingStrategy.getFilename(artifact)));
Copy link
Member

Choose a reason for hiding this comment

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

Pull the artifacts dir outside of the lambda.

/**
* Collects all dependencies needed by the NeoFormRuntime
*/
private static List<Configuration> configureArtifactManifestConfigurations(
Copy link
Member

Choose a reason for hiding this comment

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

I'm pedantic but put this method immediately after create.

}

public Provider<RegularFile> requestAdditionalMinecraftArtifact(String id, String filename) {
return requestAdditionalMinecraftArtifact(id, modDevBuildDir.map(dir -> dir.file(filename)));
Copy link
Member

Choose a reason for hiding this comment

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

Should this not be in the artifacts dir? Or maybe another dir? Putting everything in the same dir is a bit annoying.

spec.getDependencies().add(runTypesConfigDependency);
});
} else {
// Create an implicit configuration
Copy link
Member

Choose a reason for hiding this comment

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

What does this mean? The configuration is null.

Consumer<Configuration> configureModulePath,
Consumer<Configuration> configureLegacyClasspath,
Provider<RegularFile> assetPropertiesFile,
Provider<VersionCapabilities> versionCapabilities
Copy link
Member

Choose a reason for hiding this comment

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

Why is this a provider if it is always known ahead of time? In NeoDev you can supply null.


// FML searches for client resources on the legacy classpath
private void addClientResources(Project project, Configuration spec, TaskProvider<CreateMinecraftArtifacts> createArtifacts) {
// FML searches for client resources on the legacy classpath
Copy link
Member

Choose a reason for hiding this comment

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

Duplicated comment

}

for (var target : testSuite.getTargets()) {
setupTestTask(
Copy link
Member

Choose a reason for hiding this comment

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

The current state of setupTestTask definitely does not support multiple test tasks and will fail miserably trying to configure more than one test task, we should change that or have a nicer error message.

/**
* Used to customize the groups of tasks generated by MDG.
*
* @param publicTaskGroup Use this group for tasks that are considered to be part of the user-interface of MDG.
* @param internalTaskGroup Use this group for tasks that are considered to be an implementation detail of MDG.
*/
record Branding(String publicTaskGroup, String internalTaskGroup) {
@ApiStatus.Internal
Copy link
Member

Choose a reason for hiding this comment

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

redundant since the package is already internal


/**
* This is the top-level {@code neoForge} extension, used to configure the moddev plugin.
*/
public abstract class NeoForgeExtension {
public abstract class NeoForgeExtension extends ModDevExtension {
Copy link
Member

Choose a reason for hiding this comment

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

I am not convinced that splitting the extension in two is necessary or useful, when the only difference is changing some field from neoForgeVersion to forgeVersion.

Copy link
Member

Choose a reason for hiding this comment

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

(My main annoyance is how messy the diff of this PR gets).

@@ -28,7 +28,7 @@ public void testApplyInEmptyProject() throws IOException {
.withArguments("tasks", "--all")
.build();

assertThat(result.getOutput()).contains("createMinecraftArtifacts");
assertThat(result.getOutput()).doesNotContain("createMinecraftArtifacts");
Copy link
Member

Choose a reason for hiding this comment

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

what?

@@ -29,7 +29,7 @@ public void testApplyInEmptyProject() throws IOException {
.withArguments("tasks", "--all")
.build();

assertThat(result.getOutput()).contains("createMinecraftArtifacts");
assertThat(result.getOutput()).doesNotContain("createMinecraftArtifacts");
Copy link
Member

Choose a reason for hiding this comment

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

what?

@@ -94,7 +94,7 @@ public static TaskProvider<JarJar> registerWithConfiguration(Project project, St
// jvm version. We could copy DefaultJvmFeature, and search for the target version of the compile task,
// but this is difficult - we only have a feature name, not the linked source set. For this reason, we use
// the toolchain version, which is the most likely to be correct.
attributes.attributeProvider(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, javaPlugin.getToolchain().getLanguageVersion().map(JavaLanguageVersion::asInt));
attributes.attributeProvider(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, javaPlugin.getToolchain().getLanguageVersion().orElse(JavaLanguageVersion.current()).map(JavaLanguageVersion::asInt));
Copy link
Member

Choose a reason for hiding this comment

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

Why?

*/
public void setVersion(Object version) {
enableModding(settings -> {
settings.setForgeVersion(version.toString());
Copy link
Member

Choose a reason for hiding this comment

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

toString?

.extendsFrom(configurations.getByName(ModDevPlugin.CONFIGURATION_COMPILE_DEPENDENCIES));
public void setVersion(Object version) {
enableModding(settings -> {
settings.setNeoForgeVersion(version.toString());
Copy link
Member

Choose a reason for hiding this comment

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

toString?

@neoforged-automation
Copy link

@shartte, this pull request has conflicts, please resolve them for this PR to move forward.

@neoforged-automation neoforged-automation bot added the needs rebase This Pull Request needs to be rebased before being merged label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs rebase This Pull Request needs to be rebased before being merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants