use of com.intellij.execution.BeforeRunTask in project azure-tools-for-java by microsoft.
the class BeforeRunTaskUtils method addTask.
private static synchronized <T extends BeforeRunTask<?>> void addTask(@Nonnull ConfigurationSettingsEditorWrapper editor, List<? extends T> tasks, T task, RunConfiguration config) {
if (tasks.isEmpty()) {
task.setEnabled(true);
final RunManagerEx manager = RunManagerEx.getInstanceEx(config.getProject());
final List<BeforeRunTask> tasksFromConfig = new ArrayList<>(manager.getBeforeRunTasks(config));
// need to add the before run task back to runConfiguration since for the create scenario:
// the before run task editor will reset tasks in runConfiguration, that's the reason why
// here we need to add the task here
tasksFromConfig.add(task);
manager.setBeforeRunTasks(config, tasksFromConfig);
editor.addBeforeLaunchStep(task);
} else {
for (final T t : tasks) {
t.setEnabled(true);
}
}
}
use of com.intellij.execution.BeforeRunTask in project azure-tools-for-java by microsoft.
the class MavenRunTaskUtil method addMavenPackageBeforeRunTask.
/**
* Add Maven package goal into the run configuration's before run task.
*/
public static void addMavenPackageBeforeRunTask(RunConfiguration runConfiguration) {
final RunManagerEx manager = RunManagerEx.getInstanceEx(runConfiguration.getProject());
if (isMavenProject(runConfiguration.getProject())) {
List<BeforeRunTask> tasks = new ArrayList<>(manager.getBeforeRunTasks(runConfiguration));
if (MavenRunTaskUtil.shouldAddMavenPackageTask(tasks, runConfiguration.getProject())) {
MavenBeforeRunTask task = new MavenBeforeRunTask();
task.setEnabled(true);
task.setProjectPath(runConfiguration.getProject().getBasePath() + File.separator + MavenConstants.POM_XML);
task.setGoal(MAVEN_TASK_PACKAGE);
tasks.add(task);
manager.setBeforeRunTasks(runConfiguration, tasks);
}
}
}
use of com.intellij.execution.BeforeRunTask in project azure-tools-for-java by microsoft.
the class MavenRunTaskUtil method shouldAddMavenPackageTask.
/**
* Legacy code, will be replaced by BeforeRunTaskUtils
* @deprecated
*/
@Deprecated
private static boolean shouldAddMavenPackageTask(List<BeforeRunTask> tasks, Project project) {
boolean shouldAdd = true;
for (BeforeRunTask task : tasks) {
if (task.getProviderId().equals(MavenBeforeRunTasksProvider.ID)) {
MavenBeforeRunTask mavenTask = (MavenBeforeRunTask) task;
if (mavenTask.getGoal().contains(MAVEN_TASK_PACKAGE) && Comparing.equal(mavenTask.getProjectPath(), project.getBasePath() + File.separator + MavenConstants.POM_XML)) {
mavenTask.setEnabled(true);
shouldAdd = false;
break;
}
}
}
return shouldAdd;
}
use of com.intellij.execution.BeforeRunTask in project azure-tools-for-java by microsoft.
the class DeployWebAppAction 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("webapp.deploy.configuration.title"), DefaultRunExecutor.getRunExecutorInstance())) {
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 WebDeployAction method runConfiguration.
@SuppressWarnings("deprecation")
@AzureOperation(name = "webapp.deploy_module", params = { "module.getName()" }, type = AzureOperation.Type.ACTION)
private void runConfiguration(Module module) {
Project project = module.getProject();
final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
final ConfigurationFactory factory = configType.getWebAppConfigurationFactory();
RunnerAndConfigurationSettings settings = manager.findConfigurationByName(String.format("%s: %s:%s", factory.getName(), project.getName(), module.getName()));
if (settings == null) {
settings = manager.createConfiguration(String.format("%s: %s:%s", factory.getName(), project.getName(), module.getName()), factory);
}
if (RunDialog.editConfiguration(project, settings, message("webapp.deploy.configuration.title"), DefaultRunExecutor.getRunExecutorInstance())) {
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