class ClasspathAddition {
private static final Logger LOG = Logger.getInstance(ClasspathAddition.class);
public static ClassLoader createClassLoaderWithDependencies(List<String> pathsToAdd, String mainScriptUrl, String pluginId, ErrorReporter errorReporter) {
GroovyClassLoader classLoader = new GroovyClassLoader(PluginRunner.class.getClassLoader());
try {
for (String path : pathsToAdd) {
if (path.startsWith("file:/")) {
URL url = new URL(path);
classLoader.addURL(url);
classLoader.addClasspath(url.getFile());
} else {
classLoader.addURL(new URL("file:///" + path));
classLoader.addClasspath(path);
}
}
} catch (IOException e) {
errorReporter.addLoadingError(pluginId, "Error while looking for dependencies in '" + mainScriptUrl + "'. " + e.getMessage());