diff --git a/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java b/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java index ed97f1ea86c7..8abbe757472b 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java @@ -280,7 +280,8 @@ public class CompileServerManager implements ApplicationComponent{ continue; } final RequestFuture future = submitCompilationTask(project, false, true, Collections.emptyList(), Collections.emptyList(), - Collections.emptyList(), new AutoMakeResponseHandler(project)); + Collections.emptyList(), Collections.emptyMap(), new AutoMakeResponseHandler(project) + ); if (future != null) { futures.add(future); synchronized (myAutomakeFutures) { @@ -312,9 +313,10 @@ public class CompileServerManager implements ApplicationComponent{ } @Nullable - public RequestFuture submitCompilationTask(final Project project, final boolean isRebuild, final boolean isMake, - final Collection modules, final Collection artifacts, - final Collection paths, final JpsServerResponseHandler handler) { + public RequestFuture submitCompilationTask(final Project project, final boolean isRebuild, final boolean isMake, + final Collection modules, final Collection artifacts, + final Collection paths, + final Map userData, final JpsServerResponseHandler handler) { final String projectId = project.getLocation(); final Ref futureRef = new Ref(null); final RunnableFuture future = myTaskExecutor.submit(new Runnable() { @@ -324,7 +326,7 @@ public class CompileServerManager implements ApplicationComponent{ if (client != null) { final RequestFuture requestFuture = isRebuild ? client.sendRebuildRequest(projectId, handler) : - client.sendCompileRequest(isMake, projectId, modules, artifacts, paths, handler); + client.sendCompileRequest(isMake, projectId, modules, artifacts, paths, userData, handler); futureRef.set(requestFuture); } else { diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java index 0b1bf1f4605c..8d6d0f39f63d 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -430,7 +430,24 @@ public class CompileDriver { final CompileServerManager csManager = CompileServerManager.getInstance(); final MessageBus messageBus = myProject.getMessageBus(); csManager.cancelAutoMakeTasks(myProject); - return csManager.submitCompilationTask(myProject, compileContext.isRebuild(), compileContext.isMake(), moduleNames, artifactNames, paths, new JpsServerResponseHandler() { + final CompileScope scope = compileContext.getCompileScope(); + final Map userData; + // need to pass scope's user data to server + if (scope instanceof UserDataHolderBase) { // hack + userData = new HashMap(); + ((UserDataHolderBase)scope).copyUserDataTo(new UserDataHolderBase() { + @Override + public void putUserData(@NotNull Key key, @Nullable T value) { + final String _key = key.toString(); + final String _value = value != null? value.toString() : ""; + userData.put(_key, _value); + } + }); + } + else { + userData = Collections.emptyMap(); + } + return csManager.submitCompilationTask(myProject, compileContext.isRebuild(), compileContext.isMake(), moduleNames, artifactNames, paths, userData, new JpsServerResponseHandler() { @Override public void handleCompileMessage(JpsRemoteProto.Message.Response.CompileMessage compilerMessage) { diff --git a/jps/jps-builders/proto/jps_remote_proto.proto b/jps/jps-builders/proto/jps_remote_proto.proto index 03eabce9567f..730a59e33544 100644 --- a/jps/jps-builders/proto/jps_remote_proto.proto +++ b/jps/jps-builders/proto/jps_remote_proto.proto @@ -10,6 +10,11 @@ message Message { required sint64 least_sig_bits = 2; } + message KeyValuePair { + required string key = 1; + required string value = 2; + } + enum Type { REQUEST = 1; RESPONSE = 2; @@ -44,6 +49,7 @@ message Message { repeated string module_name = 3; repeated string file_path = 4; repeated string artifact_name = 5; + repeated KeyValuePair builder_parameter = 6; } message ShutdownCommand { @@ -56,11 +62,6 @@ message Message { message SetupCommand { - message PathVariable { - required string name = 1; - required string value = 2; - } - message GlobalLibrary { required string name = 1; optional string homePath = 2; @@ -69,7 +70,7 @@ message Message { repeated string path = 5; } - repeated PathVariable path_variable = 1; + repeated KeyValuePair path_variable = 1; repeated GlobalLibrary global_library = 2; optional string global_encoding = 3; } diff --git a/jps/jps-builders/src/org/jetbrains/jps/api/JpsRemoteProto.java b/jps/jps-builders/src/org/jetbrains/jps/api/JpsRemoteProto.java index cf6dd424fbba..424a1ef5e08c 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/api/JpsRemoteProto.java +++ b/jps/jps-builders/src/org/jetbrains/jps/api/JpsRemoteProto.java @@ -359,6 +359,305 @@ public final class JpsRemoteProto { // @@protoc_insertion_point(class_scope:org.jetbrains.jpsservice.Message.UUID) } + public static final class KeyValuePair extends + com.google.protobuf.GeneratedMessageLite { + // Use KeyValuePair.newBuilder() to construct. + private KeyValuePair() { + initFields(); + } + private KeyValuePair(boolean noInit) {} + + private static final KeyValuePair defaultInstance; + public static KeyValuePair getDefaultInstance() { + return defaultInstance; + } + + public KeyValuePair getDefaultInstanceForType() { + return defaultInstance; + } + + // required string key = 1; + public static final int KEY_FIELD_NUMBER = 1; + private boolean hasKey; + private java.lang.String key_ = ""; + public boolean hasKey() { return hasKey; } + public java.lang.String getKey() { return key_; } + + // required string value = 2; + public static final int VALUE_FIELD_NUMBER = 2; + private boolean hasValue; + private java.lang.String value_ = ""; + public boolean hasValue() { return hasValue; } + public java.lang.String getValue() { return value_; } + + private void initFields() { + } + public final boolean isInitialized() { + if (!hasKey) return false; + if (!hasValue) return false; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (hasKey()) { + output.writeString(1, getKey()); + } + if (hasValue()) { + output.writeString(2, getValue()); + } + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasKey()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(1, getKey()); + } + if (hasValue()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(2, getValue()); + } + memoizedSerializedSize = size; + return size; + } + + public static org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair parseFrom(java.io.InputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + public static org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input, extensionRegistry)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + public static final class Builder extends + com.google.protobuf.GeneratedMessageLite.Builder< + org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair, Builder> { + private org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair result; + + // Construct using org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair.newBuilder() + private Builder() {} + + private static Builder create() { + Builder builder = new Builder(); + builder.result = new org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair(); + return builder; + } + + protected org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair internalGetResult() { + return result; + } + + public Builder clear() { + if (result == null) { + throw new IllegalStateException( + "Cannot call clear() after build()."); + } + result = new org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair(); + return this; + } + + public Builder clone() { + return create().mergeFrom(result); + } + + public org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair getDefaultInstanceForType() { + return org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair.getDefaultInstance(); + } + + public boolean isInitialized() { + return result.isInitialized(); + } + public org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair build() { + if (result != null && !isInitialized()) { + throw newUninitializedMessageException(result); + } + return buildPartial(); + } + + private org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair buildParsed() + throws com.google.protobuf.InvalidProtocolBufferException { + if (!isInitialized()) { + throw newUninitializedMessageException( + result).asInvalidProtocolBufferException(); + } + return buildPartial(); + } + + public org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair buildPartial() { + if (result == null) { + throw new IllegalStateException( + "build() has already been called on this Builder."); + } + org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair returnMe = result; + result = null; + return returnMe; + } + + public Builder mergeFrom(org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair other) { + if (other == org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair.getDefaultInstance()) return this; + if (other.hasKey()) { + setKey(other.getKey()); + } + if (other.hasValue()) { + setValue(other.getValue()); + } + return this; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + while (true) { + int tag = input.readTag(); + switch (tag) { + case 0: + return this; + default: { + if (!parseUnknownField(input, extensionRegistry, tag)) { + return this; + } + break; + } + case 10: { + setKey(input.readString()); + break; + } + case 18: { + setValue(input.readString()); + break; + } + } + } + } + + + // required string key = 1; + public boolean hasKey() { + return result.hasKey(); + } + public java.lang.String getKey() { + return result.getKey(); + } + public Builder setKey(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasKey = true; + result.key_ = value; + return this; + } + public Builder clearKey() { + result.hasKey = false; + result.key_ = getDefaultInstance().getKey(); + return this; + } + + // required string value = 2; + public boolean hasValue() { + return result.hasValue(); + } + public java.lang.String getValue() { + return result.getValue(); + } + public Builder setValue(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasValue = true; + result.value_ = value; + return this; + } + public Builder clearValue() { + result.hasValue = false; + result.value_ = getDefaultInstance().getValue(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.jetbrains.jpsservice.Message.KeyValuePair) + } + + static { + defaultInstance = new KeyValuePair(true); + org.jetbrains.jps.api.JpsRemoteProto.internalForceInit(); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.jetbrains.jpsservice.Message.KeyValuePair) + } + public static final class Failure extends com.google.protobuf.GeneratedMessageLite { // Use Failure.newBuilder() to construct. @@ -869,11 +1168,26 @@ public final class JpsRemoteProto { return artifactName_.get(index); } + // repeated .org.jetbrains.jpsservice.Message.KeyValuePair builder_parameter = 6; + public static final int BUILDER_PARAMETER_FIELD_NUMBER = 6; + private java.util.List builderParameter_ = + java.util.Collections.emptyList(); + public java.util.List getBuilderParameterList() { + return builderParameter_; + } + public int getBuilderParameterCount() { return builderParameter_.size(); } + public org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair getBuilderParameter(int index) { + return builderParameter_.get(index); + } + private void initFields() { commandType_ = org.jetbrains.jps.api.JpsRemoteProto.Message.Request.CompilationRequest.Type.REBUILD; } public final boolean isInitialized() { if (!hasCommandType) return false; + for (org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair element : getBuilderParameterList()) { + if (!element.isInitialized()) return false; + } return true; } @@ -895,6 +1209,9 @@ public final class JpsRemoteProto { for (java.lang.String element : getArtifactNameList()) { output.writeString(5, element); } + for (org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair element : getBuilderParameterList()) { + output.writeMessage(6, element); + } } private int memoizedSerializedSize = -1; @@ -938,6 +1255,10 @@ public final class JpsRemoteProto { size += dataSize; size += 1 * getArtifactNameList().size(); } + for (org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair element : getBuilderParameterList()) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, element); + } memoizedSerializedSize = size; return size; } @@ -1087,6 +1408,10 @@ public final class JpsRemoteProto { result.artifactName_ = java.util.Collections.unmodifiableList(result.artifactName_); } + if (result.builderParameter_ != java.util.Collections.EMPTY_LIST) { + result.builderParameter_ = + java.util.Collections.unmodifiableList(result.builderParameter_); + } org.jetbrains.jps.api.JpsRemoteProto.Message.Request.CompilationRequest returnMe = result; result = null; return returnMe; @@ -1118,6 +1443,12 @@ public final class JpsRemoteProto { } result.artifactName_.addAll(other.artifactName_); } + if (!other.builderParameter_.isEmpty()) { + if (result.builderParameter_.isEmpty()) { + result.builderParameter_ = new java.util.ArrayList(); + } + result.builderParameter_.addAll(other.builderParameter_); + } return this; } @@ -1160,6 +1491,12 @@ public final class JpsRemoteProto { addArtifactName(input.readString()); break; } + case 50: { + org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair.Builder subBuilder = org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair.newBuilder(); + input.readMessage(subBuilder, extensionRegistry); + addBuilderParameter(subBuilder.buildPartial()); + break; + } } } } @@ -1327,6 +1664,57 @@ public final class JpsRemoteProto { return this; } + // repeated .org.jetbrains.jpsservice.Message.KeyValuePair builder_parameter = 6; + public java.util.List getBuilderParameterList() { + return java.util.Collections.unmodifiableList(result.builderParameter_); + } + public int getBuilderParameterCount() { + return result.getBuilderParameterCount(); + } + public org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair getBuilderParameter(int index) { + return result.getBuilderParameter(index); + } + public Builder setBuilderParameter(int index, org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair value) { + if (value == null) { + throw new NullPointerException(); + } + result.builderParameter_.set(index, value); + return this; + } + public Builder setBuilderParameter(int index, org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair.Builder builderForValue) { + result.builderParameter_.set(index, builderForValue.build()); + return this; + } + public Builder addBuilderParameter(org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair value) { + if (value == null) { + throw new NullPointerException(); + } + if (result.builderParameter_.isEmpty()) { + result.builderParameter_ = new java.util.ArrayList(); + } + result.builderParameter_.add(value); + return this; + } + public Builder addBuilderParameter(org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair.Builder builderForValue) { + if (result.builderParameter_.isEmpty()) { + result.builderParameter_ = new java.util.ArrayList(); + } + result.builderParameter_.add(builderForValue.build()); + return this; + } + public Builder addAllBuilderParameter( + java.lang.Iterable values) { + if (result.builderParameter_.isEmpty()) { + result.builderParameter_ = new java.util.ArrayList(); + } + super.addAll(values, result.builderParameter_); + return this; + } + public Builder clearBuilderParameter() { + result.builderParameter_ = java.util.Collections.emptyList(); + return this; + } + // @@protoc_insertion_point(builder_scope:org.jetbrains.jpsservice.Message.Request.CompilationRequest) } @@ -1656,305 +2044,6 @@ public final class JpsRemoteProto { return defaultInstance; } - public static final class PathVariable extends - com.google.protobuf.GeneratedMessageLite { - // Use PathVariable.newBuilder() to construct. - private PathVariable() { - initFields(); - } - private PathVariable(boolean noInit) {} - - private static final PathVariable defaultInstance; - public static PathVariable getDefaultInstance() { - return defaultInstance; - } - - public PathVariable getDefaultInstanceForType() { - return defaultInstance; - } - - // required string name = 1; - public static final int NAME_FIELD_NUMBER = 1; - private boolean hasName; - private java.lang.String name_ = ""; - public boolean hasName() { return hasName; } - public java.lang.String getName() { return name_; } - - // required string value = 2; - public static final int VALUE_FIELD_NUMBER = 2; - private boolean hasValue; - private java.lang.String value_ = ""; - public boolean hasValue() { return hasValue; } - public java.lang.String getValue() { return value_; } - - private void initFields() { - } - public final boolean isInitialized() { - if (!hasName) return false; - if (!hasValue) return false; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (hasName()) { - output.writeString(1, getName()); - } - if (hasValue()) { - output.writeString(2, getValue()); - } - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasName()) { - size += com.google.protobuf.CodedOutputStream - .computeStringSize(1, getName()); - } - if (hasValue()) { - size += com.google.protobuf.CodedOutputStream - .computeStringSize(2, getValue()); - } - memoizedSerializedSize = size; - return size; - } - - public static org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable parseFrom(java.io.InputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - public static org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input, extensionRegistry)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - public static final class Builder extends - com.google.protobuf.GeneratedMessageLite.Builder< - org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable, Builder> { - private org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable result; - - // Construct using org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable.newBuilder() - private Builder() {} - - private static Builder create() { - Builder builder = new Builder(); - builder.result = new org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable(); - return builder; - } - - protected org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable internalGetResult() { - return result; - } - - public Builder clear() { - if (result == null) { - throw new IllegalStateException( - "Cannot call clear() after build()."); - } - result = new org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable(); - return this; - } - - public Builder clone() { - return create().mergeFrom(result); - } - - public org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable getDefaultInstanceForType() { - return org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable.getDefaultInstance(); - } - - public boolean isInitialized() { - return result.isInitialized(); - } - public org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable build() { - if (result != null && !isInitialized()) { - throw newUninitializedMessageException(result); - } - return buildPartial(); - } - - private org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable buildParsed() - throws com.google.protobuf.InvalidProtocolBufferException { - if (!isInitialized()) { - throw newUninitializedMessageException( - result).asInvalidProtocolBufferException(); - } - return buildPartial(); - } - - public org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable buildPartial() { - if (result == null) { - throw new IllegalStateException( - "build() has already been called on this Builder."); - } - org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable returnMe = result; - result = null; - return returnMe; - } - - public Builder mergeFrom(org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable other) { - if (other == org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable.getDefaultInstance()) return this; - if (other.hasName()) { - setName(other.getName()); - } - if (other.hasValue()) { - setValue(other.getValue()); - } - return this; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - while (true) { - int tag = input.readTag(); - switch (tag) { - case 0: - return this; - default: { - if (!parseUnknownField(input, extensionRegistry, tag)) { - return this; - } - break; - } - case 10: { - setName(input.readString()); - break; - } - case 18: { - setValue(input.readString()); - break; - } - } - } - } - - - // required string name = 1; - public boolean hasName() { - return result.hasName(); - } - public java.lang.String getName() { - return result.getName(); - } - public Builder setName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasName = true; - result.name_ = value; - return this; - } - public Builder clearName() { - result.hasName = false; - result.name_ = getDefaultInstance().getName(); - return this; - } - - // required string value = 2; - public boolean hasValue() { - return result.hasValue(); - } - public java.lang.String getValue() { - return result.getValue(); - } - public Builder setValue(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasValue = true; - result.value_ = value; - return this; - } - public Builder clearValue() { - result.hasValue = false; - result.value_ = getDefaultInstance().getValue(); - return this; - } - - // @@protoc_insertion_point(builder_scope:org.jetbrains.jpsservice.Message.Request.SetupCommand.PathVariable) - } - - static { - defaultInstance = new PathVariable(true); - org.jetbrains.jps.api.JpsRemoteProto.internalForceInit(); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:org.jetbrains.jpsservice.Message.Request.SetupCommand.PathVariable) - } - public static final class GlobalLibrary extends com.google.protobuf.GeneratedMessageLite { // Use GlobalLibrary.newBuilder() to construct. @@ -2415,15 +2504,15 @@ public final class JpsRemoteProto { // @@protoc_insertion_point(class_scope:org.jetbrains.jpsservice.Message.Request.SetupCommand.GlobalLibrary) } - // repeated .org.jetbrains.jpsservice.Message.Request.SetupCommand.PathVariable path_variable = 1; + // repeated .org.jetbrains.jpsservice.Message.KeyValuePair path_variable = 1; public static final int PATH_VARIABLE_FIELD_NUMBER = 1; - private java.util.List pathVariable_ = + private java.util.List pathVariable_ = java.util.Collections.emptyList(); - public java.util.List getPathVariableList() { + public java.util.List getPathVariableList() { return pathVariable_; } public int getPathVariableCount() { return pathVariable_.size(); } - public org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable getPathVariable(int index) { + public org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair getPathVariable(int index) { return pathVariable_.get(index); } @@ -2449,7 +2538,7 @@ public final class JpsRemoteProto { private void initFields() { } public final boolean isInitialized() { - for (org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable element : getPathVariableList()) { + for (org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair element : getPathVariableList()) { if (!element.isInitialized()) return false; } for (org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.GlobalLibrary element : getGlobalLibraryList()) { @@ -2461,7 +2550,7 @@ public final class JpsRemoteProto { public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); - for (org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable element : getPathVariableList()) { + for (org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair element : getPathVariableList()) { output.writeMessage(1, element); } for (org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.GlobalLibrary element : getGlobalLibraryList()) { @@ -2478,7 +2567,7 @@ public final class JpsRemoteProto { if (size != -1) return size; size = 0; - for (org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable element : getPathVariableList()) { + for (org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair element : getPathVariableList()) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, element); } @@ -2644,7 +2733,7 @@ public final class JpsRemoteProto { if (other == org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.getDefaultInstance()) return this; if (!other.pathVariable_.isEmpty()) { if (result.pathVariable_.isEmpty()) { - result.pathVariable_ = new java.util.ArrayList(); + result.pathVariable_ = new java.util.ArrayList(); } result.pathVariable_.addAll(other.pathVariable_); } @@ -2676,7 +2765,7 @@ public final class JpsRemoteProto { break; } case 10: { - org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable.Builder subBuilder = org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable.newBuilder(); + org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair.Builder subBuilder = org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair.newBuilder(); input.readMessage(subBuilder, extensionRegistry); addPathVariable(subBuilder.buildPartial()); break; @@ -2696,48 +2785,48 @@ public final class JpsRemoteProto { } - // repeated .org.jetbrains.jpsservice.Message.Request.SetupCommand.PathVariable path_variable = 1; - public java.util.List getPathVariableList() { + // repeated .org.jetbrains.jpsservice.Message.KeyValuePair path_variable = 1; + public java.util.List getPathVariableList() { return java.util.Collections.unmodifiableList(result.pathVariable_); } public int getPathVariableCount() { return result.getPathVariableCount(); } - public org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable getPathVariable(int index) { + public org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair getPathVariable(int index) { return result.getPathVariable(index); } - public Builder setPathVariable(int index, org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable value) { + public Builder setPathVariable(int index, org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair value) { if (value == null) { throw new NullPointerException(); } result.pathVariable_.set(index, value); return this; } - public Builder setPathVariable(int index, org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable.Builder builderForValue) { + public Builder setPathVariable(int index, org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair.Builder builderForValue) { result.pathVariable_.set(index, builderForValue.build()); return this; } - public Builder addPathVariable(org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable value) { + public Builder addPathVariable(org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair value) { if (value == null) { throw new NullPointerException(); } if (result.pathVariable_.isEmpty()) { - result.pathVariable_ = new java.util.ArrayList(); + result.pathVariable_ = new java.util.ArrayList(); } result.pathVariable_.add(value); return this; } - public Builder addPathVariable(org.jetbrains.jps.api.JpsRemoteProto.Message.Request.SetupCommand.PathVariable.Builder builderForValue) { + public Builder addPathVariable(org.jetbrains.jps.api.JpsRemoteProto.Message.KeyValuePair.Builder builderForValue) { if (result.pathVariable_.isEmpty()) { - result.pathVariable_ = new java.util.ArrayList(); + result.pathVariable_ = new java.util.ArrayList(); } result.pathVariable_.add(builderForValue.build()); return this; } public Builder addAllPathVariable( - java.lang.Iterable values) { + java.lang.Iterable values) { if (result.pathVariable_.isEmpty()) { - result.pathVariable_ = new java.util.ArrayList(); + result.pathVariable_ = new java.util.ArrayList(); } super.addAll(values, result.pathVariable_); return this; diff --git a/jps/jps-builders/src/org/jetbrains/jps/api/ProtoUtil.java b/jps/jps-builders/src/org/jetbrains/jps/api/ProtoUtil.java index 5df797fd4519..b93378dddacb 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/api/ProtoUtil.java +++ b/jps/jps-builders/src/org/jetbrains/jps/api/ProtoUtil.java @@ -28,23 +28,34 @@ public class ProtoUtil { return builder.build(); } - public static JpsRemoteProto.Message.Request createMakeRequest(String project, Collection modules, Collection artifacts) { - return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.MAKE, project, modules, artifacts, Collections.emptyList()); + public static JpsRemoteProto.Message.Request createMakeRequest(String project, + Collection modules, + Collection artifacts, + final Map userData) { + return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.MAKE, project, modules, artifacts, + userData, Collections.emptyList()); } public static JpsRemoteProto.Message.Request createForceCompileRequest(String project, Collection modules, - Collection artifacts, Collection paths) { - return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.FORCED_COMPILATION, project, modules, artifacts, paths); + Collection artifacts, + Collection paths, + final Map userData) { + return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.FORCED_COMPILATION, project, modules, artifacts, + userData, paths); } - public static JpsRemoteProto.Message.Request createRebuildRequest(String project) { + public static JpsRemoteProto.Message.Request createRebuildRequest(String project, final Map userData) { return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.REBUILD, project, Collections.emptyList(), - Collections.emptyList(), Collections.emptyList()); + Collections.emptyList(), userData, Collections.emptyList()); } - public static JpsRemoteProto.Message.Request createCleanRequest(String project, Collection modules, Collection artifacts) { - return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.CLEAN, project, modules, artifacts, Collections.emptyList()); + public static JpsRemoteProto.Message.Request createCleanRequest(String project, + Collection modules, + Collection artifacts, + final Map userData) { + return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.CLEAN, project, modules, artifacts, + userData, Collections.emptyList()); } public static JpsRemoteProto.Message.Request createCancelRequest(UUID compileSessionId) { @@ -53,22 +64,34 @@ public class ProtoUtil { return JpsRemoteProto.Message.Request.newBuilder().setRequestType(JpsRemoteProto.Message.Request.Type.CANCEL_BUILD_COMMAND).setCancelBuildCommand(builder.build()).build(); } - public static JpsRemoteProto.Message.Request createCompileRequest(final JpsRemoteProto.Message.Request.CompilationRequest.Type command, String project, Collection modules, - Collection artifacts, Collection paths) { + public static JpsRemoteProto.Message.Request createCompileRequest( + final JpsRemoteProto.Message.Request.CompilationRequest.Type command, + String project, + Collection modules, + Collection artifacts, Map userData, Collection paths) { + final JpsRemoteProto.Message.Request.CompilationRequest.Builder builder = JpsRemoteProto.Message.Request.CompilationRequest.newBuilder().setCommandType( command); builder.setProjectId(project); - if (modules.size() > 0) { + if (!modules.isEmpty()) { builder.addAllModuleName(modules); } - if (artifacts.size() > 0) { + if (!artifacts.isEmpty()) { builder.addAllArtifactName(artifacts); } - if (paths.size() > 0) { + if (!userData.isEmpty()) { + for (Map.Entry entry : userData.entrySet()) { + final String key = entry.getKey(); + final String value = entry.getValue(); + if (key != null && value != null) { + builder.addBuilderParameter(createPair(key, value)); + } + } + } + if (!paths.isEmpty()) { builder.addAllFilePath(paths); } - return JpsRemoteProto.Message.Request.newBuilder().setRequestType(JpsRemoteProto.Message.Request.Type.COMPILE_REQUEST).setCompileRequest( - builder.build()).build(); + return JpsRemoteProto.Message.Request.newBuilder().setRequestType(JpsRemoteProto.Message.Request.Type.COMPILE_REQUEST).setCompileRequest(builder.build()).build(); } public static JpsRemoteProto.Message.Request createShutdownRequest(boolean cancelRunningBuilds) { @@ -101,9 +124,7 @@ public class ProtoUtil { final String var = entry.getKey(); final String value = entry.getValue(); if (var != null && value != null) { - final JpsRemoteProto.Message.Request.SetupCommand.PathVariable.Builder pathVarBuilder = - JpsRemoteProto.Message.Request.SetupCommand.PathVariable.newBuilder(); - cmdBuilder.addPathVariable(pathVarBuilder.setName(var).setValue(value).build()); + cmdBuilder.addPathVariable(createPair(var, value)); } } } @@ -131,6 +152,10 @@ public class ProtoUtil { return JpsRemoteProto.Message.Request.newBuilder().setRequestType(JpsRemoteProto.Message.Request.Type.SETUP_COMMAND).setSetupCommand(cmdBuilder.build()).build(); } + public static JpsRemoteProto.Message.KeyValuePair createPair(String key, String value) { + return JpsRemoteProto.Message.KeyValuePair.newBuilder().setKey(key).setValue(value).build(); + } + public static JpsRemoteProto.Message.Response createBuildStartedEvent(@Nullable String description) { return createBuildEvent(JpsRemoteProto.Message.Response.BuildEvent.Type.BUILD_STARTED, description, null, null); } diff --git a/jps/jps-builders/src/org/jetbrains/jps/client/CompileServerClient.java b/jps/jps-builders/src/org/jetbrains/jps/client/CompileServerClient.java index 139eaa703e74..49b2e2a9a1d3 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/client/CompileServerClient.java +++ b/jps/jps-builders/src/org/jetbrains/jps/client/CompileServerClient.java @@ -5,10 +5,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jps.api.*; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; /** * @author Eugene Zhuravlev @@ -28,18 +25,20 @@ public class CompileServerClient extends SimpleProtobufClient modules, final Collection artifacts, - Collection paths, JpsServerResponseHandler handler) throws Exception{ + Collection paths, + final Map userData, + JpsServerResponseHandler handler) throws Exception{ checkConnected(); final JpsRemoteProto.Message.Request request = isMake? - ProtoUtil.createMakeRequest(projectId, modules, artifacts) : - ProtoUtil.createForceCompileRequest(projectId, modules, artifacts, paths); + ProtoUtil.createMakeRequest(projectId, modules, artifacts, userData) : + ProtoUtil.createForceCompileRequest(projectId, modules, artifacts, paths, userData); return sendRequest(request, handler); } @NotNull public RequestFuture sendRebuildRequest(String projectId, JpsServerResponseHandler handler) throws Exception{ checkConnected(); - return sendRequest(ProtoUtil.createRebuildRequest(projectId), handler); + return sendRequest(ProtoUtil.createRebuildRequest(projectId, Collections.emptyMap()), handler); } @NotNull diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/CompileContext.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/CompileContext.java index d500daa21dc0..95a64bbeb63b 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/CompileContext.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/CompileContext.java @@ -41,6 +41,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler private volatile boolean myErrorsFound = false; private final long myCompilationStartStamp; private final TimestampStorage myTsStorage; + private final Map myBuilderParams; private final CanceledStatus myCancelStatus; private float myDone = -1.0f; @@ -49,8 +50,15 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler boolean isProjectRebuild, ProjectChunks productionChunks, ProjectChunks testChunks, - FSState fsState, final BuildDataManager dataManager, TimestampStorage tsStorage, MessageHandler delegateMessageHandler, final ModuleRootsIndex rootsIndex, CanceledStatus cancelStatus) throws ProjectBuildException { + FSState fsState, + final BuildDataManager dataManager, + TimestampStorage tsStorage, + MessageHandler delegateMessageHandler, + final ModuleRootsIndex rootsIndex, + Map builderParams, + CanceledStatus cancelStatus) throws ProjectBuildException { myTsStorage = tsStorage; + myBuilderParams = Collections.unmodifiableMap(builderParams); myCancelStatus = cancelStatus; myCompilationStartStamp = System.currentTimeMillis(); myScope = scope; @@ -82,6 +90,11 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler return myIsProjectRebuild; } + @Nullable + public String getBuilderParameter(String paramName) { + return myBuilderParams.get(paramName); + } + public void markDirty(final File file) throws IOException { final RootDescriptor descriptor = getModuleAndRoot(file); if (descriptor != null) { diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java index 97fc6b25399f..bfc942b296ae 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java @@ -37,6 +37,7 @@ public class IncProjectBuilder { private final ProjectDescriptor myProjectDescriptor; private final BuilderRegistry myBuilderRegistry; + private final Map myBuilderParams; private final CanceledStatus myCancelStatus; private ProjectChunks myProductionChunks; private ProjectChunks myTestChunks; @@ -53,9 +54,10 @@ public class IncProjectBuilder { private final float myTotalModulesWork; private final int myTotalModuleLevelBuilderCount; - public IncProjectBuilder(ProjectDescriptor pd, BuilderRegistry builderRegistry, CanceledStatus cs) { + public IncProjectBuilder(ProjectDescriptor pd, BuilderRegistry builderRegistry, Map builderParams, CanceledStatus cs) { myProjectDescriptor = pd; myBuilderRegistry = builderRegistry; + myBuilderParams = builderParams; myCancelStatus = cs; myProductionChunks = new ProjectChunks(pd.project, ClasspathKind.PRODUCTION_COMPILE); myTestChunks = new ProjectChunks(pd.project, ClasspathKind.TEST_COMPILE); @@ -182,8 +184,10 @@ public class IncProjectBuilder { final FSState fsState = myProjectDescriptor.fsState; final ModuleRootsIndex rootsIndex = myProjectDescriptor.rootsIndex; final BuildDataManager dataManager = myProjectDescriptor.dataManager; - return new CompileContext(scope, isMake, isProjectRebuild, myProductionChunks, myTestChunks, fsState, dataManager, tsStorage, - myMessageDispatcher, rootsIndex, myCancelStatus); + return new CompileContext( + scope, isMake, isProjectRebuild, myProductionChunks, myTestChunks, fsState, dataManager, tsStorage, myMessageDispatcher, rootsIndex, + myBuilderParams, myCancelStatus + ); } private void cleanOutputRoots(CompileContext context) throws ProjectBuildException { diff --git a/jps/jps-builders/src/org/jetbrains/jps/server/ServerMessageHandler.java b/jps/jps-builders/src/org/jetbrains/jps/server/ServerMessageHandler.java index 2dc966b51c51..bc3739d5ae61 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/server/ServerMessageHandler.java +++ b/jps/jps-builders/src/org/jetbrains/jps/server/ServerMessageHandler.java @@ -69,8 +69,8 @@ class ServerMessageHandler extends SimpleChannelHandler { case SETUP_COMMAND: final Map pathVars = new HashMap(); final JpsRemoteProto.Message.Request.SetupCommand setupCommand = request.getSetupCommand(); - for (JpsRemoteProto.Message.Request.SetupCommand.PathVariable variable : setupCommand.getPathVariableList()) { - pathVars.put(variable.getName(), variable.getValue()); + for (JpsRemoteProto.Message.KeyValuePair variable : setupCommand.getPathVariableList()) { + pathVars.put(variable.getKey(), variable.getValue()); } final List libs = new ArrayList(); for (JpsRemoteProto.Message.Request.SetupCommand.GlobalLibrary library : setupCommand.getGlobalLibraryList()) { @@ -187,8 +187,14 @@ class ServerMessageHandler extends SimpleChannelHandler { case REBUILD: { channelContext.setAttachment(sessionId); final BuildType buildType = convertCompileType(compileType); - final CompilationTask task = new CompilationTask(sessionId, channelContext, projectId, buildType, compileRequest.getModuleNameList(), - compileRequest.getArtifactNameList(), compileRequest.getFilePathList()); + final List modules = compileRequest.getModuleNameList(); + final List artifacts = compileRequest.getArtifactNameList(); + final List paths = compileRequest.getFilePathList(); + final Map builderParams = new HashMap(); + for (JpsRemoteProto.Message.KeyValuePair pair : compileRequest.getBuilderParameterList()) { + builderParams.put(pair.getKey(), pair.getValue()); + } + final CompilationTask task = new CompilationTask(sessionId, channelContext, projectId, buildType, modules, artifacts, builderParams, paths); final RunnableFuture future = getCompileTaskExecutor(projectId).submit(task); myBuildsInProgress.add(new Pair(future, task)); return null; @@ -230,6 +236,7 @@ class ServerMessageHandler extends SimpleChannelHandler { private final String myProjectPath; private final BuildType myBuildType; private final Collection myArtifacts; + private final Map myBuilderParams; private final Collection myPaths; private final Set myModules; private volatile boolean myCanceled = false; @@ -240,12 +247,13 @@ class ServerMessageHandler extends SimpleChannelHandler { BuildType buildType, Collection modules, Collection artifacts, - Collection paths) { + Map builderParams, Collection paths) { mySessionId = sessionId; myChannelContext = channelContext; myProjectPath = projectId; myBuildType = buildType; myArtifacts = artifacts; + myBuilderParams = builderParams; myPaths = paths; myModules = new HashSet(modules); } @@ -264,7 +272,7 @@ class ServerMessageHandler extends SimpleChannelHandler { final Ref hasErrors = new Ref(false); final Ref markedFilesUptodate = new Ref(false); try { - ServerState.getInstance().startBuild(myProjectPath, myBuildType, myModules, myArtifacts, myPaths, new MessageHandler() { + ServerState.getInstance().startBuild(myProjectPath, myBuildType, myModules, myArtifacts, myBuilderParams, myPaths, new MessageHandler() { public void processMessage(BuildMessage buildMessage) { final JpsRemoteProto.Message.Response response; if (buildMessage instanceof FileGeneratedEvent) { diff --git a/jps/jps-builders/src/org/jetbrains/jps/server/ServerState.java b/jps/jps-builders/src/org/jetbrains/jps/server/ServerState.java index d8b201ba316c..30b878bf2e76 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/server/ServerState.java +++ b/jps/jps-builders/src/org/jetbrains/jps/server/ServerState.java @@ -124,7 +124,7 @@ class ServerState { } public void startBuild(String projectPath, BuildType buildType, Set modules, Collection artifacts, - Collection paths, final MessageHandler msgHandler, CanceledStatus cs) throws Throwable{ + Map builderParams, Collection paths, final MessageHandler msgHandler, CanceledStatus cs) throws Throwable{ final String projectName = getProjectName(projectPath); @@ -167,7 +167,7 @@ class ServerState { try { final CompileScope compileScope = createCompilationScope(buildType, pd, modules, artifacts, paths); - final IncProjectBuilder builder = new IncProjectBuilder(pd, BuilderRegistry.getInstance(), cs); + final IncProjectBuilder builder = new IncProjectBuilder(pd, BuilderRegistry.getInstance(), builderParams, cs); if (msgHandler != null) { builder.addMessageHandler(msgHandler); } diff --git a/jps/jps-builders/testSrc/org/jetbrains/ether/IncrementalTestCase.java b/jps/jps-builders/testSrc/org/jetbrains/ether/IncrementalTestCase.java index 48ed13b9920e..549f4f5772ca 100644 --- a/jps/jps-builders/testSrc/org/jetbrains/ether/IncrementalTestCase.java +++ b/jps/jps-builders/testSrc/org/jetbrains/ether/IncrementalTestCase.java @@ -325,7 +325,7 @@ public abstract class IncrementalTestCase extends TestCase { try { new IncProjectBuilder( - projectDescriptor, BuilderRegistry.getInstance(), CanceledStatus.NULL + projectDescriptor, BuilderRegistry.getInstance(), Collections.emptyMap(), CanceledStatus.NULL ).build( new AllProjectScope(project, Collections.emptySet(), true), false, true ); @@ -337,7 +337,7 @@ public abstract class IncrementalTestCase extends TestCase { } new IncProjectBuilder( - projectDescriptor, BuilderRegistry.getInstance(), CanceledStatus.NULL + projectDescriptor, BuilderRegistry.getInstance(), Collections.emptyMap(), CanceledStatus.NULL ).build( new AllProjectScope(project, Collections.emptySet(), false), true, false );