From fda59f1e20c0b1f0dbdfd855f80625af092ee27e Mon Sep 17 00:00:00 2001 From: Tako Schotanus Date: Fri, 12 Jul 2024 02:01:21 +0200 Subject: [PATCH] build: make sure we build for JDK 8 (for now) --- pom.xml | 4 ++-- .../java/org/codejive/jpm/util/ResolverUtils.java | 8 ++++++-- src/main/java/org/codejive/jpm/util/SearchUtils.java | 12 +++++++----- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 19cf024..a1c9331 100644 --- a/pom.xml +++ b/pom.xml @@ -29,8 +29,8 @@ UTF-8 - 17 - 17 + 8 + 8 org.codejive.jpm.Main 2.4.15 4.7.6 diff --git a/src/main/java/org/codejive/jpm/util/ResolverUtils.java b/src/main/java/org/codejive/jpm/util/ResolverUtils.java index b8946fc..ba5afbc 100644 --- a/src/main/java/org/codejive/jpm/util/ResolverUtils.java +++ b/src/main/java/org/codejive/jpm/util/ResolverUtils.java @@ -33,7 +33,9 @@ public static List resolveArtifactPaths(String[] artifactNames) throws DependencyResolutionException { List artifacts = parseArtifacts(artifactNames); List resolvedArtifacts = resolveArtifacts(artifacts); - return resolvedArtifacts.stream().map(ar -> ar.getArtifact().getFile().toPath()).toList(); + return resolvedArtifacts.stream() + .map(ar -> ar.getArtifact().getFile().toPath()) + .collect(Collectors.toList()); } /** @@ -57,7 +59,9 @@ public static List parseArtifacts(String[] artifactNames) { public static List resolveArtifacts(List artifacts) throws DependencyResolutionException { List dependencies = - artifacts.stream().map(a -> new Dependency(a, JavaScopes.RUNTIME)).toList(); + artifacts.stream() + .map(a -> new Dependency(a, JavaScopes.RUNTIME)) + .collect(Collectors.toList()); ContextOverrides overrides = ContextOverrides.create().build(); Runtime runtime = Runtimes.INSTANCE.getRuntime(); try (Context context = runtime.create(overrides)) { diff --git a/src/main/java/org/codejive/jpm/util/SearchUtils.java b/src/main/java/org/codejive/jpm/util/SearchUtils.java index f540646..bd44d59 100644 --- a/src/main/java/org/codejive/jpm/util/SearchUtils.java +++ b/src/main/java/org/codejive/jpm/util/SearchUtils.java @@ -7,6 +7,7 @@ import java.io.InputStreamReader; import java.net.URLEncoder; import java.util.List; +import java.util.stream.Collectors; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; @@ -55,18 +56,19 @@ private static SearchResult select(String query, int start, int count) throws IO String finalQuery; if (parts.length >= 3) { // Exact group/artifact match for retrieving versions - finalQuery = "g:%s AND a:%s".formatted(parts[0], parts[1]); + finalQuery = String.format("g:%s AND a:%s", parts[0], parts[1]); } else if (parts.length == 2) { // Partial group/artifact match, we will filter the results // to remove those that match an inverted artifact/group - finalQuery = "%s AND %s".formatted(parts[0], parts[1]); + finalQuery = String.format("%s AND %s", parts[0], parts[1]); } else { // Simple partial match finalQuery = query; } String searchUrl = - "https://search.maven.org/solrsearch/select?start=%d&rows=%d&q=%s" - .formatted(start, count, URLEncoder.encode(finalQuery, "UTF-8")); + String.format( + "https://search.maven.org/solrsearch/select?start=%d&rows=%d&q=%s", + start, count, URLEncoder.encode(finalQuery, "UTF-8")); if (parts.length >= 3) { searchUrl += "&core=gav"; } @@ -100,7 +102,7 @@ private static SearchResult select(String query, int start, int count) throws IO d.a, "", d.v != null ? d.v : d.latestVersion)) - .toList(); + .collect(Collectors.toList()); return new SearchResult(artifacts, query, start, count, result.response.numFound); } }