Skip to content

Commit

Permalink
Update DynamicProjectExtension.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed Jul 4, 2024
1 parent a5120f9 commit bed4125
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import net.neoforged.gradle.common.util.constants.RunsConstants;
import net.neoforged.gradle.dsl.common.extensions.AccessTransformers;
import net.neoforged.gradle.dsl.common.extensions.Mappings;
import net.neoforged.gradle.dsl.common.extensions.subsystems.Subsystems;
import net.neoforged.gradle.dsl.common.runs.run.Run;
import net.neoforged.gradle.dsl.common.runs.type.RunType;
import net.neoforged.gradle.dsl.common.runtime.naming.TaskBuildingContext;
Expand Down Expand Up @@ -316,12 +315,12 @@ public void runtime(final String neoFormVersion, Directory patches, Directory re
});

var mergeMappings = runtimeDefinition.getJoinedNeoFormRuntimeDefinition().getTask("mergeMappings");
Provider<RegularFile> compiledJarProvider = maybeRenameCompiledJar(
Provider<RegularFile> compiledJarProvider = parchmentArtifact.isPresent() ? renameCompiledJar(
parchmentArtifact.flatMap(ver -> mergeMappings.flatMap(WithOutput::getOutput)),
project.getTasks().named(mainSource.getJarTaskName(), Jar.class),
runtimeDefinition,
workingDirectory
);
) : project.getTasks().named(mainSource.getJarTaskName(), Jar.class).flatMap(Jar::getArchiveFile);

javaPluginExtension.withSourcesJar();
final TaskProvider<? extends Jar> sourcesJarProvider = project.getTasks().named(mainSource.getSourcesJarTaskName(), Jar.class);
Expand Down Expand Up @@ -998,15 +997,11 @@ private TaskProvider<? extends WithOutput> createFlippedMojMapProvider(final Tas
});
}

private Provider<RegularFile> maybeRenameCompiledJar(Provider<RegularFile> mappingsFile,
TaskProvider<? extends Jar> input,
final RuntimeDevRuntimeDefinition runtimeDefinition,
final File workingDirectory) {
private Provider<RegularFile> renameCompiledJar(Provider<RegularFile> mappingsFile,
TaskProvider<? extends Jar> input,
final RuntimeDevRuntimeDefinition runtimeDefinition,
final File workingDirectory) {
var inputFile = input.flatMap(Jar::getArchiveFile);
if (!mappingsFile.isPresent()) {
return inputFile;
}

return project.getTasks().register(CommonRuntimeUtils.buildTaskName(runtimeDefinition, "renameCompiledJar"), DefaultExecute.class, task -> {
task.getArguments().putFile("mappings", mappingsFile.map(RegularFile::getAsFile));
task.getArguments().putRegularFile("input", inputFile);
Expand Down

0 comments on commit bed4125

Please sign in to comment.