diff --git a/src/main/java/org/codejive/jpm/util/SearchUtils.java b/src/main/java/org/codejive/jpm/util/SearchUtils.java index bd44d59..9e07a93 100644 --- a/src/main/java/org/codejive/jpm/util/SearchUtils.java +++ b/src/main/java/org/codejive/jpm/util/SearchUtils.java @@ -67,7 +67,7 @@ private static SearchResult select(String query, int start, int count) throws IO } String searchUrl = String.format( - "https://search.maven.org/solrsearch/select?start=%d&rows=%d&q=%s", + "https://search.maven.org/solrsearch/select?start=%d&rows=%d&q=p:jar+AND+%s", start, count, URLEncoder.encode(finalQuery, "UTF-8")); if (parts.length >= 3) { searchUrl += "&core=gav"; @@ -90,23 +90,23 @@ private static SearchResult select(String query, int start, int count) throws IO } List artifacts = result.response.docs.stream() - .filter( - d -> - parts.length != 2 - || d.g.contains(parts[0]) - && d.a.contains(parts[1])) - .map( - d -> - new DefaultArtifact( - d.g, - d.a, - "", - d.v != null ? d.v : d.latestVersion)) + .filter(d -> acceptDoc(d, parts)) + .map(SearchUtils::toArtifact) .collect(Collectors.toList()); return new SearchResult(artifacts, query, start, count, result.response.numFound); } } } + + private static boolean acceptDoc(MsrDoc d, String[] parts) { + return d.ec != null + && d.ec.contains(".jar") + && (parts.length != 2 || d.g.contains(parts[0]) && d.a.contains(parts[1])); + } + + private static DefaultArtifact toArtifact(MsrDoc d) { + return new DefaultArtifact(d.g, d.a, "", d.v != null ? d.v : d.latestVersion); + } } class MvnSearchResult { @@ -129,4 +129,6 @@ class MsrDoc { public String a; public String v; public String latestVersion; + public String p; + public List ec; }