/** * Adds a file to the classpath if it exists. * * @param filename the name of the file to add */ public void addFile(String filename) { if (filename != null) addFile(new File(filename)); }
/** * Adds a classpath to this configuration. It expects a string with * multiple paths, separated by the system dependent path separator. * Expands wildcards, e.g. dir/* into all the jars in dir. * * @param path the path as a path separator delimited string * @see java.io.File#pathSeparator */ public void addClassPath(String path) { String[] paths = path.split(File.pathSeparator); for (String cpPath : paths) { // Check to support wild card classpath if (cpPath.endsWith("*")) { File dir = new File(cpPath.substring(0, cpPath.length() - 1)); File[] files = dir.listFiles(); if (files != null) { for (File file : files) { if (file.isFile() && file.getName().endsWith(".jar")) addFile(file); } } } else { addFile(new File(cpPath)); } } }
private void findMatchingFiles(File[] files, Pattern pattern, boolean recursive) { for (File file : files) { String fileString = getSlashyPath(file.getPath()); Matcher m = pattern.matcher(fileString); if (m.matches() && file.isFile()) { addFile(file); } if (file.isDirectory() && recursive) { final File[] dirFiles = file.listFiles(); if (dirFiles != null) { findMatchingFiles(dirFiles, pattern, true); } } } }
private void loadFilteredPath(String filter) { if (filter == null) return; filter = getSlashyPath(filter); int starIndex = filter.indexOf(WILDCARD); if (starIndex == -1) { addFile(new File(filter)); return; } boolean recursive = filter.contains(ALL_WILDCARD); if (filter.lastIndexOf('/') < starIndex) { starIndex = filter.lastIndexOf('/') + 1; } String startDir = filter.substring(0, starIndex - 1); File root = new File(startDir); filter = Pattern.quote(filter); filter = filter.replaceAll("\\" + WILDCARD + "\\" + WILDCARD, MATCH_ALL); filter = filter.replaceAll("\\" + WILDCARD, MATCH_FILE_NAME); Pattern pattern = Pattern.compile(filter); final File[] files = root.listFiles(); if (files != null) { findMatchingFiles(files, pattern, recursive); } }
private RootLoader makeRoot() { String[] list = taskClasspath.list(); LoaderConfiguration lc = new LoaderConfiguration(); for (int i=0; i<list.length; i++) { if (list[i].matches(".*ant-[^/]*jar$")) { continue; } if (list[i].matches(".*commons-logging-[^/]*jar$")) { continue; } if (list[i].matches(".*xerces-[^/]*jar$")) { continue; } lc.addFile(list[i]); } return new RootLoader(lc); }
/** * Adds a file to the classpath if it exists. * * @param filename the name of the file to add */ public void addFile(String filename) { if (filename != null) addFile(new File(filename)); }
/** * Adds a file to the classpath if it exists. * * @param filename the name of the file to add */ public void addFile(String filename) { if (filename != null) addFile(new File(filename)); }
/** * Adds a file to the classpath if it exists. * * @param filename the name of the file to add */ public void addFile(String filename) { if (filename != null) addFile(new File(filename)); }
/** * Adds a file to the classpath if it exists. * * @param filename the name of the file to add */ public void addFile(String filename) { if (filename != null) addFile(new File(filename)); }
/** * Adds a classpath to this configuration. It expects a string with * multiple paths, seperated by the system dependent path separator * * @param path the path as a path separator delimited string * @see java.io.File#pathSeparator */ public void addClassPath(String path) { String[] paths = path.split(File.pathSeparator); for (int i = 0; i < paths.length; i++) { addFile(new File(paths[i])); } }
/** * Adds a classpath to this configuration. It expects a string with * multiple paths, seperated by the system dependent path separator * * @param path the path as a path separator delimited string * @see java.io.File#pathSeparator */ public void addClassPath(String path) { String[] paths = path.split(File.pathSeparator); for (int i = 0; i < paths.length; i++) { addFile(new File(paths[i])); } }
/** * Adds a classpath to this configuration. It expects a string with * multiple paths, seperated by the system dependent path separator * * @param path the path as a path separator delimited string * @see java.io.File#pathSeparator */ public void addClassPath(String path) { String[] paths = path.split(File.pathSeparator); for (int i = 0; i < paths.length; i++) { addFile(new File(paths[i])); } }
private void findMatchingFiles(File[] files, Pattern pattern, boolean recursive) { for (int i = 0; i < files.length; i++) { File file = files[i]; String fileString = getSlashyPath(file.getPath()); Matcher m = pattern.matcher(fileString); if (m.matches() && file.isFile()) { addFile(file); } if (file.isDirectory() && recursive) { final File[] dirFiles = file.listFiles(); if (dirFiles != null) { findMatchingFiles(dirFiles, pattern, true); } } } }
private void findMatchingFiles(File[] files, Pattern pattern, boolean recursive) { for (int i = 0; i < files.length; i++) { File file = files[i]; String fileString = getSlashyPath(file.getPath()); Matcher m = pattern.matcher(fileString); if (m.matches() && file.isFile()) { addFile(file); } if (file.isDirectory() && recursive) { final File[] dirFiles = file.listFiles(); if (dirFiles != null) { findMatchingFiles(dirFiles, pattern, true); } } } }
private void findMatchingFiles(File[] files, Pattern pattern, boolean recursive) { for (int i = 0; i < files.length; i++) { File file = files[i]; String fileString = getSlashyPath(file.getPath()); Matcher m = pattern.matcher(fileString); if (m.matches() && file.isFile()) { addFile(file); } if (file.isDirectory() && recursive) { final File[] dirFiles = file.listFiles(); if (dirFiles != null) { findMatchingFiles(dirFiles, pattern, true); } } } }
private void findMatchingFiles(File[] files, Pattern pattern, boolean recursive) { for (int i = 0; i < files.length; i++) { File file = files[i]; String fileString = getSlashyPath(file.getPath()); Matcher m = pattern.matcher(fileString); if (m.matches() && file.isFile()) { addFile(file); } if (file.isDirectory() && recursive) { final File[] dirFiles = file.listFiles(); if (dirFiles != null) { findMatchingFiles(dirFiles, pattern, true); } } } }
private RootLoader makeRoot() { String[] list = taskClasspath.list(); LoaderConfiguration lc = new LoaderConfiguration(); for (int i=0; i<list.length; i++) { if (list[i].matches(".*ant-[^/]*jar$")) { continue; } if (list[i].matches(".*commons-logging-[^/]*jar$")) { continue; } if (list[i].matches(".*xerces-[^/]*jar$")) { continue; } lc.addFile(list[i]); } return new RootLoader(lc); }
private RootLoader makeRoot() { String[] list = taskClasspath.list(); LoaderConfiguration lc = new LoaderConfiguration(); for (int i=0; i<list.length; i++) { if (list[i].matches(".*ant-[^/]*jar$")) { continue; } if (list[i].matches(".*commons-logging-[^/]*jar$")) { continue; } if (list[i].matches(".*xerces-[^/]*jar$")) { continue; } lc.addFile(list[i]); } return new RootLoader(lc); }
private RootLoader makeRoot() { String[] list = taskClasspath.list(); LoaderConfiguration lc = new LoaderConfiguration(); for (int i=0; i<list.length; i++) { if (list[i].matches(".*ant-[^/]*jar$")) { continue; } if (list[i].matches(".*commons-logging-[^/]*jar$")) { continue; } if (list[i].matches(".*xerces-[^/]*jar$")) { continue; } lc.addFile(list[i]); } return new RootLoader(lc); }
private RootLoader makeRoot() { String[] list = taskClasspath.list(); LoaderConfiguration lc = new LoaderConfiguration(); for (int i=0; i<list.length; i++) { if (list[i].matches(".*ant-[^/]*jar$")) { continue; } if (list[i].matches(".*commons-logging-[^/]*jar$")) { continue; } if (list[i].matches(".*xerces-[^/]*jar$")) { continue; } lc.addFile(list[i]); } return new RootLoader(lc); }