Search in sources :

Example 16 with MavenExplicitProfiles

use of org.jetbrains.idea.maven.model.MavenExplicitProfiles in project intellij-community by JetBrains.

the class MavenProjectsManagerTest method testSavingAndLoadingState.

public void testSavingAndLoadingState() throws Exception {
    MavenProjectsManagerState state = myProjectsManager.getState();
    assertTrue(state.originalFiles.isEmpty());
    assertTrue(MavenWorkspaceSettingsComponent.getInstance(myProject).getSettings().enabledProfiles.isEmpty());
    assertTrue(state.ignoredFiles.isEmpty());
    assertTrue(state.ignoredPathMasks.isEmpty());
    VirtualFile p1 = createModulePom("project1", "<groupId>test</groupId>" + "<artifactId>project1</artifactId>" + "<version>1</version>");
    VirtualFile p2 = createModulePom("project2", "<groupId>test</groupId>" + "<artifactId>project2</artifactId>" + "<version>1</version>" + "<packaging>pom</packaging>" + "<modules>" + "  <module>../project3</module>" + "</modules>");
    VirtualFile p3 = createModulePom("project3", "<groupId>test</groupId>" + "<artifactId>project3</artifactId>" + "<version>1</version>");
    importProjects(p1, p2);
    myProjectsManager.setExplicitProfiles(new MavenExplicitProfiles(Arrays.asList("one", "two")));
    myProjectsManager.setIgnoredFilesPaths(Arrays.asList(p1.getPath()));
    myProjectsManager.setIgnoredFilesPatterns(Arrays.asList("*.xxx"));
    state = myProjectsManager.getState();
    assertUnorderedPathsAreEqual(state.originalFiles, Arrays.asList(p1.getPath(), p2.getPath()));
    assertUnorderedElementsAreEqual(MavenWorkspaceSettingsComponent.getInstance(myProject).getState().enabledProfiles, "one", "two");
    assertUnorderedPathsAreEqual(state.ignoredFiles, Arrays.asList(p1.getPath()));
    assertUnorderedElementsAreEqual(state.ignoredPathMasks, "*.xxx");
    MavenProjectsManagerState newState = new MavenProjectsManagerState();
    newState.originalFiles = Arrays.asList(p1.getPath(), p3.getPath());
    MavenWorkspaceSettingsComponent.getInstance(myProject).getSettings().setEnabledProfiles(Arrays.asList("three"));
    newState.ignoredFiles = Collections.singleton(p1.getPath());
    newState.ignoredPathMasks = Arrays.asList("*.zzz");
    myProjectsManager.loadState(newState);
    assertUnorderedPathsAreEqual(myProjectsManager.getProjectsTreeForTests().getManagedFilesPaths(), Arrays.asList(p1.getPath(), p3.getPath()));
    assertUnorderedElementsAreEqual(myProjectsManager.getExplicitProfiles().getEnabledProfiles(), "three");
    assertUnorderedPathsAreEqual(myProjectsManager.getIgnoredFilesPaths(), Arrays.asList(p1.getPath()));
    assertUnorderedElementsAreEqual(myProjectsManager.getIgnoredFilesPatterns(), "*.zzz");
    waitForReadingCompletion();
    assertUnorderedElementsAreEqual(myProjectsManager.getProjectsTreeForTests().getRootProjectsFiles(), p1, p3);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenExplicitProfiles(org.jetbrains.idea.maven.model.MavenExplicitProfiles)

Example 17 with MavenExplicitProfiles

use of org.jetbrains.idea.maven.model.MavenExplicitProfiles in project intellij-community by JetBrains.

the class MavenConfigurationProducer method createBuildParameters.

private static MavenRunnerParameters createBuildParameters(Location l) {
    if (!(l instanceof MavenGoalLocation))
        return null;
    VirtualFile f = ((PsiFile) l.getPsiElement()).getVirtualFile();
    List<String> goals = ((MavenGoalLocation) l).getGoals();
    MavenExplicitProfiles profiles = MavenProjectsManager.getInstance(l.getProject()).getExplicitProfiles();
    return new MavenRunnerParameters(true, f.getParent().getPath(), goals, profiles.getEnabledProfiles(), profiles.getDisabledProfiles());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenExplicitProfiles(org.jetbrains.idea.maven.model.MavenExplicitProfiles) PsiFile(com.intellij.psi.PsiFile)

Example 18 with MavenExplicitProfiles

use of org.jetbrains.idea.maven.model.MavenExplicitProfiles in project intellij-community by JetBrains.

the class MavenProjectsTreeTestCase method updateAll.

protected void updateAll(List<String> profiles, VirtualFile... files) throws MavenProcessCanceledException {
    myTree.resetManagedFilesAndProfiles(asList(files), new MavenExplicitProfiles(profiles));
    myTree.updateAll(false, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS);
}
Also used : MavenExplicitProfiles(org.jetbrains.idea.maven.model.MavenExplicitProfiles)

Example 19 with MavenExplicitProfiles

use of org.jetbrains.idea.maven.model.MavenExplicitProfiles in project kotlin by JetBrains.

the class MavenImportingTestCase method readProjects.

protected void readProjects(List<VirtualFile> files, String... profiles) {
    myProjectsManager.resetManagedFilesAndProfilesInTests(files, new MavenExplicitProfiles(Arrays.asList(profiles)));
    waitForReadingCompletion();
}
Also used : MavenExplicitProfiles(org.jetbrains.idea.maven.model.MavenExplicitProfiles)

Example 20 with MavenExplicitProfiles

use of org.jetbrains.idea.maven.model.MavenExplicitProfiles in project azure-tools-for-java by Microsoft.

the class MavenUtils method evaluateEffectivePom.

public static String evaluateEffectivePom(@NotNull Project ideaProject, @NotNull MavenProject mavenProject) throws MavenProcessCanceledException {
    final MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(ideaProject);
    final MavenEmbeddersManager embeddersManager = projectsManager.getEmbeddersManager();
    final MavenExplicitProfiles profiles = mavenProject.getActivatedProfilesIds();
    final MavenEmbedderWrapper embedder = embeddersManager.getEmbedder(mavenProject, MavenEmbeddersManager.FOR_DEPENDENCIES_RESOLVE);
    embedder.clearCachesFor(mavenProject.getMavenId());
    return embedder.evaluateEffectivePom(mavenProject.getFile(), profiles.getEnabledProfiles(), profiles.getDisabledProfiles());
}
Also used : MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenExplicitProfiles(org.jetbrains.idea.maven.model.MavenExplicitProfiles) MavenEmbeddersManager(org.jetbrains.idea.maven.project.MavenEmbeddersManager) MavenEmbedderWrapper(org.jetbrains.idea.maven.server.MavenEmbedderWrapper)

Aggregations

MavenExplicitProfiles (org.jetbrains.idea.maven.model.MavenExplicitProfiles)20 MavenRunnerParameters (org.jetbrains.idea.maven.execution.MavenRunnerParameters)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 MavenProjectsManager (org.jetbrains.idea.maven.project.MavenProjectsManager)4 Project (com.intellij.openapi.project.Project)3 MavenProfileKind (org.jetbrains.idea.maven.model.MavenProfileKind)3 MavenProject (org.jetbrains.idea.maven.project.MavenProject)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Semaphore (com.intellij.util.concurrency.Semaphore)2 NotNull (org.jetbrains.annotations.NotNull)2 MavenEmbedderWrapper (org.jetbrains.idea.maven.server.MavenEmbedderWrapper)2 IdeModifiableModelsProviderImpl (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)1 IdeUIModifiableModelsProvider (com.intellij.openapi.externalSystem.service.project.IdeUIModifiableModelsProvider)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 Task (com.intellij.openapi.progress.Task)1 IgnoredFileBean (com.intellij.openapi.vcs.changes.IgnoredFileBean)1 PsiFile (com.intellij.psi.PsiFile)1 IOException (java.io.IOException)1 Map (java.util.Map)1 Nullable (org.jetbrains.annotations.Nullable)1