提交 37f20e35 编写于 作者: J jurgen

POM imports

上级 11a12906
......@@ -53,7 +53,6 @@ public class DriverDependencies implements DBPDriverDependencies
libraryList.addAll(libMap.values());
/*
{
StringBuilder sb = new StringBuilder();
Set<String> ns = new TreeSet<>();
for (String lib : libMap.keySet()) {
......@@ -67,20 +66,17 @@ public class DriverDependencies implements DBPDriverDependencies
sb.append(lib).append("\n");
}
System.out.println(sb.toString());
*/
System.out.println("---------------------------");
for (DependencyNode node : rootNodes) {
dumpNode(node, 0);
}
}
*/
}
} catch (IOException e) {
throw new DBException("IO error while resolving dependencies", e);
}
}
/*
private void dumpNode(DependencyNode node, int level) {
if (node.duplicate) {
return;
......@@ -91,7 +87,6 @@ public class DriverDependencies implements DBPDriverDependencies
dumpNode(child, level + 1);
}
}
*/
private void resolveDependencies(DBRProgressMonitor monitor, DependencyNode ownerNode, Map<String, DBPDriverLibrary> libMap) throws IOException {
Collection<? extends DBPDriverLibrary> dependencies = ownerNode.library.getDependencies(monitor);
......
......@@ -53,6 +53,7 @@ public class MavenArtifactVersion {
private String description;
private String url;
private MavenArtifactVersion parent;
private List<MavenArtifactVersion> imports;
private final List<MavenArtifactLicense> licenses = new ArrayList<>();
private final List<MavenProfile> profiles = new ArrayList<>();
......@@ -259,16 +260,33 @@ public class MavenArtifactVersion {
// Activation
Element activationElement = XMLUtils.getChildElement(element, "activation");
if (activationElement != null) {
String activeByDefault = XMLUtils.getChildElementBody(element, "activeByDefault");
String activeByDefault = XMLUtils.getChildElementBody(activationElement, "activeByDefault");
if (!CommonUtils.isEmpty(activeByDefault)) {
profile.active = CommonUtils.getBoolean(activeByDefault);
}
String jdk = XMLUtils.getChildElementBody(element, "jdk");
String jdk = XMLUtils.getChildElementBody(activationElement, "jdk");
if (!CommonUtils.isEmpty(jdk)) {
profile.active = MavenArtifact.versionMatches(System.getProperty("java.version"), jdk);
}
Element osElement = XMLUtils.getChildElement(activationElement, "os");
if (osElement != null) {
}
Element propElement = XMLUtils.getChildElement(activationElement, "property");
if (propElement != null) {
String propName = XMLUtils.getChildElementBody(propElement, "name");
String propValue = XMLUtils.getChildElementBody(propElement, "value");
// TODO: implement real properties checks. Now enable all profiles with !prop
if (propName != null && propName.startsWith("!")) {
profile.active = true;
}
}
}
}
if (!profile.active) {
// Do not parse dependencies of non-active profiles (most likely they will fail).
return;
}
{
// Properties
Element propsElement = XMLUtils.getChildElement(element, "properties");
......@@ -323,9 +341,29 @@ public class MavenArtifactVersion {
}
boolean optional = CommonUtils.getBoolean(XMLUtils.getChildElementBody(dep, "optional"), false);
// TODO: maybe we should include some of them
if (depManagement || (!optional && includesScope(scope))) {
String version = evaluateString(XMLUtils.getChildElementBody(dep, "version"));
String version = evaluateString(XMLUtils.getChildElementBody(dep, "version"));
if (depManagement && scope == MavenArtifactDependency.Scope.IMPORT) {
// Import another pom
if (version == null) {
log.error("Missing imported artifact [" + groupId + ":" + artifactId + "] version. Skip.");
continue;
}
MavenArtifactReference importReference = new MavenArtifactReference(
groupId,
artifactId,
version);
MavenArtifactVersion importedVersion = MavenRegistry.getInstance().findArtifact(monitor, importReference);
if (importedVersion == null) {
log.error("Imported artifact [" + importReference + "] not found. Skip.");
}
if (imports == null) {
imports = new ArrayList<>();
}
imports.add(importedVersion);
} else if (depManagement || (!optional && includesScope(scope))) {
// TODO: maybe we should include optional or PROVIDED
if (version == null) {
version = findDependencyVersion(monitor, groupId, artifactId);
}
......@@ -380,6 +418,15 @@ public class MavenArtifactVersion {
}
}
}
// Check in imported BOMs
if (imports != null) {
for (MavenArtifactVersion i : imports) {
String dependencyVersion = i.findDependencyVersion(monitor, groupId, artifactId);
if (dependencyVersion != null) {
return dependencyVersion;
}
}
}
return parent == null ? null : parent.findDependencyVersion(monitor, groupId, artifactId);
}
......
......@@ -127,7 +127,7 @@ public class MavenRepository
}
return version;
} catch (IOException e) {
log.debug("Artifact version " + ref + " not found", e);
log.debug("Artifact version " + ref + " not found: " + e.getMessage());
return null;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册