Skip to content

Commit

Permalink
Remove all usages of Stream.toList().
Browse files Browse the repository at this point in the history
It should work but this was reported from before.
  • Loading branch information
marchermans committed Mar 8, 2025
1 parent 896cae3 commit c029f35
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* A simple manager which configures runs based on the IDE it is attached to.
Expand Down Expand Up @@ -203,9 +204,9 @@ private void createIdeaRun(Project project, Run run, RunConfigurationContainer i

ideaRun.setMainClass(runImpl.getMainClass().get());
ideaRun.setWorkingDirectory(runImpl.getWorkingDirectory().get().getAsFile().getAbsolutePath());
ideaRun.setJvmArgs(RunsUtil.escapeAndJoin(RunsUtil.deduplicateElementsFollowingEachOther(jvmArguments.stream()).toList()));
ideaRun.setJvmArgs(RunsUtil.escapeAndJoin(RunsUtil.deduplicateElementsFollowingEachOther(jvmArguments.stream()).collect(Collectors.toList())));
ideaRun.setModuleName(RunsUtil.getIntellijModuleName(run.getExtensions().getByType(IdeaRunExtension.class).getPrimarySourceSet().get()));
ideaRun.setProgramParameters(RunsUtil.escapeAndJoin(RunsUtil.deduplicateElementsFollowingEachOther(programArguments.stream()).toList()));
ideaRun.setProgramParameters(RunsUtil.escapeAndJoin(RunsUtil.deduplicateElementsFollowingEachOther(programArguments.stream()).collect(Collectors.toList())));
ideaRun.setEnvs(productionEnvironment);
ideaRun.setShortenCommandLine(ShortenCommandLine.ARGS_FILE);

Expand Down Expand Up @@ -343,8 +344,8 @@ public void vscode(Project project, EclipseModel eclipse)

final LaunchConfiguration cfg = launchWriter.createGroup("NG - " + project.getName(), WritingMode.REMOVE_EXISTING)
.createLaunchConfiguration()
.withAdditionalJvmArgs(RunsUtil.deduplicateElementsFollowingEachOther(runImpl.realiseJvmArguments().stream()).toList())
.withArguments(RunsUtil.deduplicateElementsFollowingEachOther(runImpl.getArguments().get().stream()).toList())
.withAdditionalJvmArgs(RunsUtil.deduplicateElementsFollowingEachOther(runImpl.realiseJvmArguments().stream()).collect(Collectors.toList()))
.withArguments(RunsUtil.deduplicateElementsFollowingEachOther(runImpl.getArguments().get().stream()).collect(Collectors.toList()))
.withCurrentWorkingDirectory(PathLike.ofNio(runImpl.getWorkingDirectory().get().getAsFile().toPath()))
.withEnvironmentVariables(adaptEnvironment(runImpl, RunsUtil::buildRunWithEclipseModClasses))
.withShortenCommandLine(ShortCmdBehaviour.ARGUMENT_FILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import javax.inject.Inject;
import java.util.Map;
import java.util.stream.Collectors;

public class JUnitWithBeforeRun extends JUnit {

Expand Down Expand Up @@ -39,7 +40,7 @@ public void beforeRun(Action<PolymorphicDomainObjectContainer<BeforeRunTask>> ac
public Map<String, ?> toMap() {
final Map map = super.toMap();

map.put("beforeRun", beforeRun.stream().map(BeforeRunTask::toMap).toList());
map.put("beforeRun", beforeRun.stream().map(BeforeRunTask::toMap).collect(Collectors.toList()));

return map;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.io.File;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

public abstract class RunImpl implements ConfigurableDSLElement<Run>, Run {

Expand Down Expand Up @@ -90,29 +91,29 @@ public RunImpl(final Project project, final String name) {

getRuntimeClasspath().from(
getModSources().all().map(Multimap::values)
.map(sourcesSets -> sourcesSets.stream().map(SourceSet::getRuntimeClasspath).toList())
.map(sourcesSets -> sourcesSets.stream().map(SourceSet::getRuntimeClasspath).collect(Collectors.toList()))
);
getTestRuntimeClasspath().from(getRuntimeClasspath());
getTestRuntimeClasspath().from(
getUnitTestSources().all().map(Multimap::values)
.map(sourcesSets -> sourcesSets.stream().map(SourceSet::getRuntimeClasspath).toList())
.map(sourcesSets -> sourcesSets.stream().map(SourceSet::getRuntimeClasspath).collect(Collectors.toList()))
);
getCompileClasspath().from(
getModSources().all().map(Multimap::values)
.map(sourcesSets -> sourcesSets.stream().map(SourceSet::getCompileClasspath).toList())
.map(sourcesSets -> sourcesSets.stream().map(SourceSet::getCompileClasspath).collect(Collectors.toList()))
);
getTestCompileClasspath().from(getCompileClasspath());
getTestCompileClasspath().from(
getUnitTestSources().all().map(Multimap::values)
.map(sourcesSets -> sourcesSets.stream().map(SourceSet::getCompileClasspath).toList())
.map(sourcesSets -> sourcesSets.stream().map(SourceSet::getCompileClasspath).collect(Collectors.toList()))
);
getSdkClasspath().from(
getModSources().all().map(Multimap::values)
.map(sourcesSets -> sourcesSets.stream().map(ConfigurationUtils::getSdkConfiguration).toList())
.map(sourcesSets -> sourcesSets.stream().map(ConfigurationUtils::getSdkConfiguration).collect(Collectors.toList()))
);
getSdkClasspath().from(
getUnitTestSources().all().map(Multimap::values)
.map(sourcesSets -> sourcesSets.stream().map(ConfigurationUtils::getSdkConfiguration).toList())
.map(sourcesSets -> sourcesSets.stream().map(ConfigurationUtils::getSdkConfiguration).collect(Collectors.toList()))
);

getShouldExportToIDE().convention(true);
Expand Down Expand Up @@ -299,12 +300,12 @@ private void potentiallyAddRunTemplateFromType() {
rawSpecifications.map(l -> l.stream().filter(RunType.class::isInstance).map(RunType.class::cast)
.map(RunType::getRunTemplate)
.filter(Objects::nonNull)
.toList())
.collect(Collectors.toList()))
);
}

private void configureFromRuns() {
Provider<List<Run>> runSpecifications = specifications.map(l -> l.stream().filter(Run.class::isInstance).map(Run.class::cast).toList());
Provider<List<Run>> runSpecifications = specifications.map(l -> l.stream().filter(Run.class::isInstance).map(Run.class::cast).collect(Collectors.toList()));

//Properties of the run
getWorkingDirectory().convention(
Expand Down Expand Up @@ -648,7 +649,7 @@ private Provider<List<RunType>> getRunTypesByName(String name) {
.map(runTypes::parse)
.flatMap(Collection::stream)
.filter(runType -> runType.getName().equals(name))
.toList()
.collect(Collectors.toList())
))).map(types -> {
if (types.isEmpty()) {
final IProblemReporter reporter = project.getExtensions().getByType(IProblemReporter.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public RenderableRun(Run run) {
this.environment = run.getEnvironmentVariables().get();
this.mainClass = run.getMainClass().get();
this.properties = run.getSystemProperties().get();
this.arguments = RunsUtil.deduplicateElementsFollowingEachOther(run.getArguments().get().stream()).toList();
this.jvmArguments = RunsUtil.deduplicateElementsFollowingEachOther(run.getJvmArguments().get().stream()).toList();
this.arguments = RunsUtil.deduplicateElementsFollowingEachOther(run.getArguments().get().stream()).collect(Collectors.toList());
this.jvmArguments = RunsUtil.deduplicateElementsFollowingEachOther(run.getJvmArguments().get().stream()).collect(Collectors.toList());
this.isSingleInstance = run.getIsSingleInstance().get();
this.workingDirectory = run.getWorkingDirectory().get().getAsFile().getAbsolutePath();
this.isClient = run.getIsClient().get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public final class TaskHasher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ 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.getJvmArguments().set(run.getJvmArguments().map(arguments -> deduplicateElementsFollowingEachOther(arguments.stream())).map(Stream::toList));
runExec.args(deduplicateElementsFollowingEachOther(run.getArguments().get().stream()).collect(Collectors.toList()));
runExec.getJvmArguments().set(run.getJvmArguments().map(arguments -> deduplicateElementsFollowingEachOther(arguments.stream())).map(s -> s.collect(Collectors.toList())));
runExec.systemProperties(run.getSystemProperties().get());
runExec.environment(run.getEnvironmentVariables().get());
run.getModSources().all().get().values().stream()
Expand Down Expand Up @@ -409,7 +409,7 @@ private static File createArgsFile(Provider<RegularFile> outputFile, List<String
}
}
try {
final List<String> value = deduplicateElementsFollowingEachOther(inputs.stream()).toList();
final List<String> value = deduplicateElementsFollowingEachOther(inputs.stream()).collect(Collectors.toList());
if (output.exists()) {
if (Files.readAllLines(output.toPath()).equals(value)) {
return output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ protected NeoFormRuntimeDefinition doCreate(final NeoFormRuntimeSpecification sp
versionJson.map(VersionJson::getLibraries)
.map(libraries -> libraries.stream()
.map(library -> getProject().getDependencies().create(library.getName()))
.toList()
.collect(Collectors.toList())
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private Provider<List<String>> parseFileInternal(File file) {
.map(fls -> fls.stream()
.map(FileSystemLocation::getAsFile)
.filter(File::isFile)
.toList()
.collect(Collectors.toList())
)
.map(files -> files.stream()
.map(this::parseInternalFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;

public final class UserDevDependencyManager {
private static final UserDevDependencyManager INSTANCE = new UserDevDependencyManager();
Expand Down Expand Up @@ -48,7 +49,7 @@ private void registerUnitTestDependencyMapping(Project project) {
run.getSdkClasspathElements()
.map(files -> files.stream()
.map(FileSystemLocation::getAsFile)
.map(parser::parse).toList())
.map(parser::parse).collect(Collectors.toList()))
.flatMap(TransformerUtils.combineAllLists(project, String.class, Function.identity()))
.map(dependencyCoordinates -> {
final DependencyCollector collector = project.getObjects().dependencyCollector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class UserDevRunTypeParser implements RunTypeManager.Parser {
Expand Down Expand Up @@ -43,7 +44,7 @@ public Collection<RunType> parse(File file) {
.getFiles()
.stream()
.flatMap(this::parseInternalFile)
.toList();
.collect(Collectors.toList());
}

private Stream<RunType> parseInternalFile(File file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* Utility class which handles gradles transformers.
Expand Down Expand Up @@ -202,7 +203,7 @@ record Entry<K, V>(K key, V value) {}
final ListProperty<Entry<K, V>> map = (ListProperty) project.getObjects().listProperty(Entry.class);
return guard(t -> {
for (I i : t) {
map.addAll(valueProvider.apply(i).map(m -> m.entries().stream().map(e -> new Entry<>(e.getKey(), e.getValue())).toList()));
map.addAll(valueProvider.apply(i).map(m -> m.entries().stream().map(e -> new Entry<>(e.getKey(), e.getValue())).collect(Collectors.toList())));
}
return map.map(entries -> {
final Multimap<K, V> multimap = Multimaps.newSetMultimap(new HashMap<>(), HashSet::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;

/**
* Represents a configured and registered runtime for vanilla.
Expand Down Expand Up @@ -101,7 +102,7 @@ public void configureRun(RunImpl run) {
.map(stream -> stream
.filter(VersionJson.RuledObject::isAllowed)
.flatMap(arg -> arg.value.stream())
.toList()
.collect(Collectors.toList())
)

);
Expand All @@ -112,7 +113,7 @@ public void configureRun(RunImpl run) {
.map(stream -> stream
.filter(VersionJson.RuledObject::isAllowed)
.flatMap(arg -> arg.value.stream())
.toList()
.collect(Collectors.toList())
)
);
run.getMainClass().set(getVersionJson().map(VersionJson::getMainClass));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

@SuppressWarnings({"unused"}) // API Design
public abstract class VanillaRuntimeExtension extends CommonRuntimeExtension<VanillaRuntimeSpecification, VanillaRuntimeSpecification.Builder, VanillaRuntimeDefinition> {
Expand Down Expand Up @@ -81,7 +82,7 @@ protected VanillaRuntimeDefinition doCreate(final VanillaRuntimeSpecification sp

final Configuration minecraftDependenciesConfiguration = ConfigurationUtils.temporaryConfiguration(getProject(), "VanillaMinecraftDependenciesFor" + spec.getIdentifier());
minecraftDependenciesConfiguration.getDependencies().addAllLater(
versionJson.map(VersionJson::getLibraries).map(libraries -> libraries.stream().map(library -> spec.getProject().getDependencies().create(library.getName())).toList())
versionJson.map(VersionJson::getLibraries).map(libraries -> libraries.stream().map(library -> spec.getProject().getDependencies().create(library.getName())).collect(Collectors.toList()))
);

stepsMcpDirectory.mkdirs();
Expand Down

0 comments on commit c029f35

Please sign in to comment.