org.jetbrains.idea.maven.model.MavenExplicitProfiles Java Examples

The following examples show how to use org.jetbrains.idea.maven.model.MavenExplicitProfiles. 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: MavenImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
protected void readProjects(List<VirtualFile> files, String... profiles) {
  myProjectsManager.resetManagedFilesAndProfilesInTests(files, new MavenExplicitProfiles(Arrays.asList(profiles)));
  waitForReadingCompletion();
}
 
Example #2
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;
}