org.jetbrains.idea.maven.execution.MavenRunnerParameters Java Examples

The following examples show how to use org.jetbrains.idea.maven.execution.MavenRunnerParameters. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RunTestFileAction.java    From MavenHelper with Apache License 2.0 6 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
	MavenProject mavenProject = MavenActionUtil.getMavenProject(e.getDataContext());
	if (mavenProject != null) {

		PsiFile psiFile = LangDataKeys.PSI_FILE.getData(e.getDataContext());
		if (psiFile instanceof PsiClassOwner) {
			List<String> goals = getGoals(e, (PsiClassOwner) psiFile,
					MavenActionUtil.getMavenProject(e.getDataContext()));

			final DataContext context = e.getDataContext();
			MavenRunnerParameters params = new MavenRunnerParameters(true, mavenProject.getDirectory(), null, goals,
					MavenActionUtil.getProjectsManager(context).getExplicitProfiles());
			run(context, params);
		} else {
			Messages.showWarningDialog(e.getProject(), "Cannot run for current file", "Maven Test File");
		}
	}
}
 
Example #2
Source File: MavenImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
protected void executeGoal(String relativePath, String goal) {
  VirtualFile dir = myProjectRoot.findFileByRelativePath(relativePath);

  MavenRunnerParameters rp = new MavenRunnerParameters(true, dir.getPath(), (String)null, Arrays.asList(goal), Collections.emptyList());
  MavenRunnerSettings rs = new MavenRunnerSettings();
  MavenExecutor e = new MavenExternalExecutor(myProject, rp, getMavenGeneralSettings(), rs, new SoutMavenConsole());

  e.execute(new EmptyProgressIndicator());
}
 
Example #3
Source File: MavenDebugConfigurationType.java    From MavenHelper with Apache License 2.0 5 votes vote down vote up
public static void debugConfiguration(Project project, @NotNull MavenRunnerParameters params,
		@Nullable MavenGeneralSettings settings, @Nullable MavenRunnerSettings runnerSettings,
		@Nullable ProgramRunner.Callback callback) {

	RunnerAndConfigurationSettings configSettings = MavenRunConfigurationType.createRunnerAndConfigurationSettings(
			settings, runnerSettings, params, project);
	final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();

	debugConfiguration(project, callback, configSettings, executor);
}
 
Example #4
Source File: RunGoalAction.java    From MavenHelper with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(Project project, String pomDir, MavenProjectsManager projectsManager, PsiFile psiFile, ConfigurationContext configurationContext) {
	if (pomDir != null) {
		List<String> goalsToRun = goal.parse(psiFile, configurationContext);
		MavenRunnerParameters params = new MavenRunnerParameters(true, pomDir, null, goalsToRun, projectsManager.getExplicitProfiles());
		params.setResolveToWorkspace(ApplicationSettings.get().isResolveWorkspaceArtifacts());
		run(params, project);
	}
}
 
Example #5
Source File: MuleBeforeRunTasksProvider.java    From mule-intellij-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public boolean executeTask(DataContext dataContext, RunConfiguration runConfiguration, ExecutionEnvironment executionEnvironment, MuleBeforeRunTask muleBeforeRunTask)
{
    final Semaphore targetDone = new Semaphore();
    final List<Boolean> results = new ArrayList<>();

    final Project project = executionEnvironment.getProject();

    MuleConfiguration muleConfiguration = (MuleConfiguration) runConfiguration;

    Module[] modules = muleConfiguration.getModules();

    for (Module nextModule : modules) {
        //final MavenProject mavenProject = getMavenProject(runConfiguration, project);
        final MavenProject mavenProject = getMavenProject(nextModule);
        try {
            ApplicationManager.getApplication().invokeAndWait(new Runnable() {
                public void run() {
                    if (!project.isDisposed() && mavenProject != null) {
                        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("package"), explicitProfiles.getEnabledProfiles(),
                                                    explicitProfiles.getDisabledProfiles());
                                    boolean result = mavenRunner.runBatch(Collections.singletonList(params), null, null, TasksBundle.message("maven.tasks.executing"), indicator);
                                    results.add(result);
                                } finally {
                                    targetDone.up();
                                }
                            }

                            public boolean shouldStartInBackground() {
                                return MavenRunner.getInstance(project).getSettings().isRunMavenInBackground();
                            }

                            public void processSentToBackground() {
                                MavenRunner.getInstance(project).getSettings().setRunMavenInBackground(true);
                            }
                        }).queue();
                    }
                }
            }, ModalityState.NON_MODAL);
        } catch (Exception exeception) {
            return false;
        }
        targetDone.waitFor();
    }

    boolean endResult = true;

    for (Boolean nextResult : results) {
        endResult = endResult && nextResult;
    }

    return endResult;
}
 
Example #6
Source File: MavenDebugConfigurationType.java    From MavenHelper with Apache License 2.0 4 votes vote down vote up
public static void debugConfiguration(Project project, MavenRunnerParameters params,
		@Nullable ProgramRunner.Callback callback) {
	debugConfiguration(project, params, null, null, callback);
}
 
Example #7
Source File: DebugTestFileAction.java    From MavenHelper with Apache License 2.0 4 votes vote down vote up
@Override
protected void run(final DataContext context, final MavenRunnerParameters params) {
	runInternal(MavenActionUtil.getProject(context), params);
}
 
Example #8
Source File: DebugTestFileAction.java    From MavenHelper with Apache License 2.0 4 votes vote down vote up
private void runInternal(final Project project, final MavenRunnerParameters params) {
	MavenDebugConfigurationType.debugConfiguration(project, params, null);
}
 
Example #9
Source File: DebugGoalAction.java    From MavenHelper with Apache License 2.0 4 votes vote down vote up
@Override
protected void run(final MavenRunnerParameters params, Project project) {
	params.getGoals().addAll(Debug.DEBUG_FORK_MODE);
	runInternal(project, params);
}
 
Example #10
Source File: DebugGoalAction.java    From MavenHelper with Apache License 2.0 4 votes vote down vote up
private void runInternal(final Project project, final MavenRunnerParameters params) {
	MavenDebugConfigurationType.debugConfiguration(project, params, null);
}
 
Example #11
Source File: RunTestFileAction.java    From MavenHelper with Apache License 2.0 4 votes vote down vote up
protected void run(DataContext context, MavenRunnerParameters params) {
	MavenRunConfigurationType.runConfiguration(MavenActionUtil.getProject(context), params, null);
}
 
Example #12
Source File: RunGoalAction.java    From MavenHelper with Apache License 2.0 4 votes vote down vote up
protected void run(MavenRunnerParameters params, Project project) {
	MavenRunConfigurationType.runConfiguration(project, params, null);
}