private static URL[] getClassPathURLs(File dir, @Nullable String extraClassPath, Set<String> libDirs) { try { List<URL> urls = Lists.newArrayList(dir.toURI().toURL()); addJarURLs(dir, urls); for (String libDir : libDirs) { addJarURLs(new File(dir, libDir), urls); } if (extraClassPath != null) { for (String path : Splitter.on(File.pathSeparatorChar).omitEmptyStrings().split(extraClassPath)) { String wildcardSuffix = File.separator + "*"; if (path.endsWith(wildcardSuffix)) { addJarURLs(new File(path.substring(0, path.length() - wildcardSuffix.length())), urls); } else { urls.add(new File(path).toURI().toURL()); } } } return urls.toArray(new URL[urls.size()]); } catch (MalformedURLException e) { // Should never happen LOG.error("Error in adding jar URLs to classPathUrls", e); throw Throwables.propagate(e); } }
private static URL[] getClassPathURLs(File dir, @Nullable String extraClassPath, Set<String> libDirs) { try { List<URL> urls = Lists.newArrayList(dir.toURI().toURL()); addJarURLs(dir, urls); for (String libDir : libDirs) { addJarURLs(new File(dir, libDir), urls); } if (extraClassPath != null) { for (String path : Splitter.on(File.pathSeparatorChar).omitEmptyStrings().split(extraClassPath)) { String wildcardSuffix = File.separator + "*"; if (path.endsWith(wildcardSuffix)) { addJarURLs(new File(path.substring(0, path.length() - wildcardSuffix.length())), urls); } else { urls.add(new File(path).toURI().toURL()); } } } return urls.toArray(new URL[urls.size()]); } catch (MalformedURLException e) { // Should never happen LOG.error("Error in adding jar URLs to classPathUrls", e); throw Throwables.propagate(e); } }