private void parseCoordElements(final File pom) { Reader reader = null; XMLStreamReader xml = null; try { reader = new FileReader(pom); xml = XMLInputFactory.newFactory().createXMLStreamReader(reader); final Stack<String> path = new Stack<String>(); while (xml.hasNext()) { final int evt = xml.next(); switch (evt) { case START_ELEMENT: { path.push(xml.getLocalName()); if (captureValue(path, xml)) { // seems like xml.getElementText() traverses the END_ELEMENT event... path.pop(); } if (foundPreferredValues()) { return; } break; } case END_ELEMENT: { path.pop(); break; } default: { } } } } catch (final IOException e) { logger.warn( "Failed to peek at POM coordinate for: %s. Reason: %s\n" + "This POM will NOT be available as an ancestor to other models during effective-model building.", e, pom, e.getMessage()); } catch (final XMLStreamException e) { logger.warn( "Failed to peek at POM coordinate for: %s. Reason: %s\n" + "This POM will NOT be available as an ancestor to other models during effective-model building.", e, pom, e.getMessage()); } catch (final FactoryConfigurationError e) { logger.warn( "Failed to peek at POM coordinate for: %s. Reason: %s\n" + "This POM will NOT be available as an ancestor to other models during effective-model building.", e, pom, e.getMessage()); } finally { if (xml != null) { try { xml.close(); } catch (final XMLStreamException e) { } } closeQuietly(reader); } }
public PomPeek(final File pom) { parseCoordElements(pom); if (!createCoordinate()) { logger.warn( "Could not peek at POM coordinate for: %s. " + "This POM will NOT be available as an ancestor to other models during effective-model building.", pom); } }