|
15 | 15 | */
|
16 | 16 | package org.springframework.sbm.java;
|
17 | 17 |
|
18 |
| -import org.assertj.core.api.Assertions; |
| 18 | +import org.jboss.shrinkwrap.resolver.api.maven.Maven; |
19 | 19 | import org.openrewrite.*;
|
20 | 20 | import org.openrewrite.internal.InMemoryLargeSourceSet;
|
| 21 | +import org.springframework.sbm.java.util.JavaSourceUtil; |
| 22 | +import org.springframework.sbm.testhelper.common.utils.TestDiff; |
| 23 | +import org.assertj.core.api.Assertions; |
21 | 24 | import org.openrewrite.java.JavaIsoVisitor;
|
22 | 25 | import org.openrewrite.java.JavaParser;
|
23 | 26 | import org.openrewrite.java.JavaVisitor;
|
24 | 27 | import org.openrewrite.java.tree.J;
|
25 |
| -import org.openrewrite.maven.cache.LocalMavenArtifactCache; |
26 |
| -import org.openrewrite.maven.tree.ResolvedDependency; |
27 |
| -import org.openrewrite.maven.tree.ResolvedGroupArtifactVersion; |
28 |
| -import org.openrewrite.maven.utilities.MavenArtifactDownloader; |
29 |
| -import org.springframework.sbm.java.util.JavaSourceUtil; |
30 |
| -import org.springframework.sbm.testhelper.common.utils.TestDiff; |
31 | 28 |
|
32 | 29 | import java.io.File;
|
33 | 30 | import java.nio.file.Path;
|
|
39 | 36 | import java.util.stream.Collectors;
|
40 | 37 | import java.util.stream.Stream;
|
41 | 38 |
|
42 |
| -import static org.junit.jupiter.api.AssertionsKt.fail; |
| 39 | +import static org.junit.jupiter.api.Assertions.fail; |
43 | 40 |
|
44 | 41 |
|
45 | 42 | public class OpenRewriteTestSupport {
|
@@ -238,27 +235,16 @@ public static JavaParser.Builder getJavaParser(String... classpath) {
|
238 | 235 | }
|
239 | 236 |
|
240 | 237 | /**
|
241 |
| - * Retrieve the <code>Path</code>s of jars for given gav |
| 238 | + * Retrieve the <code>Path</code>s of jars for given classpath |
242 | 239 | *
|
243 |
| - * @param gav in 'groupId:artifactId:version' format |
| 240 | + * @param classpath in 'groupId:artifactId:version' format |
244 | 241 | */
|
245 |
| - public static List<Path> getClasspathFiles(String... gav) { |
246 |
| - if (gav.length == 0) return List.of(); |
247 |
| - Path localM2 = Path.of(System.getProperty("user.home")).resolve(".m2/repository").normalize().toAbsolutePath(); |
248 |
| - MavenArtifactDownloader mavenArtifactDownloader = new MavenArtifactDownloader(new LocalMavenArtifactCache(localM2), null, t -> { |
249 |
| - throw new RuntimeException(t); |
250 |
| - }); |
251 |
| - return Arrays.stream(gav) |
252 |
| - .map(g -> g.split(":")) |
253 |
| - .map(g -> new ResolvedGroupArtifactVersion(null, g[0], g[1], g.length == 3 ? g[2] : null, null)) |
254 |
| - .map(g -> ResolvedDependency.builder() |
255 |
| - .gav(g) |
256 |
| - .build() |
257 |
| - ) |
258 |
| - .map(g -> { |
259 |
| - return mavenArtifactDownloader.downloadArtifact(g); |
260 |
| - }) |
261 |
| - .toList(); |
| 242 | + public static List<Path> getClasspathFiles(String... classpath) { |
| 243 | + if (classpath.length == 0) return List.of(); |
| 244 | + File[] as = org.jboss.shrinkwrap.resolver.api.maven.Maven.resolver().resolve(classpath).withTransitivity().as(File.class); |
| 245 | + return Arrays.stream(as) |
| 246 | + .map(File::toPath) |
| 247 | + .collect(Collectors.toList()); |
262 | 248 | }
|
263 | 249 |
|
264 | 250 | private static <P> RecipeRun refactor(J.CompilationUnit given, JavaVisitor<ExecutionContext> visitor) {
|
|
0 commit comments