Skip to content

Commit d455439

Browse files
committed
Remove unused code
1 parent b841baa commit d455439

File tree

1 file changed

+0
-54
lines changed

1 file changed

+0
-54
lines changed

native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/NativeTestMojo.java

-54
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,9 @@
6060
import org.eclipse.aether.resolution.DependencyRequest;
6161
import org.eclipse.aether.resolution.DependencyResolutionException;
6262
import org.eclipse.aether.resolution.DependencyResult;
63-
import org.graalvm.buildtools.utils.FileUtils;
6463
import org.graalvm.buildtools.utils.JUnitUtils;
6564
import org.graalvm.buildtools.utils.NativeImageConfigurationUtils;
66-
import org.w3c.dom.Document;
67-
import org.xml.sax.SAXException;
6865

69-
import javax.xml.parsers.DocumentBuilder;
70-
import javax.xml.parsers.DocumentBuilderFactory;
71-
import javax.xml.parsers.ParserConfigurationException;
72-
import java.io.File;
7366
import java.io.IOException;
7467
import java.io.UncheckedIOException;
7568
import java.nio.file.Files;
@@ -82,7 +75,6 @@
8275
import java.util.HashSet;
8376
import java.util.List;
8477
import java.util.Set;
85-
import java.util.regex.Pattern;
8678
import java.util.stream.Collectors;
8779
import java.util.stream.Stream;
8880

@@ -142,7 +134,6 @@ protected void addDependenciesToClasspath() throws MojoExecutionException {
142134
.map(it -> it.getFile().toPath())
143135
.forEach(imageClasspath::add);
144136

145-
modules.addAll(collectJUnitModulesAlreadyOnClasspath());
146137
var jars = findJunitPlatformNativeJars(modules);
147138
imageClasspath.addAll(jars);
148139
}
@@ -318,51 +309,6 @@ private List<Path> findJunitPlatformNativeJars(Set<Module> modulesAlreadyOnClass
318309
.collect(Collectors.toList());
319310
}
320311

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-
366312
private static final class Module {
367313
private final String groupId;
368314
private final String artifactId;

0 commit comments

Comments
 (0)