use of com.intellij.compiler.server.CompileServerPlugin in project intellij-community by JetBrains.
the class BuildProcessClasspathManager method computeCompileServerPluginsClasspath.
private static List<String> computeCompileServerPluginsClasspath() {
final List<String> classpath = ContainerUtil.newArrayList();
for (CompileServerPlugin serverPlugin : CompileServerPlugin.EP_NAME.getExtensions()) {
final PluginId pluginId = serverPlugin.getPluginDescriptor().getPluginId();
final IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
LOG.assertTrue(plugin != null, pluginId);
final File baseFile = plugin.getPath();
if (baseFile.isFile()) {
classpath.add(baseFile.getPath());
} else if (baseFile.isDirectory()) {
for (String relativePath : StringUtil.split(serverPlugin.getClasspath(), ";")) {
final File jarFile = new File(new File(baseFile, "lib"), relativePath);
File classesDir = new File(baseFile, "classes");
if (jarFile.exists()) {
classpath.add(jarFile.getPath());
} else if (classesDir.isDirectory()) {
//'plugin run configuration': all module output are copied to 'classes' folder
classpath.add(classesDir.getPath());
} else {
//development mode: add directory out/classes/production/<jar-name> to classpath, assuming that jar-name is equal to module name
final String moduleName = FileUtil.getNameWithoutExtension(PathUtil.getFileName(relativePath));
File baseOutputDir = baseFile.getParentFile();
if (baseOutputDir.getName().equals("test")) {
baseOutputDir = new File(baseOutputDir.getParentFile(), "production");
}
final File dir = new File(baseOutputDir, moduleName);
if (dir.exists()) {
classpath.add(dir.getPath());
} else {
//looks like <jar-name> refers to a library, try to find it under <plugin-dir>/lib
File pluginDir = getPluginDir(plugin);
if (pluginDir != null) {
File libraryFile = new File(pluginDir, "lib" + File.separator + PathUtil.getFileName(relativePath));
if (libraryFile.exists()) {
classpath.add(libraryFile.getPath());
} else {
LOG.error("Cannot add " + relativePath + " from '" + plugin.getName() + ' ' + plugin.getVersion() + "'" + " to external compiler classpath: library " + libraryFile.getAbsolutePath() + " not found");
}
} else {
LOG.error("Cannot add " + relativePath + " from '" + plugin.getName() + ' ' + plugin.getVersion() + "'" + " to external compiler classpath: home directory of plugin not found");
}
}
}
}
}
}
return classpath;
}
Aggregations