提交 9caa840f 编写于 作者: S serge-rider

Maven artifacts resolve fix (trim identifiers)

上级 38930ae8
......@@ -661,4 +661,7 @@ public class CommonUtils {
return String.valueOf(val);
}
public static String trim(String str) {
return str == null ? null : str.trim();
}
}
......@@ -70,9 +70,9 @@ public class MavenArtifact implements IMavenIdentifier
public MavenArtifact(@NotNull MavenRepository repository, @NotNull String groupId, @NotNull String artifactId, @Nullable String classifier)
{
this.repository = repository;
this.groupId = groupId;
this.artifactId = artifactId;
this.classifier = classifier;
this.groupId = CommonUtils.trim(groupId);
this.artifactId = CommonUtils.trim(artifactId);
this.classifier = CommonUtils.trim(classifier);
}
public void loadMetadata(DBRProgressMonitor monitor) throws IOException {
......@@ -141,7 +141,6 @@ public class MavenArtifact implements IMavenIdentifier
@Override
public void saxStartElement(SAXReader reader, String namespaceURI, String localName, Attributes atts) throws XMLException {
lastTag = localName;
}
@Override
......
......@@ -18,6 +18,7 @@ package org.jkiss.dbeaver.registry.maven;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.utils.CommonUtils;
/**
* Maven artifact reference
......@@ -42,10 +43,10 @@ public class MavenArtifactReference implements IMavenIdentifier
private final String classifier;
public MavenArtifactReference(@NotNull String groupId, @NotNull String artifactId, @Nullable String classifier, @NotNull String version) {
this.groupId = groupId;
this.artifactId = artifactId;
this.version = version;
this.classifier = classifier;
this.groupId = CommonUtils.trim(groupId);
this.artifactId = CommonUtils.trim(artifactId);
this.version = CommonUtils.trim(version);
this.classifier = CommonUtils.trim(classifier);
this.id = makeId(this);
}
......
......@@ -88,7 +88,7 @@ public class MavenArtifactVersion implements IMavenIdentifier {
MavenArtifactVersion(@NotNull DBRProgressMonitor monitor, @NotNull MavenArtifact artifact, @NotNull String version) throws IOException {
this.artifact = artifact;
this.version = version;
this.version = CommonUtils.trim(version);
loadPOM(monitor);
}
......@@ -250,11 +250,11 @@ public class MavenArtifactVersion implements IMavenIdentifier {
throw new IOException("Error parsing POM", e);
}
Element root = pomDocument.getDocumentElement();
name = XMLUtils.getChildElementBody(root, "name");
url = XMLUtils.getChildElementBody(root, "url");
version = XMLUtils.getChildElementBody(root, "version");
packaging = XMLUtils.getChildElementBody(root, "packaging");
description = XMLUtils.getChildElementBody(root, "description");
name = CommonUtils.trim(XMLUtils.getChildElementBody(root, "name"));
url = CommonUtils.trim(XMLUtils.getChildElementBody(root, "url"));
version = CommonUtils.trim(XMLUtils.getChildElementBody(root, "version"));
packaging = CommonUtils.trim(XMLUtils.getChildElementBody(root, "packaging"));
description = CommonUtils.trim(XMLUtils.getChildElementBody(root, "description"));
if (description != null) {
description = TextUtils.compactWhiteSpaces(description.trim());
}
......@@ -264,9 +264,9 @@ public class MavenArtifactVersion implements IMavenIdentifier {
// Parent
Element parentElement = XMLUtils.getChildElement(root, "parent");
if (parentElement != null) {
String parentGroupId = XMLUtils.getChildElementBody(parentElement, "groupId");
String parentArtifactId = XMLUtils.getChildElementBody(parentElement, "artifactId");
String parentVersion = XMLUtils.getChildElementBody(parentElement, "version");
String parentGroupId = CommonUtils.trim(XMLUtils.getChildElementBody(parentElement, "groupId"));
String parentArtifactId = CommonUtils.trim(XMLUtils.getChildElementBody(parentElement, "artifactId"));
String parentVersion = CommonUtils.trim(XMLUtils.getChildElementBody(parentElement, "version"));
if (parentGroupId == null || parentArtifactId == null || parentVersion == null) {
log.error("Broken parent reference: " + parentGroupId + ":" + parentArtifactId + ":" + parentVersion);
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册