Skip to content

Commit

Permalink
Lazy JVM Arguments?
Browse files Browse the repository at this point in the history
  • Loading branch information
marchermans committed Nov 14, 2024
1 parent e8cbd63 commit 9ea7f11
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static void createTasks(Project project, Run run) {
runExec.getMainClass().convention(run.getMainClass());
runExec.setWorkingDir(workingDir);
runExec.args(deduplicateElementsFollowingEachOther(run.getArguments().get().stream()).toList());
runExec.jvmArgs(deduplicateElementsFollowingEachOther(run.getJvmArguments().get().stream()).toList());
runExec.getJvmArguments().set(run.getJvmArguments().map(arguments -> deduplicateElementsFollowingEachOther(arguments.stream())).map(Stream::toList));
runExec.systemProperties(run.getSystemProperties().get());
runExec.environment(run.getEnvironmentVariables().get());
run.getModSources().all().get().values().stream()
Expand Down Expand Up @@ -223,16 +223,24 @@ public static void setupRenderDocSupport(Project project, Run run) {

run.getDependsOn().add(setupRenderDoc);

//We need the renderNurse path resolved here, because eclipse resolves the run tasks in a place that is not compatible with late resolve of configurations
//Idea has no such issues, but the problem remains that if we don't get the actuall file and delay the configuration resolve untill import time, it will crash.
File renderNurse = ToolUtilities.resolveTool(project, renderDocTools.getRenderNurse()).get();
Configuration renderNurse = null;
if (run.getModSources().getPrimary().isPresent()) {
renderNurse = addLocalRenderNurse(run.getModSources().getPrimary().get(), run);
}

if (renderNurse == null) {
//This happens when no primary source set is set, and the renderNurse configuration is not added to the runtime classpath.
renderNurse = registerRenderNurse(run.getProject());
}

//Add the relevant properties, so that render nurse can be used, see its readme for the required values.
run.getEnvironmentVariables().put("LD_PRELOAD", setupRenderDoc.flatMap(RenderDocDownloaderTask::getRenderDocLibraryFile).map(RegularFile::getAsFile).map(File::getAbsolutePath));
run.getSystemProperties().put(
"neoforge.rendernurse.renderdoc.library", setupRenderDoc.flatMap(RenderDocDownloaderTask::getRenderDocLibraryFile).map(RegularFile::getAsFile).map(File::getAbsolutePath)
);
run.getJvmArguments().add("-javaagent:%s".formatted(renderNurse.getAbsolutePath()));
run.getJvmArguments().add(renderNurse.getIncoming().getArtifacts().getResolvedArtifacts()
.map(artifactView -> artifactView.iterator().next())
.map(resolvedArtifact -> "-javaagent:%s".formatted(resolvedArtifact.getFile().getAbsolutePath())));
run.getJvmArguments().add("--enable-preview");
run.getJvmArguments().add("--enable-native-access=ALL-UNNAMED");
}
Expand Down

0 comments on commit 9ea7f11

Please sign in to comment.