Skip to content

Commit

Permalink
build: make sure we build for JDK 8 (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
quintesse committed Jul 12, 2024
1 parent 8956385 commit fda59f1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<mainClass>org.codejive.jpm.Main</mainClass>
<version.mima>2.4.15</version.mima>
<version.picocli>4.7.6</version.picocli>
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/codejive/jpm/util/ResolverUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public static List<Path> resolveArtifactPaths(String[] artifactNames)
throws DependencyResolutionException {
List<Artifact> artifacts = parseArtifacts(artifactNames);
List<ArtifactResult> 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());
}

/**
Expand All @@ -57,7 +59,9 @@ public static List<Artifact> parseArtifacts(String[] artifactNames) {
public static List<ArtifactResult> resolveArtifacts(List<Artifact> artifacts)
throws DependencyResolutionException {
List<Dependency> 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)) {
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/org/codejive/jpm/util/SearchUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
}
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit fda59f1

Please sign in to comment.