private String[] listSelectedFiles() { Selection selection = new Selection(basedir, includes, buildExcludes(), useDefaultExcludes); debug("From: %s", basedir); debug("Including: %s", deepToString(selection.getIncluded())); debug("Excluding: %s", deepToString(selection.getExcluded())); return selection.getSelectedFiles(); }
private Map<String, HeaderDefinition> buildHeaderDefinitions() throws MojoFailureException { // like mappings, first get default definitions final Map<String, HeaderDefinition> headers = new HashMap<String, HeaderDefinition>(HeaderType.defaultDefinitions()); // and then override them with those provided in properties file for (String resource : headerDefinitions) { try { InputSource source = new InputSource(finder.findResource(resource).openStream()); source.setEncoding(encoding); final AdditionalHeaderDefinition fileDefinitions = new AdditionalHeaderDefinition(XMLDoc.from(source, true)); final Map<String, HeaderDefinition> map = fileDefinitions.getDefinitions(); debug("%d header definitions loaded from '%s'", map.size(), resource); headers.putAll(map); } catch (IOException ex) { throw new MojoFailureException("Error reading header definition: " + resource, ex); } } // force inclusion of unknow item to manage unknown files headers.put(HeaderType.UNKNOWN.getDefinition().getType(), HeaderType.UNKNOWN.getDefinition()); return headers; }
@Override public void run() { Document document = documentFactory.createDocuments(file); debug("Selected file: %s [header style: %s]", document.getFilePath(), document.getHeaderDefinition()); if (document.isNotSupported()) { callback.onUnknownFile(document, h); } else if (document.is(h)) { debug("Skipping header file: %s", document.getFilePath()); } else if (document.hasHeader(h, strictCheck)) { callback.onExistingHeader(document, h); } else { boolean headerFound = false; for (Header validHeader : validHeaders) { if (headerFound = document.hasHeader(validHeader, strictCheck)) { callback.onExistingHeader(document, h); break; } } if (!headerFound) { callback.onHeaderNotFound(document, h); } } } }, null);