use of com.intellij.execution.BeforeRunTask in project google-cloud-intellij by GoogleCloudPlatform.
the class BuildDeploymentSourceType method setBuildBeforeRunTask.
/**
* Creates a pre-deploy task ({@link BeforeRunTask}) for the given build-system and attaches it to
* this module deployment source type. Invoked when a new deployment configuration is created.
*
* <p>Provides the common functionality for creating the build-system packaging task, delegating
* build-system specific functions to the concrete sub-types.
*
* <p>Only creates a new task if one is not already configured.
*/
@Override
public void setBuildBeforeRunTask(@NotNull RunConfiguration configuration, @NotNull ModuleDeploymentSource source) {
Module module = source.getModule();
if (module == null) {
return;
}
setConfiguration(configuration);
RunManagerEx runManager = RunManagerEx.getInstanceEx(configuration.getProject());
final Collection<? extends BeforeRunTask> buildTasks = getBuildTasks(runManager, configuration);
if (!hasBuildTaskForModule(buildTasks, module)) {
BeforeRunTask buildTask = createBuildTask(module);
if (buildTask != null) {
List<BeforeRunTask> tasks = runManager.getBeforeRunTasks(configuration);
ImmutableList<BeforeRunTask> newTaskList = ImmutableList.<BeforeRunTask>builder().addAll(tasks).add(buildTask).build();
runManager.setBeforeRunTasks(configuration, newTaskList, true);
}
}
}
use of com.intellij.execution.BeforeRunTask in project google-cloud-intellij by GoogleCloudPlatform.
the class BuildDeploymentSourceType method updateBuildBeforeRunOption.
/**
* Updates the pre-deploy build tasks ({@link BeforeRunTask}) when the deployment source is
* updated.
*
* <p>Similar to {@link BuildDeploymentSourceType#setBuildBeforeRunTask(RunConfiguration,
* ModuleDeploymentSource)}, but it is invoked when switching between deployment sources in the
* UI.
*
* <p>Only creates a new task if one is not already configured. In following the IntelliJ pattern
* used for bundled deployment sources, this does NOT remove any existing tasks.
*/
@Override
public void updateBuildBeforeRunOption(@NotNull JComponent runConfigurationEditorComponent, @NotNull Project project, @NotNull ModuleDeploymentSource source, boolean select) {
final DataContext dataContext = DataManager.getInstance().getDataContext(runConfigurationEditorComponent);
final ConfigurationSettingsEditorWrapper editor = ConfigurationSettingsEditorWrapper.CONFIGURATION_EDITOR_KEY.getData(dataContext);
Module module = source.getModule();
if (module == null || editor == null) {
return;
}
List<BeforeRunTask> buildTasks = editor.getStepsBeforeLaunch();
if (select && !hasBuildTaskForModule(buildTasks, module)) {
BeforeRunTask buildTask = createBuildTask(module);
if (buildTask != null) {
editor.addBeforeLaunchStep(buildTask);
}
}
}
use of com.intellij.execution.BeforeRunTask in project azure-tools-for-java by microsoft.
the class DeployFunctionAppAction method actionPerformed.
@Override
protected void actionPerformed(final NodeActionEvent nodeActionEvent) throws AzureCmdException {
final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
final RunnerAndConfigurationSettings settings = getRunConfigurationSettings(manager);
if (RunDialog.editConfiguration(project, settings, message("function.deploy.configuration.title"), DefaultRunExecutor.getRunExecutorInstance())) {
final List<BeforeRunTask> tasks = new ArrayList<>(manager.getBeforeRunTasks(settings.getConfiguration()));
manager.addConfiguration(settings, false, tasks, false);
manager.setSelectedConfiguration(settings);
ProgramRunnerUtil.executeConfiguration(project, settings, DefaultRunExecutor.getRunExecutorInstance());
}
}
use of com.intellij.execution.BeforeRunTask in project azure-tools-for-java by microsoft.
the class DeployFunctionAction method runConfiguration.
private void runConfiguration(Module module) {
// todo: investigate when will module be null
if (module == null) {
return;
}
final Project project = module.getProject();
final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
final ConfigurationFactory factory = new FunctionDeploymentConfigurationFactory(configType);
final RunnerAndConfigurationSettings settings = RunConfigurationUtils.getOrCreateRunConfigurationSettings(module, manager, factory);
if (RunDialog.editConfiguration(project, settings, message("function.deploy.configuration.title"), DefaultRunExecutor.getRunExecutorInstance())) {
final List<BeforeRunTask> tasks = new ArrayList<>(manager.getBeforeRunTasks(settings.getConfiguration()));
manager.addConfiguration(settings, false, tasks, false);
manager.setSelectedConfiguration(settings);
ProgramRunnerUtil.executeConfiguration(project, settings, DefaultRunExecutor.getRunExecutorInstance());
}
}
use of com.intellij.execution.BeforeRunTask in project azure-tools-for-java by microsoft.
the class RunFunctionAction method runConfiguration.
private void runConfiguration(Module module) {
// todo: investigate when will module be null
if (module == null) {
return;
}
final Project project = module.getProject();
final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
final ConfigurationFactory factory = new FunctionRunConfigurationFactory(configType);
final RunnerAndConfigurationSettings settings = RunConfigurationUtils.getOrCreateRunConfigurationSettings(module, manager, factory);
if (RunDialog.editConfiguration(project, settings, message("function.run.configuration.title"), DefaultRunExecutor.getRunExecutorInstance())) {
final List<BeforeRunTask> tasks = new ArrayList<>(manager.getBeforeRunTasks(settings.getConfiguration()));
manager.addConfiguration(settings, false, tasks, false);
manager.setSelectedConfiguration(settings);
ProgramRunnerUtil.executeConfiguration(project, settings, DefaultRunExecutor.getRunExecutorInstance());
}
}
Aggregations