From e57e0d49566cc905de8cc9d4549740b4977a2ae7 Mon Sep 17 00:00:00 2001 From: Miroslav Pokorny Date: Thu, 5 Sep 2024 14:39:58 +1000 Subject: [PATCH] https://github.com/mP1/walkingkooka/pull/2773 SortedSets & ImmutableSortedSet - https://github.com/mP1/walkingkooka/pull/2773 - SortedSets & ImmutableSortedSet --- src/main/java/walkingkooka/j2cl/maven/J2clArtifact.java | 5 +++-- .../java/walkingkooka/j2cl/maven/J2clArtifactCoords.java | 4 ++-- .../java/walkingkooka/j2cl/maven/J2clMavenContext.java | 4 ++-- .../walkingkooka/j2cl/maven/J2clMojoBuildTestWatch.java | 4 ++-- src/main/java/walkingkooka/j2cl/maven/J2clMojoTest.java | 4 ++-- src/main/java/walkingkooka/j2cl/maven/J2clPath.java | 3 ++- .../walkingkooka/j2cl/maven/closure/ClosureCompiler.java | 7 +++++-- .../java/walkingkooka/j2cl/maven/hash/J2clTaskHash.java | 4 ++-- .../j2cl/maven/output/J2clTaskOutputAssembler.java | 3 ++- .../java/walkingkooka/j2cl/maven/shade/J2clTaskShade.java | 8 ++++---- .../maven/strip/GwtIncompatibleStripPreprocessor.java | 3 ++- .../j2cl/maven/J2clArtifactGraphCalculatorTest.java | 3 ++- 12 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/main/java/walkingkooka/j2cl/maven/J2clArtifact.java b/src/main/java/walkingkooka/j2cl/maven/J2clArtifact.java index e9bebf22..46b54e7e 100644 --- a/src/main/java/walkingkooka/j2cl/maven/J2clArtifact.java +++ b/src/main/java/walkingkooka/j2cl/maven/J2clArtifact.java @@ -29,6 +29,7 @@ import walkingkooka.collect.list.Lists; import walkingkooka.collect.map.Maps; import walkingkooka.collect.set.Sets; +import walkingkooka.collect.set.SortedSets; import walkingkooka.j2cl.maven.log.TreeLogger; import walkingkooka.predicate.Predicates; import walkingkooka.reflect.PackageName; @@ -566,7 +567,7 @@ private void verify(final TreeLogger logger) { this.context.verifyClasspathRequiredJavascriptSourceRequiredIgnoredDependencies( all.stream() .map(J2clArtifact::coords) - .collect(Collectors.toCollection(Sets::sorted)), + .collect(Collectors.toCollection(SortedSets::tree)), this, logger ); @@ -708,7 +709,7 @@ private void logDependencies(final String label, this.dependencies().stream() .filter(filter) .map(J2clArtifact::toString) - .collect(Collectors.toCollection(Sets::sorted)) + .collect(Collectors.toCollection(SortedSets::tree)) ); } diff --git a/src/main/java/walkingkooka/j2cl/maven/J2clArtifactCoords.java b/src/main/java/walkingkooka/j2cl/maven/J2clArtifactCoords.java index 2bb07a68..a563cf44 100644 --- a/src/main/java/walkingkooka/j2cl/maven/J2clArtifactCoords.java +++ b/src/main/java/walkingkooka/j2cl/maven/J2clArtifactCoords.java @@ -21,7 +21,7 @@ import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.model.Dependency; -import walkingkooka.collect.set.Sets; +import walkingkooka.collect.set.SortedSets; import walkingkooka.j2cl.maven.unpack.J2clTaskUnpack; import walkingkooka.text.CharSequences; @@ -40,7 +40,7 @@ final class J2clArtifactCoords implements Comparable { * Creates a sorted {@link Set} to hold coords. */ static Set set() { - return Sets.sorted(); + return SortedSets.tree(); } /** diff --git a/src/main/java/walkingkooka/j2cl/maven/J2clMavenContext.java b/src/main/java/walkingkooka/j2cl/maven/J2clMavenContext.java index 97d672d0..55e1d953 100644 --- a/src/main/java/walkingkooka/j2cl/maven/J2clMavenContext.java +++ b/src/main/java/walkingkooka/j2cl/maven/J2clMavenContext.java @@ -22,7 +22,7 @@ import walkingkooka.Context; import walkingkooka.collect.list.Lists; import walkingkooka.collect.map.Maps; -import walkingkooka.collect.set.Sets; +import walkingkooka.collect.set.SortedSets; import walkingkooka.j2cl.maven.closure.ClosureFormattingOption; import walkingkooka.j2cl.maven.hash.HashBuilder; import walkingkooka.j2cl.maven.log.MavenLogger; @@ -307,7 +307,7 @@ private void prepareTasks(final J2clArtifact artifact) { if (false == this.tasks.containsKey(artifact)) { // keep transitive dependencies alphabetical sorted for better readability when trySubmitTasks pretty prints queue processing. - final Set required = Sets.sorted(); + final Set required = SortedSets.tree(); this.tasks.put(artifact, required); diff --git a/src/main/java/walkingkooka/j2cl/maven/J2clMojoBuildTestWatch.java b/src/main/java/walkingkooka/j2cl/maven/J2clMojoBuildTestWatch.java index b46fc1bc..7f2f1537 100644 --- a/src/main/java/walkingkooka/j2cl/maven/J2clMojoBuildTestWatch.java +++ b/src/main/java/walkingkooka/j2cl/maven/J2clMojoBuildTestWatch.java @@ -29,7 +29,7 @@ import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; -import walkingkooka.collect.set.Sets; +import walkingkooka.collect.set.SortedSets; import walkingkooka.j2cl.maven.closure.ClosureFormattingOption; import walkingkooka.j2cl.maven.log.TreeLogger; import walkingkooka.text.CharSequences; @@ -222,7 +222,7 @@ final Set formatting() { final Set javaCompilerArguments() { return this.javaCompilerArguments.stream() .map(String::trim) - .collect(Collectors.toCollection(Sets::sorted)); + .collect(Collectors.toCollection(SortedSets::tree)); } @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") diff --git a/src/main/java/walkingkooka/j2cl/maven/J2clMojoTest.java b/src/main/java/walkingkooka/j2cl/maven/J2clMojoTest.java index f5fc9368..d5237db8 100644 --- a/src/main/java/walkingkooka/j2cl/maven/J2clMojoTest.java +++ b/src/main/java/walkingkooka/j2cl/maven/J2clMojoTest.java @@ -23,7 +23,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import walkingkooka.collect.list.Lists; -import walkingkooka.collect.set.Sets; +import walkingkooka.collect.set.SortedSets; import walkingkooka.j2cl.maven.log.BrowserLogLevel; import walkingkooka.j2cl.maven.log.MavenLogger; import walkingkooka.j2cl.maven.log.TreeLogger; @@ -147,7 +147,7 @@ private List findTestClassNames(final TreeLogger logger) throws IOExcept logger.line(testSourceRootPath.toAbsolutePath().toString()); logger.indent(); { - final Set tests = Sets.sorted(); + final Set tests = SortedSets.tree(); final List pathMatchers = this.tests(testSourceRootPath); Files.walkFileTree(testSourceRootPath, new SimpleFileVisitor<>() { diff --git a/src/main/java/walkingkooka/j2cl/maven/J2clPath.java b/src/main/java/walkingkooka/j2cl/maven/J2clPath.java index d78e2a57..a47ffe58 100644 --- a/src/main/java/walkingkooka/j2cl/maven/J2clPath.java +++ b/src/main/java/walkingkooka/j2cl/maven/J2clPath.java @@ -21,6 +21,7 @@ import walkingkooka.collect.list.Lists; import walkingkooka.collect.map.Maps; import walkingkooka.collect.set.Sets; +import walkingkooka.collect.set.SortedSets; import walkingkooka.file.Files2; import walkingkooka.j2cl.maven.log.TreeFormat; import walkingkooka.j2cl.maven.log.TreeLogger; @@ -273,7 +274,7 @@ public Set gatherFiles(final Predicate filter) throws IOExceptio return Files.find(this.path(), Integer.MAX_VALUE, (p, a) -> filter.test(p)) .map(J2clPath::with) .sorted() - .collect(Collectors.toCollection(Sets::sorted)); + .collect(Collectors.toCollection(SortedSets::tree)); } public boolean isFile() { diff --git a/src/main/java/walkingkooka/j2cl/maven/closure/ClosureCompiler.java b/src/main/java/walkingkooka/j2cl/maven/closure/ClosureCompiler.java index fa151223..0223119e 100644 --- a/src/main/java/walkingkooka/j2cl/maven/closure/ClosureCompiler.java +++ b/src/main/java/walkingkooka/j2cl/maven/closure/ClosureCompiler.java @@ -26,6 +26,7 @@ import walkingkooka.collect.list.Lists; import walkingkooka.collect.map.Maps; import walkingkooka.collect.set.Sets; +import walkingkooka.collect.set.SortedSets; import walkingkooka.j2cl.maven.J2clArtifact; import walkingkooka.j2cl.maven.J2clMavenContext; import walkingkooka.j2cl.maven.J2clPath; @@ -163,7 +164,9 @@ private static boolean compile0(final J2clArtifact artifact, defines, entryPoints, externs, - formatting.stream().map(ClosureFormattingOption::name).collect(Collectors.toCollection(Sets::sorted)), + formatting.stream() + .map(ClosureFormattingOption::name) + .collect(Collectors.toCollection(SortedSets::tree)), languageOut, sourceMaps, unitedSourceRoot, @@ -250,7 +253,7 @@ private static Map> prepareArguments(final Compilatio arguments.put("--compilation_level", Sets.of(compilationLevel.name())); { - final Set definesSet = Sets.sorted(); + final Set definesSet = SortedSets.tree(); if (compilationLevel == CompilationLevel.BUNDLE) { definesSet.add("goog.ENABLE_DEBUG_LOADER=false"); } diff --git a/src/main/java/walkingkooka/j2cl/maven/hash/J2clTaskHash.java b/src/main/java/walkingkooka/j2cl/maven/hash/J2clTaskHash.java index ae15c111..206dfb48 100644 --- a/src/main/java/walkingkooka/j2cl/maven/hash/J2clTaskHash.java +++ b/src/main/java/walkingkooka/j2cl/maven/hash/J2clTaskHash.java @@ -18,7 +18,7 @@ package walkingkooka.j2cl.maven.hash; import com.google.common.collect.Lists; -import walkingkooka.collect.set.Sets; +import walkingkooka.collect.set.SortedSets; import walkingkooka.j2cl.maven.J2clArtifact; import walkingkooka.j2cl.maven.J2clMavenContext; import walkingkooka.j2cl.maven.J2clPath; @@ -69,7 +69,7 @@ public J2clTaskResult execute(final J2clArtifact artifact, final J2clTaskKind kind, final C context, final TreeLogger logger) throws Exception { - final Set hashItemNames = Sets.sorted(); + final Set hashItemNames = SortedSets.tree(); final HashBuilder hash = HashBuilder.empty(); context.computeHash( artifact, diff --git a/src/main/java/walkingkooka/j2cl/maven/output/J2clTaskOutputAssembler.java b/src/main/java/walkingkooka/j2cl/maven/output/J2clTaskOutputAssembler.java index b58cbad1..cf553a73 100644 --- a/src/main/java/walkingkooka/j2cl/maven/output/J2clTaskOutputAssembler.java +++ b/src/main/java/walkingkooka/j2cl/maven/output/J2clTaskOutputAssembler.java @@ -18,6 +18,7 @@ package walkingkooka.j2cl.maven.output; import walkingkooka.collect.set.Sets; +import walkingkooka.collect.set.SortedSets; import walkingkooka.j2cl.maven.J2clArtifact; import walkingkooka.j2cl.maven.J2clMavenContext; import walkingkooka.j2cl.maven.J2clPath; @@ -121,7 +122,7 @@ public J2clTaskResult executeWithDirectory(final J2clArtifact artifact, } logger.outdent(); - final Set destinationFiles = Sets.sorted(); + final Set destinationFiles = SortedSets.tree(); destinationFiles.addAll(closureCompileDestinationFiles); destinationFiles.addAll(unpackPublicDestinationFiles); diff --git a/src/main/java/walkingkooka/j2cl/maven/shade/J2clTaskShade.java b/src/main/java/walkingkooka/j2cl/maven/shade/J2clTaskShade.java index 00d885f0..463d6dc6 100644 --- a/src/main/java/walkingkooka/j2cl/maven/shade/J2clTaskShade.java +++ b/src/main/java/walkingkooka/j2cl/maven/shade/J2clTaskShade.java @@ -17,7 +17,7 @@ package walkingkooka.j2cl.maven.shade; -import walkingkooka.collect.set.Sets; +import walkingkooka.collect.set.SortedSets; import walkingkooka.j2cl.maven.J2clArtifact; import walkingkooka.j2cl.maven.J2clMavenContext; import walkingkooka.j2cl.maven.J2clPath; @@ -117,10 +117,10 @@ private void copyAndShade(final J2clArtifact artifact, final Set files = root.gatherFiles(J2clPath.ALL_FILES.and(filter)); - final Set possibleFiles = Sets.sorted(); + final Set possibleFiles = SortedSets.tree(); possibleFiles.addAll(files); - final Set nonShadedFiles = Sets.sorted(); + final Set nonShadedFiles = SortedSets.tree(); nonShadedFiles.addAll(files); for (final Entry mapping : shade.entrySet()) { @@ -131,7 +131,7 @@ private void copyAndShade(final J2clArtifact artifact, output : output.append(replace.replace('.', File.separatorChar)); - final Set shadedFiles = Sets.sorted(); + final Set shadedFiles = SortedSets.tree(); final J2clPath shadedRoot = root.append(find.replace('.', File.separatorChar)); // filter only files belonging to and under shade source root diff --git a/src/main/java/walkingkooka/j2cl/maven/strip/GwtIncompatibleStripPreprocessor.java b/src/main/java/walkingkooka/j2cl/maven/strip/GwtIncompatibleStripPreprocessor.java index f89a8afc..9fc0251d 100644 --- a/src/main/java/walkingkooka/j2cl/maven/strip/GwtIncompatibleStripPreprocessor.java +++ b/src/main/java/walkingkooka/j2cl/maven/strip/GwtIncompatibleStripPreprocessor.java @@ -22,6 +22,7 @@ import com.google.j2cl.tools.gwtincompatible.GwtIncompatibleStripper; import walkingkooka.collect.list.Lists; import walkingkooka.collect.set.Sets; +import walkingkooka.collect.set.SortedSets; import walkingkooka.j2cl.maven.J2clPath; import walkingkooka.j2cl.maven.J2clTaskResult; import walkingkooka.j2cl.maven.log.TreeFormat; @@ -215,7 +216,7 @@ private static Set gatherFiles(final J2clPath root, private static Set gatherFiles0(final J2clPath root, final Predicate include) throws IOException { - final SortedSet files = Sets.sorted(); + final SortedSet files = SortedSets.tree(); Files.walkFileTree( root.path(), diff --git a/src/test/java/walkingkooka/j2cl/maven/J2clArtifactGraphCalculatorTest.java b/src/test/java/walkingkooka/j2cl/maven/J2clArtifactGraphCalculatorTest.java index 8a1ea07a..1cda58bd 100644 --- a/src/test/java/walkingkooka/j2cl/maven/J2clArtifactGraphCalculatorTest.java +++ b/src/test/java/walkingkooka/j2cl/maven/J2clArtifactGraphCalculatorTest.java @@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test; import walkingkooka.collect.map.Maps; import walkingkooka.collect.set.Sets; +import walkingkooka.collect.set.SortedSets; import walkingkooka.reflect.ClassTesting2; import walkingkooka.reflect.JavaVisibility; @@ -170,7 +171,7 @@ private Map> transform(final Map transformCsv(final String csv) { return Arrays.stream(csv.isEmpty() ? new String[0] : csv.split(",")) .map(J2clArtifactCoords::parse) - .collect(Collectors.toCollection(Sets::sorted)); + .collect(Collectors.toCollection(SortedSets::tree)); } private void runAndCheck0(final Map> flat,