in doc-architect/doc-architect-core/src/main/java/com/docarchitect/core/scanner/impl/java/MavenDependencyScanner.java [243:298]
private void extractDependencies(Map<String, Object> pom, String section,
Map<String, String> properties, List<Dependency> dependencies) {
Object sectionObj = pom.get(section);
if (sectionObj == null) {
return;
}
// Handle dependencyManagement wrapper
if (KEY_DEPENDENCY_MANAGEMENT.equals(section) && sectionObj instanceof Map) {
Map<String, Object> depMgmt = (Map<String, Object>) sectionObj;
sectionObj = depMgmt.get(KEY_DEPENDENCIES);
if (sectionObj == null) {
return;
}
}
List<Map<String, Object>> depsList;
if (sectionObj instanceof Map) {
Map<String, Object> depsMap = (Map<String, Object>) sectionObj;
Object dependency = depsMap.get(KEY_DEPENDENCY);
if (dependency instanceof List) {
depsList = (List<Map<String, Object>>) dependency;
} else if (dependency instanceof Map) {
depsList = List.of((Map<String, Object>) dependency);
} else {
return;
}
} else if (sectionObj instanceof List) {
depsList = (List<Map<String, Object>>) sectionObj;
} else {
return;
}
for (Map<String, Object> dep : depsList) {
String groupId = resolveProperties(extractText(dep, KEY_GROUP_ID), properties);
String artifactId = extractText(dep, KEY_ARTIFACT_ID);
String versionRaw = extractText(dep, KEY_VERSION);
String version = versionRaw != null ? resolveProperties(versionRaw, properties) : null;
String scope = extractText(dep, KEY_SCOPE, DEFAULT_SCOPE);
if (groupId != null && artifactId != null) {
// Use current component as source (extracted from properties map)
String sourceComponentId = properties.getOrDefault(PROPERTY_PROJECT_ARTIFACT_ID, DEFAULT_SOURCE_COMPONENT);
Dependency dependency = new Dependency(
sourceComponentId,
groupId,
artifactId,
version,
scope,
true // All POM dependencies are direct dependencies
);
dependencies.add(dependency);
}
}
}