|
60 | 60 | import org.eclipse.aether.resolution.DependencyRequest;
|
61 | 61 | import org.eclipse.aether.resolution.DependencyResolutionException;
|
62 | 62 | import org.eclipse.aether.resolution.DependencyResult;
|
63 |
| -import org.graalvm.buildtools.utils.FileUtils; |
64 | 63 | import org.graalvm.buildtools.utils.JUnitUtils;
|
65 | 64 | import org.graalvm.buildtools.utils.NativeImageConfigurationUtils;
|
66 |
| -import org.w3c.dom.Document; |
67 |
| -import org.xml.sax.SAXException; |
68 | 65 |
|
69 |
| -import javax.xml.parsers.DocumentBuilder; |
70 |
| -import javax.xml.parsers.DocumentBuilderFactory; |
71 |
| -import javax.xml.parsers.ParserConfigurationException; |
72 |
| -import java.io.File; |
73 | 66 | import java.io.IOException;
|
74 | 67 | import java.io.UncheckedIOException;
|
75 | 68 | import java.nio.file.Files;
|
|
82 | 75 | import java.util.HashSet;
|
83 | 76 | import java.util.List;
|
84 | 77 | import java.util.Set;
|
85 |
| -import java.util.regex.Pattern; |
86 | 78 | import java.util.stream.Collectors;
|
87 | 79 | import java.util.stream.Stream;
|
88 | 80 |
|
@@ -142,7 +134,6 @@ protected void addDependenciesToClasspath() throws MojoExecutionException {
|
142 | 134 | .map(it -> it.getFile().toPath())
|
143 | 135 | .forEach(imageClasspath::add);
|
144 | 136 |
|
145 |
| - modules.addAll(collectJUnitModulesAlreadyOnClasspath()); |
146 | 137 | var jars = findJunitPlatformNativeJars(modules);
|
147 | 138 | imageClasspath.addAll(jars);
|
148 | 139 | }
|
@@ -318,51 +309,6 @@ private List<Path> findJunitPlatformNativeJars(Set<Module> modulesAlreadyOnClass
|
318 | 309 | .collect(Collectors.toList());
|
319 | 310 | }
|
320 | 311 |
|
321 |
| - private Set<Module> collectJUnitModulesAlreadyOnClasspath() { |
322 |
| - Set<Module> artifacts = new HashSet<>(); |
323 |
| - for (Path entry : imageClasspath) { |
324 |
| - if (isJUnitArtifact(entry)) { |
325 |
| - File pom = getArtifactPOM(entry); |
326 |
| - if (pom != null) { |
327 |
| - artifacts.add(getModuleFromPOM(pom)); |
328 |
| - } |
329 |
| - } |
330 |
| - } |
331 |
| - |
332 |
| - return artifacts; |
333 |
| - } |
334 |
| - |
335 |
| - private boolean isJUnitArtifact(Path entry) { |
336 |
| - return entry.toString().contains("junit"); |
337 |
| - } |
338 |
| - |
339 |
| - private File getArtifactPOM(Path classpathEntry) { |
340 |
| - List<File> artifactContent = getArtifactContent(classpathEntry.getParent()); |
341 |
| - List<File> candidates = artifactContent.stream().filter(f -> f.getName().endsWith(".pom")).collect(Collectors.toList()); |
342 |
| - return candidates.size() != 1 ? null : candidates.get(0); |
343 |
| - } |
344 |
| - |
345 |
| - private List<File> getArtifactContent(Path path) { |
346 |
| - File[] content = path.toFile().listFiles(); |
347 |
| - return content == null ? List.of() : List.of(content); |
348 |
| - } |
349 |
| - |
350 |
| - private Module getModuleFromPOM(File pom) { |
351 |
| - try { |
352 |
| - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
353 |
| - factory.setIgnoringElementContentWhitespace(true); |
354 |
| - DocumentBuilder builder = factory.newDocumentBuilder(); |
355 |
| - Document doc = builder.parse(pom); |
356 |
| - |
357 |
| - String groupId = doc.getElementsByTagName("groupId").item(0).getFirstChild().getTextContent(); |
358 |
| - String artifactId = doc.getElementsByTagName("artifactId").item(0).getFirstChild().getTextContent(); |
359 |
| - |
360 |
| - return new Module(groupId, artifactId); |
361 |
| - } catch (ParserConfigurationException | IOException | SAXException e) { |
362 |
| - throw new RuntimeException("Cannot get maven coordinates from " + pom.getPath() + ". Reason: " + e.getMessage()); |
363 |
| - } |
364 |
| - } |
365 |
| - |
366 | 312 | private static final class Module {
|
367 | 313 | private final String groupId;
|
368 | 314 | private final String artifactId;
|
|
0 commit comments