public File download(String url) throws IOException { Parser parser = Parser.parsePathWithSchemePrefix(url); return resolveFile( parser.getGroup(), parser.getArtifact(), parser.getClassifier(), parser.getType(), parser.getVersion(), parser.getRepositoryURL() ); }
protected void addMavenCoordinates(Element owner, Parser parser, int indent) { String group = groupId(parser); createAndAppendChild(owner, "groupId", indent, group); createAndAppendChild(owner, "artifactId", indent, parser.getArtifact()); createAndAppendChild(owner, "version", indent, parser.getVersion()); String type = parser.getType(); if (type != null && !Objects.equal("jar", type)) { createAndAppendChild(owner, "type", indent, type); } String classifier = parser.getClassifier(); if (Strings.isNotBlank(classifier)) { createAndAppendChild(owner, "classifier", indent, classifier); } }
protected void addOrUpdateDependency(Element dependencies, Parser parser) throws XPathExpressionException { String group = groupId(parser); String artifact = parser.getArtifact(); String xpath = "dependency[groupId = '" + group + "' and artifactId = '" + artifact + "'"; String type = parser.getType(); if (Strings.isNotBlank(type) && !Objects.equal("jar", type)) { xpath += " and type='" + type + "'"; } String classifier = parser.getClassifier(); if (Strings.isNotBlank(classifier)) { xpath += " and classifier='" + classifier + "'"; } xpath += "]"; String scope = "provided"; Element dependency = xpath(xpath).element(dependencies); if (dependency != null) { // lets preserve the scope or not add it if there is no scope // on the previously found dependency scope = xpath("scope").elementTextContent(dependency); detachElement(dependency); } dependency = createAndAppendChild(dependencies, "dependency", 2); addMavenCoordinates(dependency, parser, 3); if (Strings.isNotBlank(scope)) { createAndAppendChild(dependency, "scope", 3, scope); } }