mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
compile server: jdk versions added to model
This commit is contained in:
@@ -530,7 +530,14 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
additionalDataXml = JDOMUtil.writeElement(element, "\n");
|
||||
}
|
||||
final List<String> paths = convertToLocalPaths(sdk.getRootProvider().getFiles(OrderRootType.CLASSES));
|
||||
globals.add(new SdkLibrary(name, sdkType.getName(), homePath, paths, additionalDataXml));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ message Message {
|
||||
optional string type_name = 3;
|
||||
optional string additional_data_xml = 4;
|
||||
repeated string path = 5;
|
||||
optional string version = 6;
|
||||
}
|
||||
|
||||
repeated KeyValuePair path_variable = 1;
|
||||
|
||||
@@ -2789,6 +2789,10 @@ public final class JpsRemoteProto {
|
||||
java.util.List<String> getPathList();
|
||||
int getPathCount();
|
||||
String getPath(int index);
|
||||
|
||||
// optional string version = 6;
|
||||
boolean hasVersion();
|
||||
String getVersion();
|
||||
}
|
||||
public static final class GlobalLibrary extends
|
||||
com.google.protobuf.GeneratedMessageLite
|
||||
@@ -2951,12 +2955,45 @@ public final class JpsRemoteProto {
|
||||
return path_.get(index);
|
||||
}
|
||||
|
||||
// optional string version = 6;
|
||||
public static final int VERSION_FIELD_NUMBER = 6;
|
||||
private java.lang.Object version_;
|
||||
public boolean hasVersion() {
|
||||
return ((bitField0_ & 0x00000010) == 0x00000010);
|
||||
}
|
||||
public String getVersion() {
|
||||
java.lang.Object ref = version_;
|
||||
if (ref instanceof String) {
|
||||
return (String) ref;
|
||||
} else {
|
||||
com.google.protobuf.ByteString bs =
|
||||
(com.google.protobuf.ByteString) ref;
|
||||
String s = bs.toStringUtf8();
|
||||
if (com.google.protobuf.Internal.isValidUtf8(bs)) {
|
||||
version_ = s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
private com.google.protobuf.ByteString getVersionBytes() {
|
||||
java.lang.Object ref = version_;
|
||||
if (ref instanceof String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8((String) ref);
|
||||
version_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
name_ = "";
|
||||
homePath_ = "";
|
||||
typeName_ = "";
|
||||
additionalDataXml_ = "";
|
||||
path_ = com.google.protobuf.LazyStringArrayList.EMPTY;
|
||||
version_ = "";
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
@@ -2989,6 +3026,9 @@ public final class JpsRemoteProto {
|
||||
for (int i = 0; i < path_.size(); i++) {
|
||||
output.writeBytes(5, path_.getByteString(i));
|
||||
}
|
||||
if (((bitField0_ & 0x00000010) == 0x00000010)) {
|
||||
output.writeBytes(6, getVersionBytes());
|
||||
}
|
||||
}
|
||||
|
||||
private int memoizedSerializedSize = -1;
|
||||
@@ -3022,6 +3062,10 @@ public final class JpsRemoteProto {
|
||||
size += dataSize;
|
||||
size += 1 * getPathList().size();
|
||||
}
|
||||
if (((bitField0_ & 0x00000010) == 0x00000010)) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeBytesSize(6, getVersionBytes());
|
||||
}
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
}
|
||||
@@ -3134,6 +3178,8 @@ public final class JpsRemoteProto {
|
||||
bitField0_ = (bitField0_ & ~0x00000008);
|
||||
path_ = com.google.protobuf.LazyStringArrayList.EMPTY;
|
||||
bitField0_ = (bitField0_ & ~0x00000010);
|
||||
version_ = "";
|
||||
bitField0_ = (bitField0_ & ~0x00000020);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -3189,6 +3235,10 @@ public final class JpsRemoteProto {
|
||||
bitField0_ = (bitField0_ & ~0x00000010);
|
||||
}
|
||||
result.path_ = path_;
|
||||
if (((from_bitField0_ & 0x00000020) == 0x00000020)) {
|
||||
to_bitField0_ |= 0x00000010;
|
||||
}
|
||||
result.version_ = version_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
return result;
|
||||
}
|
||||
@@ -3217,6 +3267,9 @@ public final class JpsRemoteProto {
|
||||
}
|
||||
|
||||
}
|
||||
if (other.hasVersion()) {
|
||||
setVersion(other.getVersion());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -3270,6 +3323,11 @@ public final class JpsRemoteProto {
|
||||
path_.add(input.readBytes());
|
||||
break;
|
||||
}
|
||||
case 50: {
|
||||
bitField0_ |= 0x00000020;
|
||||
version_ = input.readBytes();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3476,6 +3534,42 @@ public final class JpsRemoteProto {
|
||||
|
||||
}
|
||||
|
||||
// optional string version = 6;
|
||||
private java.lang.Object version_ = "";
|
||||
public boolean hasVersion() {
|
||||
return ((bitField0_ & 0x00000020) == 0x00000020);
|
||||
}
|
||||
public String getVersion() {
|
||||
java.lang.Object ref = version_;
|
||||
if (!(ref instanceof String)) {
|
||||
String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();
|
||||
version_ = s;
|
||||
return s;
|
||||
} else {
|
||||
return (String) ref;
|
||||
}
|
||||
}
|
||||
public Builder setVersion(String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
bitField0_ |= 0x00000020;
|
||||
version_ = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
public Builder clearVersion() {
|
||||
bitField0_ = (bitField0_ & ~0x00000020);
|
||||
version_ = getDefaultInstance().getVersion();
|
||||
|
||||
return this;
|
||||
}
|
||||
void setVersion(com.google.protobuf.ByteString value) {
|
||||
bitField0_ |= 0x00000020;
|
||||
version_ = value;
|
||||
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.jpsservice.Message.Request.SetupCommand.GlobalLibrary)
|
||||
}
|
||||
|
||||
|
||||
@@ -149,6 +149,10 @@ public class ProtoUtil {
|
||||
if (additional != null) {
|
||||
libBuilder.setAdditionalDataXml(additional);
|
||||
}
|
||||
final String version = sdk.getVersion();
|
||||
if (version != null) {
|
||||
libBuilder.setVersion(version);
|
||||
}
|
||||
}
|
||||
cmdBuilder.addGlobalLibrary(libBuilder.build());
|
||||
}
|
||||
|
||||
@@ -9,23 +9,26 @@ import java.util.List;
|
||||
* 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, final String typeName, String homePath, List<String> paths) {
|
||||
this(name, typeName, homePath, paths, null);
|
||||
}
|
||||
|
||||
public SdkLibrary(String name, String typeName, String homePath, List<String> paths, @Nullable String additionalDataXml) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class ServerMessageHandler extends SimpleChannelHandler {
|
||||
for (JpsRemoteProto.Message.Request.SetupCommand.GlobalLibrary library : setupCommand.getGlobalLibraryList()) {
|
||||
libs.add(
|
||||
library.hasHomePath()?
|
||||
new SdkLibrary(library.getName(), library.getTypeName(), library.getHomePath(), library.getPathList(), library.hasAdditionalDataXml()? library.getAdditionalDataXml() : null) :
|
||||
new SdkLibrary(library.getName(), library.getTypeName(), library.hasVersion() ? library.getVersion() : null, library.getHomePath(), library.getPathList(), library.hasAdditionalDataXml()? library.getAdditionalDataXml() : null) :
|
||||
new GlobalLibrary(library.getName(), library.getPathList())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ class ServerState {
|
||||
LOG.info(e);
|
||||
}
|
||||
}
|
||||
final Sdk jdk = project.createSdk(/*"JavaSDK"*/sdk.getTypeName(), sdk.getName(), sdk.getHomePath(), additionalData);
|
||||
final Sdk jdk = project.createSdk(sdk.getTypeName(), sdk.getName(), sdk.getVersion(), sdk.getHomePath(), additionalData);
|
||||
if (jdk != null) {
|
||||
jdk.setClasspath(sdk.getPaths());
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ public abstract class IncrementalTestCase extends TestCase {
|
||||
final String projectPath = getWorkDir() + File.separator + ".idea";
|
||||
final Project project = new Project();
|
||||
|
||||
final Sdk jdk = project.createSdk("JavaSDK", "IDEA jdk", System.getProperty("java.home"), null);
|
||||
final Sdk jdk = project.createSdk("JavaSDK", "IDEA jdk", "1.6", System.getProperty("java.home"), null);
|
||||
final List<String> paths = new LinkedList<String>();
|
||||
|
||||
paths.add(FileUtil.toSystemIndependentName(ClasspathBootstrap.getResourcePath(Object.class).getCanonicalPath()));
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ public abstract class ArtifactBuilderTestCase extends UsefulTestCase {
|
||||
protected Module addModule(String moduleName, @Nullable String srcPath) {
|
||||
if (myJdk == null) {
|
||||
try {
|
||||
myJdk = myProject.createSdk("JavaSDK", "jdk", System.getProperty("java.home"), null);
|
||||
myJdk = myProject.createSdk("JavaSDK", "jdk", "1.6", System.getProperty("java.home"), null);
|
||||
final List<String> paths = new LinkedList<String>();
|
||||
paths.add(FileUtil.toSystemIndependentName(ClasspathBootstrap.getResourcePath(Object.class).getCanonicalPath()));
|
||||
myJdk.setClasspath(paths);
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package org.jetbrains.jps
|
||||
|
||||
import org.jetbrains.annotations.Nullable
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class JavaSdkImpl extends JavaSdk {
|
||||
String jdkPath
|
||||
@Nullable String version
|
||||
|
||||
def JavaSdkImpl(Project project, String name, String jdkPath, Closure initializer) {
|
||||
def JavaSdkImpl(Project project, String name, String version, String jdkPath, Closure initializer) {
|
||||
super(project, name, initializer)
|
||||
this.version = version
|
||||
this.jdkPath = jdkPath
|
||||
}
|
||||
|
||||
|
||||
@@ -46,13 +46,13 @@ class Project {
|
||||
}
|
||||
|
||||
def JavaSdk createJavaSdk(String name, String path, Closure initializer) {
|
||||
def sdk = new JavaSdkImpl(this, name, path, initializer)
|
||||
def sdk = new JavaSdkImpl(this, name, null, path, initializer)
|
||||
sdks[name] = sdk
|
||||
return sdk
|
||||
}
|
||||
|
||||
def Sdk createSdk(String typeName, String sdkName, String path, Node additionalData) {
|
||||
def sdk = SdkLoader.createSdk(this, typeName, sdkName, path, additionalData)
|
||||
def Sdk createSdk(String typeName, String sdkName, String version, String path, Node additionalData) {
|
||||
def sdk = SdkLoader.createSdk(this, typeName, sdkName, version, path, additionalData)
|
||||
sdks[sdkName] = sdk
|
||||
return sdk
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class JavaSdkType extends SdkTypeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
Sdk createSdk(Project project, String name, String homePath, Node additionalData) {
|
||||
return new JavaSdkImpl(project, name, homePath, {})
|
||||
Sdk createSdk(Project project, String name, String version, String homePath, Node additionalData) {
|
||||
return new JavaSdkImpl(project, name, version, homePath, {})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ public class SdkLoader {
|
||||
private static final OwnServiceLoader<SdkTypeService> sdkTypeLoader = OwnServiceLoader.load(SdkTypeService.class)
|
||||
private static Map<String, SdkTypeService> sdkTypes
|
||||
|
||||
public static Sdk createSdk(Project project, String typeName, String sdkName, String homePath, Node additionalData) {
|
||||
public static Sdk createSdk(Project project, String typeName, String sdkName, String version, String homePath, Node additionalData) {
|
||||
def type = findSdkType(typeName)
|
||||
if (type == null) {
|
||||
return null
|
||||
}
|
||||
return type.createSdk(project, sdkName, homePath, additionalData)
|
||||
return type.createSdk(project, sdkName, version, homePath, additionalData)
|
||||
}
|
||||
|
||||
private static SdkTypeService findSdkType(String typeName) {
|
||||
|
||||
@@ -13,5 +13,5 @@ public abstract class SdkTypeService {
|
||||
this.typeName = typeName
|
||||
}
|
||||
|
||||
public abstract Sdk createSdk(Project project, String name, String homePath, Node additionalData)
|
||||
public abstract Sdk createSdk(Project project, String name, String version, String homePath, Node additionalData)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class AndroidSdkType extends SdkTypeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
Sdk createSdk(Project project, String name, String homePath, Node additionalData) {
|
||||
Sdk createSdk(Project project, String name, String version, String homePath, Node additionalData) {
|
||||
def attributes = additionalData.attributes()
|
||||
if (attributes == null) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user