update copyright
[fedora-idea.git] / plugins / maven / src / main / java / org / jetbrains / idea / maven / project / actions / RunBuildAction.java
blob8bbbd4185570a1fd29ddd20dde9a62a4d85197ef
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.jetbrains.idea.maven.project.actions;
18 import com.intellij.execution.ExecutionException;
19 import com.intellij.openapi.actionSystem.AnActionEvent;
20 import org.jetbrains.idea.maven.execution.MavenRunConfigurationType;
21 import org.jetbrains.idea.maven.execution.MavenRunnerParameters;
22 import org.jetbrains.idea.maven.utils.actions.MavenAction;
23 import org.jetbrains.idea.maven.utils.actions.MavenActionUtil;
24 import org.jetbrains.idea.maven.utils.MavenDataKeys;
25 import org.jetbrains.idea.maven.utils.MavenLog;
26 import org.jetbrains.idea.maven.project.MavenProject;
28 import java.util.List;
30 public class RunBuildAction extends MavenAction {
31 @Override
32 protected boolean isAvailable(AnActionEvent e) {
33 return super.isAvailable(e) && checkOrPerform(e, false);
36 @Override
37 public void actionPerformed(AnActionEvent e) {
38 checkOrPerform(e, true);
41 private boolean checkOrPerform(AnActionEvent e, boolean perform) {
42 MavenProject project = MavenActionUtil.getMavenProject(e);
43 if (project == null) return false;
45 List<String> goals = e.getData(MavenDataKeys.MAVEN_GOALS);
46 if (goals == null || goals.isEmpty()) return false;
48 if (!perform) return true;
50 try {
51 MavenRunnerParameters params = new MavenRunnerParameters(
52 true, project.getDirectory(), goals, MavenActionUtil.getProjectsManager(e).getActiveProfiles());
53 MavenRunConfigurationType.runConfiguration(MavenActionUtil.getProject(e), params, e.getDataContext());
55 catch (ExecutionException ex) {
56 MavenLog.LOG.warn(ex);
59 return true;