public List<File> getBinaryDirs() { init(); return binaries; } }
protected List<File> getFilesFromProperty(String property) { List<File> result = Lists.newArrayList(); String fileList = settings.getString(property); if (StringUtils.isNotEmpty(fileList)) { Iterable<String> fileNames = Splitter.on(SEPARATOR).omitEmptyStrings().split(fileList); File baseDir = fs.baseDir(); boolean hasJavaSources = hasJavaSources(); boolean isLibraryProperty = property.endsWith("libraries"); for (String pathPattern : fileNames) { List<File> libraryFilesForPattern = getFilesForPattern(baseDir, pathPattern, isLibraryProperty); if (validateLibraries && libraryFilesForPattern.isEmpty() && hasJavaSources) { LOG.error("Invalid value for " + property); String message = "No files nor directories matching '" + pathPattern + "'"; throw new IllegalStateException(message); } result.addAll(libraryFilesForPattern); } } return result; }
private Set<File> getFilesForPattern(Path baseDir, String pathPattern, boolean libraryProperty) { try { Path filePath = resolvePath(baseDir, pathPattern); File file = filePath.toFile(); if(file.isFile()) { return getMatchingFile(pathPattern, file); } if (file.isDirectory()) { return getMatchesInDir(filePath, libraryProperty); } } catch (IOException | InvalidPathException e) { // continue } String dirPath = sanitizeWildcards(pathPattern); String fileNamePattern = pathPattern; int lastPathSeparator = Math.max(dirPath.lastIndexOf(UNIX_SEPARATOR), dirPath.lastIndexOf(WINDOWS_SEPARATOR)); if (lastPathSeparator == -1) { dirPath = "."; } else { dirPath = pathPattern.substring(0, lastPathSeparator); fileNamePattern = pathPattern.substring(lastPathSeparator + 1); } Path dir = resolvePath(baseDir, dirPath); return getFilesInDir(dir, fileNamePattern, libraryProperty); }
private List<File> getFilesForPattern(File baseDir, String pathPattern, boolean libraryProperty) { String dirPath = pathPattern; String filePattern; int wildcardIndex = pathPattern.indexOf('*'); if (wildcardIndex >= 0) { dirPath = pathPattern.substring(0, wildcardIndex); } int lastPathSeparator = Math.max(dirPath.lastIndexOf('/'), dirPath.lastIndexOf('\\')); if (lastPathSeparator == -1) { dirPath = "."; filePattern = pathPattern; } else { dirPath = pathPattern.substring(0, lastPathSeparator); filePattern = pathPattern.substring(lastPathSeparator + 1); } File dir = resolvePath(baseDir, dirPath); if (!dir.isDirectory()) { return Lists.newArrayList(); } return getMatchingFiles(filePattern, dir, libraryProperty); }
private static Set<File> getMatchingLibraries(String pattern, Path dir) throws IOException { Set<File> matches = new LinkedHashSet<>(); Set<File> dirs = getMatchingDirs(pattern, dir); PathMatcher matcher = FileSystems.getDefault().getPathMatcher(getGlob(dir, pattern)); for (File d : dirs) { matches.addAll(getLibs(d.toPath())); } matches.addAll(dirs); matches.addAll(new LibraryFinder().find(dir, matcher)); if(pattern.startsWith("**/")) { // match jar in the base dir when using wildcard matches.addAll(new LibraryFinder().find(dir, FileSystems.getDefault().getPathMatcher(getGlob(dir, pattern.substring(3))))); } return matches; }
files.addAll(getMatchingFiles("**/*.jar", directory, true)); files.addAll(getMatchingFiles("**/*.zip", directory, true));
private static Set<File> getMatchingDirs(String pattern, Path dir) throws IOException { if (!StringUtils.isEmpty(pattern)) { // find all dirs and subdirs that match the pattern PathMatcher matcher = FileSystems.getDefault().getPathMatcher(getGlob(dir, pattern)); return new DirFinder().find(dir, matcher); } else { // no pattern, so we just return dir return Collections.singleton(dir.toFile()); } }
protected List<File> getFilesFromProperty(String property) { List<File> result = Lists.newArrayList(); String fileList = settings.getString(property); if (StringUtils.isNotEmpty(fileList)) { Iterable<String> fileNames = Splitter.on(SEPARATOR).omitEmptyStrings().split(fileList); File baseDir = fs.baseDir(); boolean hasJavaSources = hasJavaSources(); boolean isLibraryProperty = property.endsWith("libraries"); for (String pathPattern : fileNames) { List<File> libraryFilesForPattern = getFilesForPattern(baseDir, pathPattern, isLibraryProperty); if (validateLibraries && libraryFilesForPattern.isEmpty() && hasJavaSources) { LOG.error("Invalid value for " + property); String message = "No files nor directories matching '" + pathPattern + "'"; throw new IllegalStateException(message); } result.addAll(libraryFilesForPattern); } } return result; }
private Set<File> getFilesForPattern(Path baseDir, String pathPattern, boolean libraryProperty) { try { Path filePath = resolvePath(baseDir, pathPattern); File file = filePath.toFile(); if(file.isFile()) { return getMatchingFile(pathPattern, file); } if (file.isDirectory()) { return getMatchesInDir(filePath, libraryProperty); } } catch (IOException | InvalidPathException e) { // continue } String dirPath = sanitizeWildcards(pathPattern); String fileNamePattern = pathPattern; int lastPathSeparator = Math.max(dirPath.lastIndexOf(UNIX_SEPARATOR), dirPath.lastIndexOf(WINDOWS_SEPARATOR)); if (lastPathSeparator == -1) { dirPath = "."; } else { dirPath = pathPattern.substring(0, lastPathSeparator); fileNamePattern = pathPattern.substring(lastPathSeparator + 1); } Path dir = resolvePath(baseDir, dirPath); return getFilesInDir(dir, fileNamePattern, libraryProperty); }
private List<File> getFilesForPattern(File baseDir, String pathPattern, boolean libraryProperty) { String dirPath = pathPattern; String filePattern; int wildcardIndex = pathPattern.indexOf('*'); if (wildcardIndex >= 0) { dirPath = pathPattern.substring(0, wildcardIndex); } int lastPathSeparator = Math.max(dirPath.lastIndexOf('/'), dirPath.lastIndexOf('\\')); if (lastPathSeparator == -1) { dirPath = "."; filePattern = pathPattern; } else { dirPath = pathPattern.substring(0, lastPathSeparator); filePattern = pathPattern.substring(lastPathSeparator + 1); } File dir = resolvePath(baseDir, dirPath); if (!dir.isDirectory()) { return Lists.newArrayList(); } return getMatchingFiles(filePattern, dir, libraryProperty); }
private static Set<File> getMatchingLibraries(String pattern, Path dir) throws IOException { Set<File> matches = new LinkedHashSet<>(); Set<File> dirs = getMatchingDirs(pattern, dir); PathMatcher matcher = FileSystems.getDefault().getPathMatcher(getGlob(dir, pattern)); for (File d : dirs) { matches.addAll(getLibs(d.toPath())); } matches.addAll(dirs); matches.addAll(new LibraryFinder().find(dir, matcher)); if(pattern.startsWith("**/")) { // match jar in the base dir when using wildcard matches.addAll(new LibraryFinder().find(dir, FileSystems.getDefault().getPathMatcher(getGlob(dir, pattern.substring(3))))); } return matches; }
files.addAll(getMatchingFiles("**/*.jar", directory, true)); files.addAll(getMatchingFiles("**/*.zip", directory, true));
private static Set<File> getMatchingDirs(String pattern, Path dir) throws IOException { if (!StringUtils.isEmpty(pattern)) { // find all dirs and subdirs that match the pattern PathMatcher matcher = FileSystems.getDefault().getPathMatcher(getGlob(dir, pattern)); return new DirFinder().find(dir, matcher); } else { // no pattern, so we just return dir return Collections.singleton(dir.toFile()); } }
protected Set<File> getFilesFromProperty(String property) { Set<File> result = new LinkedHashSet<>(); String fileList = settings.get(property).orElse(""); if (StringUtils.isNotEmpty(fileList)) { Iterable<String> fileNames = Splitter.on(SEPARATOR).omitEmptyStrings().split(fileList); File baseDir = fs.baseDir(); boolean hasJavaSources = hasJavaSources(); boolean validateLibs = validateLibraries; boolean isLibraryProperty = property.endsWith("libraries"); for (String pathPattern : fileNames) { Set<File> libraryFilesForPattern = getFilesForPattern(baseDir.toPath(), pathPattern, isLibraryProperty); if (validateLibraries && libraryFilesForPattern.isEmpty() && hasJavaSources) { LOG.error("Invalid value for " + property); String message = "No files nor directories matching '" + pathPattern + "'"; throw new IllegalStateException(message); } validateLibraries = validateLibs; result.addAll(libraryFilesForPattern); } } return result; }
public List<File> getElements() { init(); return elements; }
protected Set<File> getFilesFromProperty(String property) { Set<File> result = new LinkedHashSet<>(); String fileList = settings.get(property).orElse(""); if (StringUtils.isNotEmpty(fileList)) { Iterable<String> fileNames = Splitter.on(SEPARATOR).omitEmptyStrings().split(fileList); File baseDir = fs.baseDir(); boolean hasJavaSources = hasJavaSources(); boolean validateLibs = validateLibraries; boolean isLibraryProperty = property.endsWith("libraries"); for (String pathPattern : fileNames) { Set<File> libraryFilesForPattern = getFilesForPattern(baseDir.toPath(), pathPattern, isLibraryProperty); if (validateLibraries && libraryFilesForPattern.isEmpty() && hasJavaSources) { LOG.error("Invalid value for " + property); String message = "No files nor directories matching '" + pathPattern + "'"; throw new IllegalStateException(message); } validateLibraries = validateLibs; result.addAll(libraryFilesForPattern); } } return result; }
public List<File> getBinaryDirs() { init(); return binaries; } }
public List<File> getElements() { init(); return elements; }
public List<File> getBinaryDirs() { init(); return binaries; }
public List<File> getElements() { init(); return elements; }