refactor: simplify history and mileage runtime
This commit is contained in:
@@ -98,10 +98,23 @@ class MavenModuleProfileTest {
|
||||
.doesNotContain("Spring Boot 3.4.x");
|
||||
}
|
||||
|
||||
@Test
|
||||
void duckDbDriverDoesNotLeakFromCompatibilityStoreIntoProductionApps() throws Exception {
|
||||
Document eventFileStorePom = modulePom("modules/sinks/event-file-store/pom.xml");
|
||||
|
||||
assertThat(dependencyOptional(eventFileStorePom, "org.duckdb", "duckdb_jdbc"))
|
||||
.as("event-file-store is a compatibility path; DuckDB must not be transitive")
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
private static Document rootPom() throws Exception {
|
||||
return modulePom("pom.xml");
|
||||
}
|
||||
|
||||
private static Document modulePom(String path) throws Exception {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||
return factory.newDocumentBuilder().parse(Files.newInputStream(repositoryRoot().resolve("pom.xml")));
|
||||
return factory.newDocumentBuilder().parse(Files.newInputStream(repositoryRoot().resolve(path)));
|
||||
}
|
||||
|
||||
private static String projectProperty(Document pom, String name) {
|
||||
@@ -150,6 +163,29 @@ class MavenModuleProfileTest {
|
||||
return List.copyOf(out);
|
||||
}
|
||||
|
||||
private static boolean dependencyOptional(Document pom, String groupId, String artifactId) {
|
||||
Element dependencies = firstDirectChild(pom.getDocumentElement(), "dependencies");
|
||||
if (dependencies == null) {
|
||||
return false;
|
||||
}
|
||||
NodeList children = dependencies.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
if (!(children.item(i) instanceof Element dependency) || !"dependency".equals(dependency.getTagName())) {
|
||||
continue;
|
||||
}
|
||||
Element currentGroupId = firstDirectChild(dependency, "groupId");
|
||||
Element currentArtifactId = firstDirectChild(dependency, "artifactId");
|
||||
if (currentGroupId != null
|
||||
&& currentArtifactId != null
|
||||
&& groupId.equals(currentGroupId.getTextContent().trim())
|
||||
&& artifactId.equals(currentArtifactId.getTextContent().trim())) {
|
||||
Element optional = firstDirectChild(dependency, "optional");
|
||||
return optional != null && Boolean.parseBoolean(optional.getTextContent().trim());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Element firstDirectChild(Element parent, String tagName) {
|
||||
NodeList children = parent.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user