diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2022-01-18 15:24:00 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2022-01-18 15:24:28 +0100 |
commit | 7c1a1dac865dfe2289799192827d36f5c247e4ef (patch) | |
tree | efd374d6bdb665d1e33958edbb16a09ac1cc4fc2 /config-model/src/main | |
parent | f0d603e0f23566f63b7b8df3b47c0650ce3d2b99 (diff) |
Split logic to separate method
Diffstat (limited to 'config-model/src/main')
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/application/validation/BundleValidator.java | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/BundleValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/BundleValidator.java index 87a84911d3e..1ca8e82aea6 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/BundleValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/BundleValidator.java @@ -18,6 +18,7 @@ import org.xml.sax.InputSource; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import java.io.IOException; import java.io.StringReader; @@ -154,22 +155,7 @@ public class BundleValidator extends Validator { try { Document pom = DocumentBuilderFactory.newDefaultInstance().newDocumentBuilder() .parse(new InputSource(new StringReader(pomXmlContent))); - NodeList dependencies = (NodeList) XPathFactory.newDefaultInstance().newXPath() - .compile("/project/dependencies/dependency") - .evaluate(pom, XPathConstants.NODESET); - for (int i = 0; i < dependencies.getLength(); i++) { - Element dependency = (Element) dependencies.item(i); - String groupId = dependency.getElementsByTagName("groupId").item(0).getTextContent(); - String artifactId = dependency.getElementsByTagName("artifactId").item(0).getTextContent(); - for (DeprecatedMavenArtifact deprecatedArtifact : DeprecatedMavenArtifact.values()) { - if (groupId.equals(deprecatedArtifact.groupId) && artifactId.equals(deprecatedArtifact.artifactId)) { - deployLogger.logApplicationPackage(Level.WARNING, - String.format( - "The pom.xml of bundle '%s' includes a dependency to the artifact '%s:%s'. \n%s", - jarFilename, groupId, artifactId, deprecatedArtifact.description)); - } - } - } + validateDependencies(deployLogger, jarFilename, pom); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } catch (Exception e) { @@ -177,6 +163,25 @@ public class BundleValidator extends Validator { } } + private static void validateDependencies(DeployLogger deployLogger, String jarFilename, Document pom) throws XPathExpressionException { + NodeList dependencies = (NodeList) XPathFactory.newDefaultInstance().newXPath() + .compile("/project/dependencies/dependency") + .evaluate(pom, XPathConstants.NODESET); + for (int i = 0; i < dependencies.getLength(); i++) { + Element dependency = (Element) dependencies.item(i); + String groupId = dependency.getElementsByTagName("groupId").item(0).getTextContent(); + String artifactId = dependency.getElementsByTagName("artifactId").item(0).getTextContent(); + for (DeprecatedMavenArtifact deprecatedArtifact : DeprecatedMavenArtifact.values()) { + if (groupId.equals(deprecatedArtifact.groupId) && artifactId.equals(deprecatedArtifact.artifactId)) { + deployLogger.logApplicationPackage(Level.WARNING, + String.format( + "The pom.xml of bundle '%s' includes a dependency to the artifact '%s:%s'. \n%s", + jarFilename, groupId, artifactId, deprecatedArtifact.description)); + } + } + } + } + private enum DeprecatedMavenArtifact { VESPA_HTTP_CLIENT_EXTENSION("com.yahoo.vespa", "vespa-http-client-extensions", "This artifact will be removed in Vespa 8. " + |