refactor: keep taos driver behind history store

This commit is contained in:
lingniu
2026-07-01 06:55:49 +08:00
parent e03d1d7629
commit 40dea58278
2 changed files with 71 additions and 4 deletions

View File

@@ -32,10 +32,6 @@
<groupId>org.apache.kafka</groupId> <groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId> <artifactId>kafka-clients</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>

View File

@@ -0,0 +1,71 @@
package com.lingniu.ingest.eventhistory.config;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import javax.xml.parsers.DocumentBuilderFactory;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
class EventHistoryPomBoundaryTest {
@Test
void tdengineJdbcDriverIsOwnedByTdengineHistoryStoreModule() throws Exception {
assertThat(directDependencies(modulePom()))
.doesNotContain("com.taosdata.jdbc:taos-jdbcdriver");
}
private static Document modulePom() 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("modules/services/event-history-service/pom.xml")));
}
private static List<String> directDependencies(Document pom) {
Element dependencies = firstDirectChild(pom.getDocumentElement(), "dependencies");
if (dependencies == null) {
return List.of();
}
List<String> coordinates = new ArrayList<>();
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 groupId = firstDirectChild(dependency, "groupId");
Element artifactId = firstDirectChild(dependency, "artifactId");
if (groupId != null && artifactId != null) {
coordinates.add(groupId.getTextContent().trim() + ":" + artifactId.getTextContent().trim());
}
}
return List.copyOf(coordinates);
}
private static Element firstDirectChild(Element parent, String tagName) {
NodeList children = parent.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
if (children.item(i) instanceof Element child && tagName.equals(child.getTagName())) {
return child;
}
}
return null;
}
private static Path repositoryRoot() {
Path current = Path.of(System.getProperty("user.dir")).toAbsolutePath();
while (current != null) {
if (Files.exists(current.resolve("pom.xml")) && Files.exists(current.resolve("modules"))) {
return current;
}
current = current.getParent();
}
throw new IllegalStateException("repository root not found");
}
}