/** * Lets add/update the maven dependency plugin configuration to copy deployments * to the deployDir or the webAppDir */ protected void updateDependencyPlugin(Element plugins, Element dependencies, Collection<Parser> artifacts) throws XPathExpressionException { Element plugin = getOrCreatePlugin(plugins, "maven-dependency-plugin", "2.8"); Element executions = getOrCreateChild(plugin, "executions", 6); List<Parser> warArtifacts = new ArrayList<Parser>(); List<Parser> jarArtifacts = new ArrayList<Parser>(); for (Parser artifact : artifacts) { String type = artifact.getType(); if (Objects.equal("war", type)) { warArtifacts.add(artifact); } else { jarArtifacts.add(artifact); } } if (Strings.isNotBlank(webAppDir) && !warArtifacts.isEmpty()) { recreateDependencyExecution(executions, dependencies, "fuse-fabric-deploy-webapps", webAppDir, warArtifacts, true); } if (Strings.isNotBlank(deployDir) && !jarArtifacts.isEmpty()) { recreateDependencyExecution(executions, dependencies, "fuse-fabric-deploy-shared", deployDir, jarArtifacts, false); } }
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); } }