use of org.infernus.idea.checkstyle.exception.CheckStylePluginException in project checkstyle-idea by jshiell.
the class CheckstyleClassLoaderContainer method buildClassLoader.
@NotNull
private ClassLoader buildClassLoader(@NotNull final String classPathFromProps, @NotNull final List<URL> thirdPartyClasspath) {
final String basePath = getBasePath();
final File classesDir4UnitTesting = new File(basePath, "classes/java/csaccess");
final boolean unitTesting = classesDir4UnitTesting.exists();
List<URL> urls = new ArrayList<>();
try {
if (unitTesting) {
urls.add(classesDir4UnitTesting.toURI().toURL());
} else {
urls.add(new File(basePath, "checkstyle/classes").toURI().toURL());
}
for (String jar : classPathFromProps.trim().split("\\s*;\\s*")) {
if (unitTesting) {
String testJarLocation = "tmp/gatherCheckstyleArtifacts" + jar.substring(jar.lastIndexOf('/'));
urls.add(new File(basePath, testJarLocation).toURI().toURL());
} else {
urls.add(new File(basePath, jar).toURI().toURL());
}
}
} catch (MalformedURLException e) {
throw new CheckStylePluginException("internal error", e);
}
urls.addAll(thirdPartyClasspath);
// The plugin classloader is the new classloader's parent classloader.
final ChildFirstURLClassLoader newClassLoader = new ChildFirstURLClassLoader(urls.toArray(new URL[0]), getClass().getClassLoader());
if (weAreDebuggingADifferentVersionOfIdea(newClassLoader)) {
// if we're debugging from another version of IDEA then child-first will do nasty things to the IDEA classpath
Notifications.showWarning(project, message("plugin.debugging"));
return new URLClassLoader(urls.toArray(new URL[0]), getClass().getClassLoader());
}
return newClassLoader;
}
Aggregations