IDEA-90936 Force project make option before launch in run configuration
authorVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Fri, 28 Nov 2014 14:48:44 +0000 (17:48 +0300)
committerVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Fri, 28 Nov 2014 14:50:03 +0000 (17:50 +0300)
java/execution/impl/src/com/intellij/compiler/options/CompileStepBeforeRun.java
java/execution/impl/src/com/intellij/compiler/options/MakeProjectStepBeforeRun.java [new file with mode: 0644]
platform/platform-resources-en/src/messages/ExecutionBundle.properties
resources/src/idea/RichPlatformPlugin.xml

index 124220d7596656cf0b4e196cd8fa31abbd56c107..b0d878f9bea9a0eaa451f651456421c00b60aa12 100644 (file)
@@ -102,7 +102,11 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
     return doMake(myProject, configuration, env, false);
   }
 
-   static boolean doMake(final Project myProject, final RunConfiguration configuration, final ExecutionEnvironment env, final boolean ignoreErrors) {
+  static boolean doMake(final Project myProject, final RunConfiguration configuration, final ExecutionEnvironment env, final boolean ignoreErrors) {
+    return doMake(myProject, configuration, env, ignoreErrors, Boolean.getBoolean(MAKE_PROJECT_ON_RUN_KEY));
+  }
+
+  static boolean doMake(final Project myProject, final RunConfiguration configuration, final ExecutionEnvironment env, final boolean ignoreErrors, final boolean forceMakeProject) {
     if (!(configuration instanceof RunProfileWithCompileBeforeLaunchOption)) {
       return true;
     }
@@ -130,7 +134,7 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
         public void run() {
           CompileScope scope;
           final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
-          if (Boolean.valueOf(System.getProperty(MAKE_PROJECT_ON_RUN_KEY, Boolean.FALSE.toString())).booleanValue()) {
+          if (forceMakeProject) {
             // user explicitly requested whole-project make
             scope = compilerManager.createProjectCompileScope(myProject);
           }
diff --git a/java/execution/impl/src/com/intellij/compiler/options/MakeProjectStepBeforeRun.java b/java/execution/impl/src/com/intellij/compiler/options/MakeProjectStepBeforeRun.java
new file mode 100644 (file)
index 0000000..8cf2b70
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2000-2014 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.compiler.options;
+
+import com.intellij.execution.BeforeRunTask;
+import com.intellij.execution.BeforeRunTaskProvider;
+import com.intellij.execution.ExecutionBundle;
+import com.intellij.execution.configurations.RunConfiguration;
+import com.intellij.execution.configurations.RunProfileWithCompileBeforeLaunchOption;
+import com.intellij.execution.remote.RemoteConfiguration;
+import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.compiler.CompileContext;
+import com.intellij.openapi.compiler.CompileScope;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Key;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+public class MakeProjectStepBeforeRun extends BeforeRunTaskProvider<MakeProjectStepBeforeRun.MakeProjectBeforeRunTask> {
+  public static final Key<MakeProjectBeforeRunTask> ID = Key.create("MakeProject");
+
+  private final Project myProject;
+
+  public MakeProjectStepBeforeRun(@NotNull Project project) {
+    myProject = project;
+  }
+
+  @Override
+  public Key<MakeProjectBeforeRunTask> getId() {
+    return ID;
+  }
+
+  @Override
+  public String getName() {
+    return ExecutionBundle.message("before.launch.make.project.step");
+  }
+
+  @Override
+  public String getDescription(MakeProjectBeforeRunTask task) {
+    return getName();
+  }
+  @Override
+  public Icon getIcon() {
+    return AllIcons.Actions.Compile;
+  }
+
+  @Override
+  public Icon getTaskIcon(MakeProjectBeforeRunTask task) {
+    return AllIcons.Actions.Compile;
+  }
+
+  public boolean configureTask(RunConfiguration runConfiguration, MakeProjectBeforeRunTask task) {
+    return false;
+  }
+
+  @Override
+  public boolean canExecuteTask(RunConfiguration configuration, MakeProjectBeforeRunTask task) {
+    return true;
+  }
+
+  public boolean executeTask(DataContext context, final RunConfiguration configuration, final ExecutionEnvironment env, MakeProjectBeforeRunTask task) {
+    return CompileStepBeforeRun.doMake(myProject, configuration, env, false, true);
+  }
+
+  public boolean isConfigurable() {
+    return false;
+  }
+
+  @Nullable
+  public static RunConfiguration getRunConfiguration(final CompileContext context) {
+    return getRunConfiguration(context.getCompileScope());
+  }
+
+  @Nullable
+  public static RunConfiguration getRunConfiguration(final CompileScope compileScope) {
+    return compileScope.getUserData(CompileStepBeforeRun.RUN_CONFIGURATION);
+  }
+
+
+  public MakeProjectBeforeRunTask createTask(RunConfiguration runConfiguration) {
+    return !(runConfiguration instanceof RemoteConfiguration) && runConfiguration instanceof RunProfileWithCompileBeforeLaunchOption
+           ? new MakeProjectBeforeRunTask()
+           : null;
+  }
+
+  public static class MakeProjectBeforeRunTask extends BeforeRunTask<MakeProjectBeforeRunTask> {
+    public MakeProjectBeforeRunTask() {
+      super(ID);
+    }
+  }
+}
index a98190c6a75188b6671468f32443f8b92ac1fdbe..b2f05abc66bd6ef805ccd0c87eccea0738c0687a 100644 (file)
@@ -323,6 +323,7 @@ configuration.action.chooser.title=Choose configuration type to run
 env.vars.checkbox.title=&Include parent environment variables
 
 before.launch.compile.step=Make
+before.launch.make.project.step=Make Project
 before.launch.compile.step.no.error.check=Make, no error check
 execute.before.run.debug.dialog.title=Execute {0} Before Run/Debug
 
index c125b2a5f651f255f24a2708e89db05dacd9a43f..67a2f01437ac07f382aaca6280060aa8a7a63912 100644 (file)
 
 
     <stepsBeforeRunProvider implementation="com.intellij.compiler.options.CompileStepBeforeRun" id="compileBeforeRun"/>
+    <stepsBeforeRunProvider implementation="com.intellij.compiler.options.MakeProjectStepBeforeRun" id="makeProjectBeforeRun"/>
     <stepsBeforeRunProvider implementation="com.intellij.compiler.options.CompileStepBeforeRunNoErrorCheck" id="compileBeforeRunNoErrorCheck" order="after compileBeforeRun"/>
     <stepsBeforeRunProvider implementation="com.intellij.packaging.impl.run.BuildArtifactsBeforeRunTaskProvider" order="after compileBeforeRunNoErrorCheck"/>
     <programRunner id="defaultRunRunner" implementation="com.intellij.execution.impl.DefaultJavaProgramRunner"/>