mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
global libraries and sdks removed from protocol for external compiler
This commit is contained in:
@@ -39,16 +39,14 @@ import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ProjectManagerAdapter;
|
||||
import com.intellij.openapi.projectRoots.*;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkType;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
|
||||
import com.intellij.openapi.roots.ModuleRootAdapter;
|
||||
import com.intellij.openapi.roots.ModuleRootEvent;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.ShutDownTracker;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
@@ -74,7 +72,6 @@ import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder;
|
||||
import org.jboss.netty.handler.codec.protobuf.ProtobufEncoder;
|
||||
import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
|
||||
import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
@@ -556,11 +553,6 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
}
|
||||
|
||||
final List<GlobalLibrary> globals = new ArrayList<GlobalLibrary>();
|
||||
|
||||
fillSdks(globals);
|
||||
fillGlobalLibraries(globals);
|
||||
|
||||
final CmdlineRemoteProto.Message.ControllerMessage.GlobalSettings.Builder cmdBuilder =
|
||||
CmdlineRemoteProto.Message.ControllerMessage.GlobalSettings.newBuilder();
|
||||
|
||||
@@ -576,28 +568,6 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
}
|
||||
|
||||
if (!globals.isEmpty()) {
|
||||
for (GlobalLibrary lib : globals) {
|
||||
final CmdlineRemoteProto.Message.ControllerMessage.GlobalSettings.GlobalLibrary.Builder libBuilder =
|
||||
CmdlineRemoteProto.Message.ControllerMessage.GlobalSettings.GlobalLibrary.newBuilder();
|
||||
libBuilder.setName(lib.getName()).addAllPath(lib.getPaths());
|
||||
if (lib instanceof SdkLibrary) {
|
||||
final SdkLibrary sdk = (SdkLibrary)lib;
|
||||
libBuilder.setHomePath(sdk.getHomePath());
|
||||
libBuilder.setTypeName(sdk.getTypeName());
|
||||
final String additional = sdk.getAdditionalDataXml();
|
||||
if (additional != null) {
|
||||
libBuilder.setAdditionalDataXml(additional);
|
||||
}
|
||||
final String version = sdk.getVersion();
|
||||
if (version != null) {
|
||||
libBuilder.setVersion(version);
|
||||
}
|
||||
}
|
||||
cmdBuilder.addGlobalLibrary(libBuilder.build());
|
||||
}
|
||||
}
|
||||
|
||||
final String defaultCharset = EncodingManager.getInstance().getDefaultCharsetName();
|
||||
if (!StringUtil.isEmpty(defaultCharset)) {
|
||||
cmdBuilder.setGlobalEncoding(defaultCharset);
|
||||
@@ -608,66 +578,6 @@ public class BuildManager implements ApplicationComponent{
|
||||
return cmdBuilder.build();
|
||||
}
|
||||
|
||||
private static void fillSdks(List<GlobalLibrary> globals) {
|
||||
for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) {
|
||||
final String name = sdk.getName();
|
||||
final String homePath = sdk.getHomePath();
|
||||
if (homePath == null) {
|
||||
continue;
|
||||
}
|
||||
final SdkAdditionalData data = sdk.getSdkAdditionalData();
|
||||
final String additionalDataXml;
|
||||
final SdkType sdkType = (SdkType) sdk.getSdkType();
|
||||
if (data == null) {
|
||||
additionalDataXml = null;
|
||||
}
|
||||
else {
|
||||
final Element element = new Element("additional");
|
||||
sdkType.saveAdditionalData(data, element);
|
||||
additionalDataXml = JDOMUtil.writeElement(element, "\n");
|
||||
}
|
||||
final List<String> paths = convertToLocalPaths(sdk.getRootProvider().getFiles(OrderRootType.CLASSES));
|
||||
String versionString = sdk.getVersionString();
|
||||
if (versionString != null && sdkType instanceof JavaSdk) {
|
||||
final JavaSdkVersion version = ((JavaSdk)sdkType).getVersion(versionString);
|
||||
if (version != null) {
|
||||
versionString = version.getDescription();
|
||||
}
|
||||
}
|
||||
globals.add(new SdkLibrary(name, sdkType.getName(), versionString, homePath, paths, additionalDataXml));
|
||||
}
|
||||
}
|
||||
|
||||
private static void fillGlobalLibraries(List<GlobalLibrary> globals) {
|
||||
final LibraryTablesRegistrar tableRegistrar = LibraryTablesRegistrar.getInstance();
|
||||
List<LibraryTable> tables = new ArrayList<LibraryTable>();
|
||||
tables.add(tableRegistrar.getLibraryTable());
|
||||
|
||||
tables.addAll(tableRegistrar.getCustomLibraryTables());
|
||||
for (LibraryTable libraryTable : tables) {
|
||||
final Iterator<Library> iterator = libraryTable.getLibraryIterator();
|
||||
while (iterator.hasNext()) {
|
||||
Library library = iterator.next();
|
||||
final String name = library.getName();
|
||||
|
||||
if (name != null) {
|
||||
final List<String> paths = convertToLocalPaths(library.getFiles(OrderRootType.CLASSES));
|
||||
globals.add(new GlobalLibrary(name, paths));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> convertToLocalPaths(VirtualFile[] files) {
|
||||
final List<String> paths = new ArrayList<String>();
|
||||
for (VirtualFile file : files) {
|
||||
if (file.isValid()) {
|
||||
paths.add(StringUtil.trimEnd(FileUtil.toSystemIndependentName(file.getPath()), JarFileSystem.JAR_SEPARATOR));
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
private Process launchBuildProcess(Project project, final int port, final UUID sessionId) throws ExecutionException {
|
||||
// choosing sdk with which the build process should be run
|
||||
Sdk projectJdk = null;
|
||||
|
||||
@@ -42,18 +42,7 @@ message Message {
|
||||
}
|
||||
|
||||
message GlobalSettings {
|
||||
|
||||
message GlobalLibrary {
|
||||
required string name = 1;
|
||||
optional string homePath = 2;
|
||||
optional string type_name = 3;
|
||||
optional string additional_data_xml = 4;
|
||||
repeated string path = 5;
|
||||
optional string version = 6;
|
||||
}
|
||||
|
||||
repeated KeyValuePair path_variable = 1;
|
||||
repeated GlobalLibrary global_library = 2;
|
||||
optional string global_encoding = 3;
|
||||
optional string ignored_files_patterns = 4;
|
||||
required string global_options_path = 5;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
||||
package org.jetbrains.jps.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 10/4/11
|
||||
*/
|
||||
public class GlobalLibrary {
|
||||
|
||||
private final String myName;
|
||||
private final List<String> myPaths;
|
||||
|
||||
public GlobalLibrary(String name, List<String> paths) {
|
||||
myName = name;
|
||||
myPaths = paths;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public List<String> getPaths() {
|
||||
return myPaths;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package org.jetbrains.jps.api;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 10/4/11
|
||||
*/
|
||||
public class SdkLibrary extends GlobalLibrary {
|
||||
private final String myTypeName;
|
||||
@Nullable private final String myVersion;
|
||||
private final String myHomePath;
|
||||
@Nullable
|
||||
private final String myAdditionalDataXml;
|
||||
|
||||
public SdkLibrary(String name, String typeName, @Nullable String version, String homePath, List<String> paths,
|
||||
@Nullable String additionalDataXml) {
|
||||
super(name, paths);
|
||||
myTypeName = typeName;
|
||||
myVersion = version;
|
||||
myHomePath = homePath;
|
||||
myAdditionalDataXml = additionalDataXml;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getVersion() {
|
||||
return myVersion;
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return myTypeName;
|
||||
}
|
||||
|
||||
public String getHomePath() {
|
||||
return myHomePath;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAdditionalDataXml() {
|
||||
return myAdditionalDataXml;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user