use of org.jetbrains.idea.maven.model.MavenExplicitProfiles in project intellij-community by JetBrains.
the class MavenBeforeRunTasksProvider method executeTask.
public boolean executeTask(final DataContext context, RunConfiguration configuration, ExecutionEnvironment env, final MavenBeforeRunTask task) {
final Semaphore targetDone = new Semaphore();
final boolean[] result = new boolean[] { true };
try {
ApplicationManager.getApplication().invokeAndWait(() -> {
final Project project = CommonDataKeys.PROJECT.getData(context);
final MavenProject mavenProject = getMavenProject(task);
if (project == null || project.isDisposed() || mavenProject == null)
return;
FileDocumentManager.getInstance().saveAllDocuments();
final MavenExplicitProfiles explicitProfiles = MavenProjectsManager.getInstance(project).getExplicitProfiles();
final MavenRunner mavenRunner = MavenRunner.getInstance(project);
targetDone.down();
new Task.Backgroundable(project, TasksBundle.message("maven.tasks.executing"), true) {
public void run(@NotNull ProgressIndicator indicator) {
try {
MavenRunnerParameters params = new MavenRunnerParameters(true, mavenProject.getDirectory(), ParametersListUtil.parse(task.getGoal()), explicitProfiles.getEnabledProfiles(), explicitProfiles.getDisabledProfiles());
result[0] = mavenRunner.runBatch(Collections.singletonList(params), null, null, TasksBundle.message("maven.tasks.executing"), indicator);
} finally {
targetDone.up();
}
}
@Override
public boolean shouldStartInBackground() {
return MavenRunner.getInstance(project).getSettings().isRunMavenInBackground();
}
@Override
public void processSentToBackground() {
MavenRunner.getInstance(project).getSettings().setRunMavenInBackground(true);
}
}.queue();
}, ModalityState.NON_MODAL);
} catch (Exception e) {
MavenLog.LOG.error(e);
return false;
}
targetDone.waitFor();
return result[0];
}
use of org.jetbrains.idea.maven.model.MavenExplicitProfiles in project intellij-community by JetBrains.
the class MavenTasksManager method doExecute.
private boolean doExecute(boolean before, CompileContext context) {
List<MavenRunnerParameters> parametersList;
synchronized (this) {
parametersList = new ArrayList<>();
Set<MavenCompilerTask> tasks = before ? myState.beforeCompileTasks : myState.afterCompileTasks;
if (context.isRebuild()) {
tasks = Sets.union(before ? myState.beforeRebuildTask : myState.afterRebuildTask, tasks);
}
for (MavenCompilerTask each : tasks) {
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(each.getProjectPath());
if (file == null)
continue;
MavenExplicitProfiles explicitProfiles = myProjectsManager.getExplicitProfiles();
parametersList.add(new MavenRunnerParameters(true, file.getParent().getPath(), Arrays.asList(each.getGoal()), explicitProfiles.getEnabledProfiles(), explicitProfiles.getDisabledProfiles()));
}
}
return myRunner.runBatch(parametersList, null, null, TasksBundle.message("maven.tasks.executing"), context.getProgressIndicator());
}
use of org.jetbrains.idea.maven.model.MavenExplicitProfiles in project intellij-community by JetBrains.
the class RunBuildAction method checkOrPerform.
private static boolean checkOrPerform(DataContext context, boolean perform) {
final List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
if (goals == null || goals.isEmpty())
return false;
final Project project = MavenActionUtil.getProject(context);
if (project == null)
return false;
final MavenProject mavenProject = MavenActionUtil.getMavenProject(context);
if (mavenProject == null)
return false;
if (!perform)
return true;
final MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
if (projectsManager == null)
return false;
MavenExplicitProfiles explicitProfiles = projectsManager.getExplicitProfiles();
final MavenRunnerParameters params = new MavenRunnerParameters(true, mavenProject.getDirectory(), goals, explicitProfiles.getEnabledProfiles(), explicitProfiles.getDisabledProfiles());
MavenRunConfigurationType.runConfiguration(project, params, null);
return true;
}
use of org.jetbrains.idea.maven.model.MavenExplicitProfiles in project intellij-community by JetBrains.
the class ToggleProfileAction method getTargetState.
@Nullable
private static MavenProfileKind getTargetState(@NotNull MavenProjectsManager projectsManager, Map<String, MavenProfileKind> profiles) {
MavenExplicitProfiles explicitProfiles = projectsManager.getExplicitProfiles();
MavenProfileKind targetState = null;
// all profiles should target to the same state
for (Map.Entry<String, MavenProfileKind> profile : profiles.entrySet()) {
MavenProfileKind profileTargetState = getTargetState(profile, explicitProfiles);
if (targetState == null) {
targetState = profileTargetState;
} else if (!targetState.equals(profileTargetState)) {
targetState = null;
break;
}
}
return targetState;
}
use of org.jetbrains.idea.maven.model.MavenExplicitProfiles in project liferay-ide by liferay.
the class AbstractLiferayMavenGoalAction method checkOrPerform.
public boolean checkOrPerform(DataContext context, boolean perform) {
Project project = MavenActionUtil.getProject(context);
MavenProject mavenProject = MavenActionUtil.getMavenProject(context);
if ((project == null) || (mavenProject == null)) {
return false;
}
if (!perform) {
return true;
}
String projectDir = mavenProject.getDirectory();
MavenProjectsManager mavenProjectsManager = MavenActionUtil.getProjectsManager(context);
MavenExplicitProfiles explicitProfiles = mavenProjectsManager.getExplicitProfiles();
Collection<String> enabledProfiles = explicitProfiles.getEnabledProfiles();
Collection<String> disabledProfiles = explicitProfiles.getDisabledProfiles();
MavenRunnerParameters params = new MavenRunnerParameters(true, projectDir, goals, enabledProfiles, disabledProfiles);
MavenRunConfigurationType.runConfiguration(project, params, null);
return true;
}
Aggregations