mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
external system aware make build notifications rework
This commit is contained in:
committed by
Vladislav.Soroka
parent
4a97c1643b
commit
8ec6d38717
@@ -19,17 +19,16 @@ import com.intellij.history.LocalHistory;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.build.BuildContext;
|
||||
import com.intellij.openapi.build.BuildStatusNotification;
|
||||
import com.intellij.openapi.build.BuildStatusNotificationAdapter;
|
||||
import com.intellij.openapi.build.BuildSystemManager;
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
public class CompileProjectAction extends CompileActionBase {
|
||||
protected void doAction(DataContext dataContext, final Project project) {
|
||||
BuildSystemManager.getInstance(project).rebuildProject(new BuildStatusNotification() {
|
||||
BuildSystemManager.getInstance(project).rebuildProject(new BuildStatusNotificationAdapter() {
|
||||
@Override
|
||||
public void finished(boolean aborted, int errors, int warnings, BuildContext buildContext) {
|
||||
public void finished(boolean aborted, int errors, int warnings) {
|
||||
if (aborted || project.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.intellij.util.containers.ContainerUtil.list;
|
||||
@@ -116,10 +118,29 @@ public class BuildSystemManagerImpl extends BuildSystemManager {
|
||||
return myDefaultBuildSystemDriver;
|
||||
}));
|
||||
|
||||
AtomicInteger inProgressCounter = new AtomicInteger(toBuild.size());
|
||||
AtomicInteger errorsCounter = new AtomicInteger();
|
||||
AtomicInteger warningsCounter = new AtomicInteger();
|
||||
AtomicBoolean abortedFlag = new AtomicBoolean(false);
|
||||
for (Map.Entry<BuildSystemDriver, ? extends List<? extends BuildTarget>> entry : toBuild.entrySet()) {
|
||||
BuildSystemDriver driver = entry.getKey();
|
||||
BuildScope buildScope = toBuild.size() == 1 ? scope : new BuildScopeImpl(entry.getValue(), scope.getSessionId());
|
||||
driver.build(new BuildContextImpl(myProject, buildScope, isIncrementalBuild), callback);
|
||||
BuildChunkStatusNotification chunkStatusNotification = callback == null ? null : new BuildChunkStatusNotification() {
|
||||
@Override
|
||||
public void finished(boolean aborted, int errors, int warnings, BuildContext buildContext) {
|
||||
int inProgress = inProgressCounter.decrementAndGet();
|
||||
int allErrors = errorsCounter.addAndGet(errors);
|
||||
int allWarnings = warningsCounter.addAndGet(warnings);
|
||||
if(aborted){
|
||||
abortedFlag.set(true);
|
||||
}
|
||||
callback.chunkFinished(aborted, errors, warnings, inProgress, buildContext);
|
||||
if (inProgress == 0) {
|
||||
callback.finished(abortedFlag.get(), allErrors, allWarnings);
|
||||
}
|
||||
}
|
||||
};
|
||||
driver.build(new BuildContextImpl(myProject, buildScope, isIncrementalBuild), chunkStatusNotification);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ import java.util.stream.Stream;
|
||||
*/
|
||||
public class DefaultBuildSystemDriver extends BuildSystemDriver {
|
||||
@Override
|
||||
public void build(@NotNull BuildContext buildContext, @Nullable BuildStatusNotification callback) {
|
||||
public void build(@NotNull BuildContext buildContext, @Nullable BuildChunkStatusNotification callback) {
|
||||
CompileStatusNotification compileNotification =
|
||||
callback == null ? null : (aborted, errors, warnings, compileContext) -> callback.finished(aborted, errors, warnings, buildContext);
|
||||
if (buildContext.getScope() instanceof ProjectBuildScope) {
|
||||
|
||||
+2
-3
@@ -176,12 +176,11 @@ public class BuildArtifactsBeforeRunTaskProvider extends BeforeRunTaskProvider<B
|
||||
}
|
||||
}.execute();
|
||||
|
||||
final BuildStatusNotification callback = new BuildStatusNotification() {
|
||||
final BuildStatusNotification callback = new BuildStatusNotificationAdapter() {
|
||||
@Override
|
||||
public void finished(boolean aborted,
|
||||
int errors,
|
||||
int warnings,
|
||||
BuildContext buildContext) {
|
||||
int warnings) {
|
||||
result.set(!aborted && errors == 0);
|
||||
finished.up();
|
||||
}
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.build;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 4/29/2016
|
||||
*/
|
||||
public interface BuildChunkStatusNotification {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param aborted true if the build chunk has been cancelled.
|
||||
* @param errors error count
|
||||
* @param warnings warning count
|
||||
* @param buildContext context for the build chunk
|
||||
*/
|
||||
void finished(boolean aborted, int errors, int warnings, final BuildContext buildContext);
|
||||
}
|
||||
@@ -20,12 +20,21 @@ package com.intellij.openapi.build;
|
||||
* @since 4/29/2016
|
||||
*/
|
||||
public interface BuildStatusNotification {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param aborted true if the build has been cancelled.
|
||||
* @param aborted true if the at least one build chunk has been cancelled.
|
||||
* @param errors error count
|
||||
* @param warnings warning count
|
||||
* @param buildContext context for the build
|
||||
*/
|
||||
void finished(boolean aborted, int errors, int warnings, final BuildContext buildContext);
|
||||
void finished(boolean aborted, int errors, int warnings);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param aborted true if the build chunk has been cancelled.
|
||||
* @param errors error count
|
||||
* @param warnings warning count
|
||||
* @param inProgress not finished build chunks count
|
||||
* @param buildContext context for the build chunk
|
||||
*/
|
||||
void chunkFinished(boolean aborted, int errors, int warnings, int inProgress, final BuildContext buildContext);
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.build;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/12/2016
|
||||
*/
|
||||
public class BuildStatusNotificationAdapter implements BuildStatusNotification {
|
||||
@Override
|
||||
public void finished(boolean aborted, int errors, int warnings) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chunkFinished(boolean aborted, int errors, int warnings, int inProgress, BuildContext buildContext) {
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public abstract class BuildSystemDriver {
|
||||
|
||||
public static final ExtensionPointName<BuildSystemDriver> EP_NAME = ExtensionPointName.create("com.intellij.buildSystemDriver");
|
||||
|
||||
public abstract void build(@NotNull BuildContext buildContext, @Nullable BuildStatusNotification callback);
|
||||
public abstract void build(@NotNull BuildContext buildContext, @Nullable BuildChunkStatusNotification callback);
|
||||
|
||||
public abstract boolean canBuild(@NotNull BuildTarget buildTarget);
|
||||
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class GradleBuildSystemDriver extends BuildSystemDriver {
|
||||
@Override
|
||||
public void build(@NotNull BuildContext buildContext, @Nullable BuildStatusNotification buildCallback) {
|
||||
public void build(@NotNull BuildContext buildContext, @Nullable BuildChunkStatusNotification buildCallback) {
|
||||
String executionName = null;
|
||||
if (buildContext.getScope() instanceof ProjectBuildScope) {
|
||||
executionName = buildContext.isIncrementalBuild() ? "Make" : "Rebuild";
|
||||
|
||||
Reference in New Issue
Block a user