mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
transfer artifact names to compile server
This commit is contained in:
@@ -271,9 +271,8 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
if (!config.useCompileServer() || !config.MAKE_PROJECT_ON_SAVE) {
|
||||
continue;
|
||||
}
|
||||
final RequestFuture future = submitCompilationTask(
|
||||
project, false, true, Collections.<String>emptyList(), Collections.<String>emptyList(), new AutoMakeResponseHandler(project)
|
||||
);
|
||||
final RequestFuture future = submitCompilationTask(project, false, true, Collections.<String>emptyList(), Collections.<String>emptyList(),
|
||||
Collections.<String>emptyList(), new AutoMakeResponseHandler(project));
|
||||
if (future != null) {
|
||||
futures.add(future);
|
||||
synchronized (myAutomakeFutures) {
|
||||
@@ -311,7 +310,9 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public RequestFuture submitCompilationTask(final Project project, final boolean isRebuild, final boolean isMake, final Collection<String> modules, final Collection<String> paths, final JpsServerResponseHandler handler) {
|
||||
public RequestFuture submitCompilationTask(final Project project, final boolean isRebuild, final boolean isMake,
|
||||
final Collection<String> modules, final Collection<String> artifacts,
|
||||
final Collection<String> paths, final JpsServerResponseHandler handler) {
|
||||
final String projectId = project.getLocation();
|
||||
final Ref<RequestFuture> futureRef = new Ref<RequestFuture>(null);
|
||||
final RunnableFuture future = myTaskExecutor.submit(new Runnable() {
|
||||
@@ -321,7 +322,7 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
if (client != null) {
|
||||
final RequestFuture requestFuture = isRebuild ?
|
||||
client.sendRebuildRequest(projectId, handler) :
|
||||
client.sendCompileRequest(isMake, projectId, modules, paths, handler);
|
||||
client.sendCompileRequest(isMake, projectId, modules, artifacts, paths, handler);
|
||||
futureRef.set(requestFuture);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -414,19 +414,25 @@ public class CompileDriver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RequestFuture compileOnServer(final CompileContextImpl compileContext, Collection<Module> modules, final Collection<String> paths, @Nullable final CompileStatusNotification callback)
|
||||
private RequestFuture compileOnServer(final @NotNull CompileContextImpl compileContext, @NotNull Collection<Module> modules, @NotNull Collection<Artifact> artifacts,
|
||||
final @NotNull Collection<String> paths, @Nullable final CompileStatusNotification callback)
|
||||
throws Exception {
|
||||
Collection<String> moduleNames = Collections.emptyList();
|
||||
if (modules != null && modules.size() > 0) {
|
||||
if (modules.size() > 0) {
|
||||
moduleNames = new ArrayList<String>(modules.size());
|
||||
for (Module module : modules) {
|
||||
moduleNames.add(module.getName());
|
||||
}
|
||||
}
|
||||
List<String> artifactNames = new ArrayList<String>();
|
||||
for (Artifact artifact : artifacts) {
|
||||
artifactNames.add(artifact.getName());
|
||||
}
|
||||
|
||||
final CompileServerManager csManager = CompileServerManager.getInstance();
|
||||
final MessageBus messageBus = myProject.getMessageBus();
|
||||
csManager.cancelAutoMakeTasks(myProject);
|
||||
return csManager.submitCompilationTask(myProject, compileContext.isRebuild(), compileContext.isMake(), moduleNames, paths, new JpsServerResponseHandler() {
|
||||
return csManager.submitCompilationTask(myProject, compileContext.isRebuild(), compileContext.isMake(), moduleNames, artifactNames, paths, new JpsServerResponseHandler() {
|
||||
|
||||
@Override
|
||||
public void handleCompileMessage(JpsRemoteProto.Message.Response.CompileMessage compilerMessage) {
|
||||
@@ -584,7 +590,8 @@ public class CompileDriver {
|
||||
}
|
||||
final Collection<String> paths = fetchFiles(compileContext);
|
||||
final List<Module> modules = paths.isEmpty()? Arrays.asList(compileContext.getCompileScope().getAffectedModules()) : Collections.<Module>emptyList();
|
||||
final RequestFuture future = compileOnServer(compileContext, modules, paths, callback);
|
||||
final Set<Artifact> artifacts = ArtifactCompileScope.getArtifactsToBuild(myProject, compileContext.getCompileScope(), true);
|
||||
final RequestFuture future = compileOnServer(compileContext, modules, artifacts, paths, callback);
|
||||
if (future != null) {
|
||||
try {
|
||||
startCancelWatcher(indicator, future);
|
||||
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
protoc -I=. --java_out=../src javac_remote_proto.proto
|
||||
protoc -I=. --java_out=../src jps_remote_proto.proto
|
||||
@@ -43,6 +43,7 @@ message Message {
|
||||
optional string project_id = 2;
|
||||
repeated string module_name = 3;
|
||||
repeated string file_path = 4;
|
||||
repeated string artifact_name = 5;
|
||||
}
|
||||
|
||||
message ShutdownCommand {
|
||||
|
||||
@@ -857,6 +857,18 @@ public final class JpsRemoteProto {
|
||||
return filePath_.get(index);
|
||||
}
|
||||
|
||||
// repeated string artifact_name = 5;
|
||||
public static final int ARTIFACT_NAME_FIELD_NUMBER = 5;
|
||||
private java.util.List<java.lang.String> artifactName_ =
|
||||
java.util.Collections.emptyList();
|
||||
public java.util.List<java.lang.String> getArtifactNameList() {
|
||||
return artifactName_;
|
||||
}
|
||||
public int getArtifactNameCount() { return artifactName_.size(); }
|
||||
public java.lang.String getArtifactName(int index) {
|
||||
return artifactName_.get(index);
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
commandType_ = org.jetbrains.jps.api.JpsRemoteProto.Message.Request.CompilationRequest.Type.REBUILD;
|
||||
}
|
||||
@@ -880,6 +892,9 @@ public final class JpsRemoteProto {
|
||||
for (java.lang.String element : getFilePathList()) {
|
||||
output.writeString(4, element);
|
||||
}
|
||||
for (java.lang.String element : getArtifactNameList()) {
|
||||
output.writeString(5, element);
|
||||
}
|
||||
}
|
||||
|
||||
private int memoizedSerializedSize = -1;
|
||||
@@ -914,6 +929,15 @@ public final class JpsRemoteProto {
|
||||
size += dataSize;
|
||||
size += 1 * getFilePathList().size();
|
||||
}
|
||||
{
|
||||
int dataSize = 0;
|
||||
for (java.lang.String element : getArtifactNameList()) {
|
||||
dataSize += com.google.protobuf.CodedOutputStream
|
||||
.computeStringSizeNoTag(element);
|
||||
}
|
||||
size += dataSize;
|
||||
size += 1 * getArtifactNameList().size();
|
||||
}
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
}
|
||||
@@ -1059,6 +1083,10 @@ public final class JpsRemoteProto {
|
||||
result.filePath_ =
|
||||
java.util.Collections.unmodifiableList(result.filePath_);
|
||||
}
|
||||
if (result.artifactName_ != java.util.Collections.EMPTY_LIST) {
|
||||
result.artifactName_ =
|
||||
java.util.Collections.unmodifiableList(result.artifactName_);
|
||||
}
|
||||
org.jetbrains.jps.api.JpsRemoteProto.Message.Request.CompilationRequest returnMe = result;
|
||||
result = null;
|
||||
return returnMe;
|
||||
@@ -1084,6 +1112,12 @@ public final class JpsRemoteProto {
|
||||
}
|
||||
result.filePath_.addAll(other.filePath_);
|
||||
}
|
||||
if (!other.artifactName_.isEmpty()) {
|
||||
if (result.artifactName_.isEmpty()) {
|
||||
result.artifactName_ = new java.util.ArrayList<java.lang.String>();
|
||||
}
|
||||
result.artifactName_.addAll(other.artifactName_);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1122,6 +1156,10 @@ public final class JpsRemoteProto {
|
||||
addFilePath(input.readString());
|
||||
break;
|
||||
}
|
||||
case 42: {
|
||||
addArtifactName(input.readString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1249,6 +1287,46 @@ public final class JpsRemoteProto {
|
||||
return this;
|
||||
}
|
||||
|
||||
// repeated string artifact_name = 5;
|
||||
public java.util.List<java.lang.String> getArtifactNameList() {
|
||||
return java.util.Collections.unmodifiableList(result.artifactName_);
|
||||
}
|
||||
public int getArtifactNameCount() {
|
||||
return result.getArtifactNameCount();
|
||||
}
|
||||
public java.lang.String getArtifactName(int index) {
|
||||
return result.getArtifactName(index);
|
||||
}
|
||||
public Builder setArtifactName(int index, java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
result.artifactName_.set(index, value);
|
||||
return this;
|
||||
}
|
||||
public Builder addArtifactName(java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (result.artifactName_.isEmpty()) {
|
||||
result.artifactName_ = new java.util.ArrayList<java.lang.String>();
|
||||
}
|
||||
result.artifactName_.add(value);
|
||||
return this;
|
||||
}
|
||||
public Builder addAllArtifactName(
|
||||
java.lang.Iterable<? extends java.lang.String> values) {
|
||||
if (result.artifactName_.isEmpty()) {
|
||||
result.artifactName_ = new java.util.ArrayList<java.lang.String>();
|
||||
}
|
||||
super.addAll(values, result.artifactName_);
|
||||
return this;
|
||||
}
|
||||
public Builder clearArtifactName() {
|
||||
result.artifactName_ = java.util.Collections.emptyList();
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.jpsservice.Message.Request.CompilationRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -28,20 +28,23 @@ public class ProtoUtil {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static JpsRemoteProto.Message.Request createMakeRequest(String project, Collection<String> modules) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.MAKE, project, modules, Collections.<String>emptyList());
|
||||
public static JpsRemoteProto.Message.Request createMakeRequest(String project, Collection<String> modules, Collection<String> artifacts) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.MAKE, project, modules, artifacts, Collections.<String>emptyList());
|
||||
}
|
||||
|
||||
public static JpsRemoteProto.Message.Request createForceCompileRequest(String project, Collection<String> modules, Collection<String> paths) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.FORCED_COMPILATION, project, modules, paths);
|
||||
public static JpsRemoteProto.Message.Request createForceCompileRequest(String project,
|
||||
Collection<String> modules,
|
||||
Collection<String> artifacts, Collection<String> paths) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.FORCED_COMPILATION, project, modules, artifacts, paths);
|
||||
}
|
||||
|
||||
public static JpsRemoteProto.Message.Request createRebuildRequest(String project) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.REBUILD, project, Collections.<String>emptyList(), Collections.<String>emptyList());
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.REBUILD, project, Collections.<String>emptyList(),
|
||||
Collections.<String>emptyList(), Collections.<String>emptyList());
|
||||
}
|
||||
|
||||
public static JpsRemoteProto.Message.Request createCleanRequest(String project, Collection<String> modules) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.CLEAN, project, modules, Collections.<String>emptyList());
|
||||
public static JpsRemoteProto.Message.Request createCleanRequest(String project, Collection<String> modules, Collection<String> artifacts) {
|
||||
return createCompileRequest(JpsRemoteProto.Message.Request.CompilationRequest.Type.CLEAN, project, modules, artifacts, Collections.<String>emptyList());
|
||||
}
|
||||
|
||||
public static JpsRemoteProto.Message.Request createCancelRequest(UUID compileSessionId) {
|
||||
@@ -50,13 +53,17 @@ 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<String> modules, Collection<String> paths) {
|
||||
public static JpsRemoteProto.Message.Request createCompileRequest(final JpsRemoteProto.Message.Request.CompilationRequest.Type command, String project, Collection<String> modules,
|
||||
Collection<String> artifacts, Collection<String> paths) {
|
||||
final JpsRemoteProto.Message.Request.CompilationRequest.Builder builder = JpsRemoteProto.Message.Request.CompilationRequest.newBuilder().setCommandType(
|
||||
command);
|
||||
builder.setProjectId(project);
|
||||
if (modules.size() > 0) {
|
||||
builder.addAllModuleName(modules);
|
||||
}
|
||||
if (artifacts.size() > 0) {
|
||||
builder.addAllArtifactName(artifacts);
|
||||
}
|
||||
if (paths.size() > 0) {
|
||||
builder.addAllFilePath(paths);
|
||||
}
|
||||
|
||||
@@ -27,11 +27,12 @@ public class CompileServerClient extends SimpleProtobufClient<JpsServerResponseH
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public RequestFuture sendCompileRequest(boolean isMake, String projectId, Collection<String> modules, Collection<String> paths, JpsServerResponseHandler handler) throws Exception{
|
||||
public RequestFuture sendCompileRequest(boolean isMake, String projectId, Collection<String> modules, final Collection<String> artifacts,
|
||||
Collection<String> paths, JpsServerResponseHandler handler) throws Exception{
|
||||
checkConnected();
|
||||
final JpsRemoteProto.Message.Request request = isMake?
|
||||
ProtoUtil.createMakeRequest(projectId, modules) :
|
||||
ProtoUtil.createForceCompileRequest(projectId, modules, paths);
|
||||
ProtoUtil.createMakeRequest(projectId, modules, artifacts) :
|
||||
ProtoUtil.createForceCompileRequest(projectId, modules, artifacts, paths);
|
||||
return sendRequest(request, handler);
|
||||
}
|
||||
|
||||
|
||||
+21
-11
@@ -2,6 +2,7 @@ package org.jetbrains.jps.incremental.artifacts;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.Project;
|
||||
import org.jetbrains.jps.ProjectPaths;
|
||||
import org.jetbrains.jps.artifacts.Artifact;
|
||||
@@ -37,13 +38,13 @@ public class ArtifactSourceFilesState {
|
||||
public ArtifactSourceFilesState(Artifact artifact, int artifactId, Project project,
|
||||
ModuleRootsIndex rootsIndex,
|
||||
ArtifactSourceTimestampStorage timestampStorage,
|
||||
File artifactsDataDir) {
|
||||
File mappingsDir) {
|
||||
myProject = project;
|
||||
myArtifact = artifact;
|
||||
myRootsIndex = rootsIndex;
|
||||
myTimestampStorage = timestampStorage;
|
||||
myArtifactId = artifactId;
|
||||
myMappingsFile = new File(artifactsDataDir, "mappings" + File.separator + artifactId);
|
||||
myMappingsFile = new File(mappingsDir, String.valueOf(artifactId));
|
||||
}
|
||||
|
||||
public ArtifactSourceToOutputMapping getOrCreateMapping() throws Exception {
|
||||
@@ -161,20 +162,29 @@ public class ArtifactSourceFilesState {
|
||||
}
|
||||
for (String filePath : changedFiles) {
|
||||
final ArtifactSourceTimestampStorage.PerArtifactTimestamp[] state = myTimestampStorage.getState(filePath);
|
||||
if (state == null) continue;
|
||||
for (int i = 0, length = state.length; i < length; i++) {
|
||||
if (state[i].myArtifactId == myArtifactId) {
|
||||
File file = new File(FileUtil.toSystemDependentName(filePath));
|
||||
state[i] = new ArtifactSourceTimestampStorage.PerArtifactTimestamp(myArtifactId, file.lastModified());
|
||||
myTimestampStorage.update(filePath, state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
File file = new File(FileUtil.toSystemDependentName(filePath));
|
||||
final long timestamp = file.lastModified();
|
||||
myTimestampStorage.update(filePath, updateTimestamp(state, timestamp));
|
||||
}
|
||||
myDeletedFiles.clear();
|
||||
myChangedFiles.clear();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ArtifactSourceTimestampStorage.PerArtifactTimestamp[] updateTimestamp(ArtifactSourceTimestampStorage.PerArtifactTimestamp[] oldState, long timestamp) {
|
||||
final ArtifactSourceTimestampStorage.PerArtifactTimestamp newItem = new ArtifactSourceTimestampStorage.PerArtifactTimestamp(myArtifactId, timestamp);
|
||||
if (oldState == null) {
|
||||
return new ArtifactSourceTimestampStorage.PerArtifactTimestamp[]{newItem};
|
||||
}
|
||||
for (int i = 0, length = oldState.length; i < length; i++) {
|
||||
if (oldState[i].myArtifactId == myArtifactId) {
|
||||
oldState[i] = newItem;
|
||||
return oldState;
|
||||
}
|
||||
}
|
||||
return ArrayUtil.append(oldState, newItem);
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
if (myMapping != null) {
|
||||
myMapping.close();
|
||||
|
||||
+5
-2
@@ -18,19 +18,21 @@ public class ArtifactsBuildData {
|
||||
private final ArtifactSourceTimestampStorage myTimestampStorage;
|
||||
private ArtifactCompilerPersistentData myPersistentData;
|
||||
private final File myArtifactsDataDir;
|
||||
private final File myMappingsDir;
|
||||
|
||||
public ArtifactsBuildData(File artifactsDataDir) throws Exception {
|
||||
myArtifactsDataDir = artifactsDataDir;
|
||||
myTimestampStorage = new ArtifactSourceTimestampStorage(new File(artifactsDataDir, "timestamps"));
|
||||
myArtifactState = new HashMap<Artifact, ArtifactSourceFilesState>();
|
||||
myPersistentData = new ArtifactCompilerPersistentData(artifactsDataDir);
|
||||
myMappingsDir = new File(myArtifactsDataDir, "mappings");
|
||||
}
|
||||
|
||||
public ArtifactSourceFilesState getOrCreateState(Artifact artifact, Project project, ModuleRootsIndex index) {
|
||||
ArtifactSourceFilesState state = myArtifactState.get(artifact);
|
||||
if (state == null) {
|
||||
final int artifactId = myPersistentData.getId(artifact.getName());
|
||||
state = new ArtifactSourceFilesState(artifact, artifactId, project, index, myTimestampStorage, myArtifactsDataDir);
|
||||
state = new ArtifactSourceFilesState(artifact, artifactId, project, index, myTimestampStorage, myMappingsDir);
|
||||
myArtifactState.put(artifact, state);
|
||||
}
|
||||
return state;
|
||||
@@ -42,7 +44,8 @@ public class ArtifactsBuildData {
|
||||
for (ArtifactSourceFilesState state : myArtifactState.values()) {
|
||||
state.clean();
|
||||
}
|
||||
FileUtil.delete(myArtifactsDataDir);
|
||||
myArtifactState.clear();
|
||||
FileUtil.delete(myMappingsDir);
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
|
||||
@@ -187,8 +187,8 @@ 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(), Collections.<String>emptySet(), compileRequest.getFilePathList());
|
||||
final CompilationTask task = new CompilationTask(sessionId, channelContext, projectId, buildType, compileRequest.getModuleNameList(),
|
||||
compileRequest.getArtifactNameList(), compileRequest.getFilePathList());
|
||||
final RunnableFuture future = getCompileTaskExecutor(projectId).submit(task);
|
||||
myBuildsInProgress.add(new Pair<RunnableFuture, CompilationTask>(future, task));
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user