Split logic to separate method
@@ -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,6 +155,15 @@ public class BundleValidator extends Validator {
try {
Document pom = DocumentBuilderFactory.newDefaultInstance().newDocumentBuilder()
.parse(new InputSource(new StringReader(pomXmlContent)));
+ validateDependencies(deployLogger, jarFilename, pom);
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ } catch (Exception e) {
+ deployLogger.log(Level.INFO, String.format("Unable to parse pom.xml from %s", jarFilename));
+ }
+ }
+
+ 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);
@@ -170,11 +180,6 @@ public class BundleValidator extends Validator {
}
}
}
- } catch (ParserConfigurationException e) {
- throw new RuntimeException(e);
- } catch (Exception e) {
- deployLogger.log(Level.INFO, String.format("Unable to parse pom.xml from %s", jarFilename));
- }
}
private enum DeprecatedMavenArtifact {
