/** * Returns true if this file is a valid source file name */ protected boolean isSourceFile(File file) { String name = file.getName(); String extension = Files.getExtension(name).toLowerCase(); return sourceFileExtensions.contains(extension) || sourceFileNames.contains(name); }
@Override public boolean accept(File file) { return Objects.equal(extension, Files.getExtension(file.getName())); } }
@Override public boolean accept(File file) { return Objects.equal(extension, Files.getExtension(file.getName())); } }
/** * Returns true if this file is a valid source file; so * excluding things like .svn directories and whatnot */ public boolean isValidSourceFileOrDir(File file) { String name = file.getName(); return !isExcludedDotFile(name) && !excludeExtensions.contains(Files.getExtension(file.getName())); }
protected void scanProject(File file, List<GetOverviewCommand.FileProcessor> processors, ProjectOverviewDTO overview, int level, int maxLevels) { if (file.isFile()) { String name = file.getName(); String extension = Files.getExtension(name); for (GetOverviewCommand.FileProcessor processor : new ArrayList<>(processors)) { if (processor.processes(overview, file, name, extension, level)) { processors.remove(processor); } } } else if (file.isDirectory()) { int newLevel = level + 1; if (newLevel <= maxLevels && !processors.isEmpty()) { File[] files = file.listFiles(); if (files != null) { for (File child : files) { scanProject(child, processors, overview, newLevel, maxLevels); } } } } }
protected void copyFile(File src, File dest, Replacement replaceFn, boolean isSource) throws IOException { if (replaceFn != null && isSource) { String original = IOHelpers.readFully(src); String escapedContent = original; if (original.contains("${")) { String replaced = escapedContent.replaceAll(Pattern.quote("${"), "\\${D}{"); // add Velocity expression at the beginning of the result file. // Velocity is used by mvn archetype:generate escapedContent = "#set( $D = '$' )\n" + replaced; } if (original.contains("##")) { String replaced = escapedContent.replaceAll(Pattern.quote("##"), "\\${H}"); // add Velocity expression at the beginning of the result file. // Velocity is used by mvn archetype:generate escapedContent = "#set( $H = '##' )\n" + replaced; } // do additional replacement String text = replaceFn.replace(escapedContent); IOHelpers.writeFully(dest, text); } else { if (LOG.isDebugEnabled()) { LOG.warn("Not a source dir as the extension is {}", Files.getExtension(src.getName())); } Files.copy(src, dest); } }