diff --git a/src/main/java/io/openliberty/tools/common/plugins/util/PrepareFeatureUtil.java b/src/main/java/io/openliberty/tools/common/plugins/util/PrepareFeatureUtil.java index 3cb414dd..b024dc3e 100644 --- a/src/main/java/io/openliberty/tools/common/plugins/util/PrepareFeatureUtil.java +++ b/src/main/java/io/openliberty/tools/common/plugins/util/PrepareFeatureUtil.java @@ -83,7 +83,7 @@ public void prepareFeatures(List featureBOMs) throws PluginExecutionExce File additionalBOM = downloadArtifact(groupId, artifactId, "pom", version); esaMap.putAll(populateESAMap(additionalBOM)); if(esaMap.isEmpty()) { - warn("\"The features.json could not be generated because the required feature ESA files were not provided for features-bom at coordinates " + groupId + ":" +artifactId + ":" +version); + warn("The features.json could not be generated due to errors encountered while resolving the feature ESA file specified in feautres-bom file at coordinates " + groupId + ":" +artifactId + ":" +version); }else { prepareFeature(groupId, artifactId, version, additionalBOM, esaMap); } @@ -138,8 +138,7 @@ private void prepareFeature(String groupId, String artifactId, String version, F */ private Map downloadArtifactsFromBOM(File additionalBOM) throws PluginExecutionException { Map result = new HashMap(); - String[] MavenCoord = {"groupId", "artifactId", "type", "version"}; - + ArrayList missing_tags = new ArrayList<>(); try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); @@ -150,26 +149,35 @@ private Map downloadArtifactsFromBOM(File additionalBOM) throws Pl Node node = dependencyList.item(itr); if (node.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) node; - // error checking - for (String tag : MavenCoord) { - Node tmp_node = eElement.getElementsByTagName(tag).item(0); - if (tmp_node == null) { - throw new PluginExecutionException( - "Error: <" + tag + "> tag nof found in BOM file."); - } + + if(eElement.getElementsByTagName("groupId").item(0) == null ) { + missing_tags.add("groupId"); + } + if(eElement.getElementsByTagName("artifactId").item(0) == null ) { + missing_tags.add("artifactId "); + } + if(eElement.getElementsByTagName("type").item(0) == null ) { + missing_tags.add("type"); + } + if(eElement.getElementsByTagName("version").item(0) == null ) { + missing_tags.add("version"); } - String groupId = eElement.getElementsByTagName(MavenCoord[0]).item(0).getTextContent(); - String artifactId = eElement.getElementsByTagName(MavenCoord[1]).item(0).getTextContent(); - String type = eElement.getElementsByTagName(MavenCoord[2]).item(0).getTextContent(); - String version = eElement.getElementsByTagName(MavenCoord[3]).item(0).getTextContent(); + + if(!missing_tags.isEmpty()) { + throw new PluginExecutionException("Error: "+ missing_tags.toString() + " tag(s) not found in features-bom file " + additionalBOM); + } + + String groupId = eElement.getElementsByTagName("groupId").item(0).getTextContent(); + String artifactId = eElement.getElementsByTagName("artifactId").item(0).getTextContent(); + String type = eElement.getElementsByTagName("type").item(0).getTextContent(); + String version = eElement.getElementsByTagName("version").item(0).getTextContent(); File artifactFile = downloadArtifact(groupId, artifactId, type, version); result.put(artifactFile, groupId); } } } catch (ParserConfigurationException | SAXException | IOException e) { - debug(e); - throw new PluginExecutionException("Cannot read the BOM file " + additionalBOM.getAbsolutePath() + ". " + e.getMessage()); + throw new PluginExecutionException("Cannot read the features-bom file " + additionalBOM.getAbsolutePath() + ". " + e.getMessage()); } return result;