Maven: correct activated profiles discovering
authorAnton Makeev <Anton.Makeev@jetbrains.com>
Thu, 8 Jul 2010 08:59:03 +0000 (12:59 +0400)
committerAnton Makeev <Anton.Makeev@jetbrains.com>
Thu, 8 Jul 2010 09:03:26 +0000 (13:03 +0400)
15 files changed:
plugins/maven/facade-api/src/org/jetbrains/idea/maven/facade/MavenWrapperExecutionResult.java
plugins/maven/facade-api/src/org/jetbrains/idea/maven/facade/ProfileApplicationResult.java
plugins/maven/facade-impl/lib/maven-embedder-1.0-SNAPSHOT.jar [deleted file]
plugins/maven/facade-impl/lib/maven-embedder-1.1-SNAPSHOT.jar [new file with mode: 0644]
plugins/maven/facade-impl/maven-facade-impl.iml
plugins/maven/facade-impl/src/org/jetbrains/idea/maven/facade/embedder/MavenFacadeEmbedderImpl.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomProjectProcessorUtils.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPropertyResolver.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProject.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectReader.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectReaderResult.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenNotManagedProjectInspectionsTest.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectReaderTest.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeReadingTest.java

index c382aa546dc5dfae06c64ce71784c7c47ab055f1..b5fdc9c08a0eac42310e850ad2f6b47da3685716 100644 (file)
@@ -44,12 +44,12 @@ public class MavenWrapperExecutionResult implements Serializable {
     public final MavenModel mavenModel;
     public final Map<String, String> mavenModelMap;
     public final NativeMavenProjectHolder nativeMavenProject;
-    public final Collection<MavenProfile> activatedProfiles;
+    public final Collection<String> activatedProfiles;
 
     public ProjectData(MavenModel mavenModel,
                        Map<String, String> mavenModelMap,
                        NativeMavenProjectHolder nativeMavenProject,
-                       Collection<MavenProfile> activatedProfiles) {
+                       Collection<String> activatedProfiles) {
       this.mavenModel = mavenModel;
       this.mavenModelMap = mavenModelMap;
       this.nativeMavenProject = nativeMavenProject;
index 8297c26cebba25e8ca02db45bb1700ce60ad6475..ba4bdf7b17e435c34847f6d843b5f098233aaeb6 100644 (file)
@@ -19,13 +19,14 @@ import org.jetbrains.idea.maven.model.MavenModel;
 import org.jetbrains.idea.maven.model.MavenProfile;
 
 import java.io.Serializable;
+import java.util.Collection;
 import java.util.List;
 
 public class ProfileApplicationResult implements Serializable {
   private final MavenModel myModel;
-  private final List<MavenProfile> myActivatedProfiles;
+  private final Collection<String> myActivatedProfiles;
 
-  public ProfileApplicationResult(MavenModel model, List<MavenProfile> activatedProfiles) {
+  public ProfileApplicationResult(MavenModel model, Collection<String> activatedProfiles) {
     myModel = model;
     myActivatedProfiles = activatedProfiles;
   }
@@ -34,7 +35,7 @@ public class ProfileApplicationResult implements Serializable {
     return myModel;
   }
 
-  public List<MavenProfile> getActivatedProfiles() {
+  public Collection<String> getActivatedProfiles() {
     return myActivatedProfiles;
   }
 }
diff --git a/plugins/maven/facade-impl/lib/maven-embedder-1.0-SNAPSHOT.jar b/plugins/maven/facade-impl/lib/maven-embedder-1.0-SNAPSHOT.jar
deleted file mode 100644 (file)
index 259be18..0000000
Binary files a/plugins/maven/facade-impl/lib/maven-embedder-1.0-SNAPSHOT.jar and /dev/null differ
diff --git a/plugins/maven/facade-impl/lib/maven-embedder-1.1-SNAPSHOT.jar b/plugins/maven/facade-impl/lib/maven-embedder-1.1-SNAPSHOT.jar
new file mode 100644 (file)
index 0000000..a03a706
Binary files /dev/null and b/plugins/maven/facade-impl/lib/maven-embedder-1.1-SNAPSHOT.jar differ
index 91d9782323119850418b4e052606314a1d3e5a00..d8c62e2dbc4a8dffa510db4df93813fa87972f68 100644 (file)
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/lib/maven-embedder-1.0-SNAPSHOT.jar!/" />
+          <root url="jar://$MODULE_DIR$/lib/maven-embedder-1.1-SNAPSHOT.jar!/" />
         </CLASSES>
         <JAVADOC />
-        <SOURCES />
+        <SOURCES>
+          <root url="file://$MODULE_DIR$/../../../../../maven/idea-embedder/src/main/java" />
+        </SOURCES>
       </library>
     </orderEntry>
     <orderEntry type="module-library">
index dbfbcb4e05b91c66f68cfd28ffe84d62737f9e75..93d1ef49386e62d95f0053ab8d1a8d3197553f2b 100644 (file)
@@ -159,8 +159,6 @@ public class MavenFacadeEmbedderImpl extends RemoteObject implements MavenFacade
                                                         mavenProject.getExtensionArtifacts(),
                                                         getLocalRepositoryFile());
 
-    Collection<MavenProfile> activatedProfiles = MavenModelConverter.convertProfiles(mavenProject.getActiveProfiles());
-
     RemoteNativeMavenProjectHolder holder = new RemoteNativeMavenProjectHolder(mavenProject);
     try {
       UnicastRemoteObject.exportObject(holder, 0);
@@ -169,11 +167,37 @@ public class MavenFacadeEmbedderImpl extends RemoteObject implements MavenFacade
       throw new RuntimeException(e);
     }
 
+    Collection<String> activatedProfiles = collectActivatedProfiles(mavenProject);
+
     MavenWrapperExecutionResult.ProjectData data = new MavenWrapperExecutionResult.ProjectData(
       model, MavenModelConverter.convertToMap(mavenProject.getModel()), holder, activatedProfiles);
     return new MavenWrapperExecutionResult(data, problems, unresolvedArtifacts);
   }
 
+  private Collection<String> collectActivatedProfiles(MavenProject mavenProject) {
+    // for some reason project's active profiles do not contain parent's profiles - only local and settings'.
+    // parent's profiles do not contain settings' profiles.
+
+    List<Profile> profiles = new ArrayList<Profile>();
+    while (mavenProject != null) {
+      if (profiles != null) {
+        profiles.addAll(mavenProject.getActiveProfiles());
+      }
+      mavenProject = mavenProject.getParent();
+    }
+    return collectProfilesIds(profiles);
+  }
+
+  private static Collection<String> collectProfilesIds(List<Profile> profiles) {
+    Collection<String> result = new THashSet<String>();
+    for (Profile each : profiles) {
+      if (each.getId() != null) {
+        result.add(each.getId());
+      }
+    }
+    return result;
+  }
+
   @NotNull
   public MavenArtifact resolve(@NotNull final MavenArtifactInfo info,
                                @NotNull final List<MavenRemoteRepository> remoteRepositories) throws MavenFacadeProcessCanceledException {
@@ -433,7 +457,7 @@ public class MavenFacadeEmbedderImpl extends RemoteObject implements MavenFacade
     }
 
     return new ProfileApplicationResult(MavenModelConverter.convertModel(nativeModel, null),
-                                        MavenModelConverter.convertProfiles(activatedProfiles));
+                                        collectProfilesIds(activatedProfiles));
   }
 
   private static ProfileActivator[] getProfileActivators() {
@@ -632,7 +656,7 @@ public class MavenFacadeEmbedderImpl extends RemoteObject implements MavenFacade
     catch (IllegalAccessException e) {
       MavenFacadeGlobalsManager.getLogger().info(e);
     }
-    catch(Exception e) {
+    catch (Exception e) {
       throw new RuntimeException(wrapException(e));
     }
   }
index 928663c4d5fed239f07971d6ca863929dde1d2bd..765a38cd144145e290114a159f4f940521726a9d 100644 (file)
@@ -31,7 +31,6 @@ import org.jetbrains.idea.maven.model.MavenId;
 import org.jetbrains.idea.maven.project.*;
 import org.jetbrains.idea.maven.utils.MavenUtil;
 
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Set;
@@ -426,7 +425,7 @@ public class MavenDomProjectProcessorUtils {
                                              MavenProject mavenProjectOrNull,
                                              Processor<T> processor,
                                              Function<MavenDomProfile, T> f) {
-    Collection<String> activePropfiles = mavenProjectOrNull == null ? null : mavenProjectOrNull.getActiveProfilesIds();
+    Collection<String> activePropfiles = mavenProjectOrNull == null ? null : mavenProjectOrNull.getActivatedProfilesIds();
     for (MavenDomProfile each : profilesDom.getProfiles()) {
       XmlTag idTag = each.getId().getXmlTag();
       if (idTag == null) continue;
index 060067ba2cda2d27269386a2551c1ef8b9bbf70f..253de67c47e7008b68b67450a57d2f739f22170e 100644 (file)
@@ -56,7 +56,7 @@ public class MavenPropertyResolver {
 
     collectPropertiesFromDOM(projectDom.getProperties(), result);
 
-    Collection<String> activePropfiles = project.getActiveProfilesIds();
+    Collection<String> activePropfiles = project.getActivatedProfilesIds();
     for (MavenDomProfile each : projectDom.getProfiles().getProfiles()) {
       XmlTag idTag = each.getId().getXmlTag();
       if (idTag == null || !activePropfiles.contains(idTag.getValue().getText())) continue;
index 0ab9e3fab6a4ad5da9243b05f9f9377174006449..6ba3b5d2ac6d05ea051f4a0193a7c4eb22d31d8f 100644 (file)
@@ -108,9 +108,7 @@ public class MavenProject {
     newState.myReadingProblems = readerResult.readingProblems;
     newState.myLocalRepository = settings.getEffectiveLocalRepository();
 
-    Collection<MavenProfile> activeProfiles = readerResult.activatedProfiles;
-
-    newState.myActiveProfilesIds = collectProfilesIds(activeProfiles);
+    newState.myActivatedProfilesIds = readerResult.activatedProfiles;
 
     MavenModel model = readerResult.mavenModel;
 
@@ -136,7 +134,7 @@ public class MavenProject {
 
     doSetResolvedAttributes(newState, readerResult, resetArtifacts);
 
-    newState.myModulesPathsAndNames = collectModulePathsAndNames(model, getDirectory(), activeProfiles);
+    newState.myModulesPathsAndNames = collectModulePathsAndNames(model, getDirectory());
     Collection<String> newProfiles = collectProfilesIds(model.getProfiles());
     if (resetProfiles || newState.myProfilesIds == null) {
       newState.myProfilesIds = newProfiles;
@@ -209,28 +207,18 @@ public class MavenProject {
     newState.myTestResources = model.getBuild().getTestResources();
   }
 
-  private static Map<String, String> collectModulePathsAndNames(MavenModel mavenModel,
-                                                                String baseDir,
-                                                                Collection<MavenProfile> activeProfiles) {
+  private static Map<String, String> collectModulePathsAndNames(MavenModel mavenModel, String baseDir) {
     String basePath = baseDir + "/";
     Map<String, String> result = new LinkedHashMap<String, String>();
-    for (Map.Entry<String, String> each : collectModulesRelativePathsAndNames(mavenModel, activeProfiles).entrySet()) {
+    for (Map.Entry<String, String> each : collectModulesRelativePathsAndNames(mavenModel).entrySet()) {
       result.put(new Path(basePath + each.getKey()).getPath(), each.getValue());
     }
     return result;
   }
 
-  private static Map<String, String> collectModulesRelativePathsAndNames(MavenModel mavenModel, Collection<MavenProfile> activeProfiles) {
+  private static Map<String, String> collectModulesRelativePathsAndNames(MavenModel mavenModel) {
     LinkedHashMap<String, String> result = new LinkedHashMap<String, String>();
-    addModulesToList(mavenModel.getModules(), result);
-    for (MavenProfile profile : activeProfiles) {
-      addModulesToList(profile.getModules(), result);
-    }
-    return result;
-  }
-
-  private static void addModulesToList(List<String> moduleNames, LinkedHashMap<String, String> result) {
-    for (String name : moduleNames) {
+    for (String name : mavenModel.getModules()) {
       name = name.trim();
       
       if (name.length() == 0) continue;
@@ -244,6 +232,7 @@ public class MavenProject {
 
       result.put(name, originalName);
     }
+    return result;
   }
 
   private static Collection<String> collectProfilesIds(Collection<MavenProfile> profiles) {
@@ -289,10 +278,6 @@ public class MavenProject {
     return !myState.myReadingProblems.isEmpty();
   }
 
-  public Collection<String> getActiveProfilesIds() {
-    return myState.myActiveProfilesIds;
-  }
-
   public String getName() {
     return myState.myName;
   }
@@ -378,7 +363,7 @@ public class MavenProject {
     MavenProjectReaderResult result = reader.resolveProject(generalSettings,
                                                             embedder,
                                                             getFile(),
-                                                            getActiveProfilesIds(),
+                                                            getActivatedProfilesIds(),
                                                             locator);
     MavenProjectChanges changes = set(result, generalSettings, false, result.readingProblems.isEmpty(), false);
 
@@ -397,7 +382,7 @@ public class MavenProject {
     MavenProjectReaderResult result = reader.generateSources(embedder,
                                                              importingSettings,
                                                              getFile(),
-                                                             getActiveProfilesIds(),
+                                                             getActivatedProfilesIds(),
                                                              console);
     if (result == null || !result.readingProblems.isEmpty()) return Pair.create(false, MavenProjectChanges.NONE);
     MavenProjectChanges changes = setFolders(result);
@@ -561,6 +546,10 @@ public class MavenProject {
     return myState.myProfilesIds;
   }
 
+  public Collection<String> getActivatedProfilesIds() {
+    return myState.myActivatedProfilesIds;
+  }
+
   public List<MavenArtifact> getDependencies() {
     return myState.myDependencies;
   }
@@ -767,16 +756,15 @@ public class MavenProject {
 
     List<MavenArtifact> myDependencies;
     List<MavenArtifactNode> myDependencyTree;
-
     List<MavenRemoteRepository> myRemoteRepositories;
 
     Map<String, String> myModulesPathsAndNames;
 
-    Collection<String> myProfilesIds;
-
     Map<String, String> myModelMap;
 
-    Collection<String> myActiveProfilesIds;
+    Collection<String> myProfilesIds;
+    Collection<String> myActivatedProfilesIds;
+
     Collection<MavenProjectProblem> myReadingProblems;
     Set<MavenId> myUnresolvedArtifactIds;
     File myLocalRepository;
index 6a4d16818d4c150899a4d13de90787301d8af4a2..992ea2e3b15d52aadbe52c0a8dea8f80317aa57b 100644 (file)
@@ -50,7 +50,7 @@ public class MavenProjectReader {
                                               VirtualFile file,
                                               Collection<String> explicitProfiles,
                                               MavenProjectReaderProjectLocator locator) {
-    Pair<RawModelReadResult, Collection<MavenProfile>> readResult =
+    Pair<RawModelReadResult, Collection<String>> readResult =
       doReadProjectModel(generalSettings, file, explicitProfiles, new THashSet<VirtualFile>(), locator);
 
     File basedir = getBaseDir(file);
@@ -68,11 +68,11 @@ public class MavenProjectReader {
     return new File(file.getParent().getPath());
   }
 
-  private Pair<RawModelReadResult, Collection<MavenProfile>> doReadProjectModel(MavenGeneralSettings generalSettings,
-                                                                                VirtualFile file,
-                                                                                Collection<String> explicitProfiles,
-                                                                                Set<VirtualFile> recursionGuard,
-                                                                                MavenProjectReaderProjectLocator locator) {
+  private Pair<RawModelReadResult, Collection<String>> doReadProjectModel(MavenGeneralSettings generalSettings,
+                                                                          VirtualFile file,
+                                                                          Collection<String> explicitProfiles,
+                                                                          Set<VirtualFile> recursionGuard,
+                                                                          MavenProjectReaderProjectLocator locator) {
     RawModelReadResult cachedModel = myRawModelsCache.get(file);
     if (cachedModel == null) {
       cachedModel = doReadProjectModel(file, false);
@@ -92,8 +92,8 @@ public class MavenProjectReader {
 
     repairModelBody(model);
 
-    return new Pair<RawModelReadResult, Collection<MavenProfile>>(new RawModelReadResult(model, problems, alwaysOnProfiles),
-                                                                  applied.getActivatedProfiles());
+    return new Pair<RawModelReadResult, Collection<String>>(new RawModelReadResult(model, problems, alwaysOnProfiles),
+                                                            applied.getActivatedProfiles());
   }
 
   private RawModelReadResult doReadProjectModel(VirtualFile file, boolean headerOnly) {
index 6da3fe0496be915d903dba72d5153f68e0acf8f0..432df6b72f572d6d57b9640a53006111edb4f1ae 100644 (file)
@@ -29,14 +29,14 @@ import java.util.Set;
 public class MavenProjectReaderResult {
   public final MavenModel mavenModel;
   public final Map<String, String> nativeModelMap;
-  public final Collection<MavenProfile> activatedProfiles;
+  public final Collection<String> activatedProfiles;
   @Nullable public final NativeMavenProjectHolder nativeMavenProject;
   public final Collection<MavenProjectProblem> readingProblems;
   public final Set<MavenId> unresolvedArtifactIds;
 
   public MavenProjectReaderResult(MavenModel mavenModel,
                                   Map<String, String> nativeModelMap,
-                                  Collection<MavenProfile> activatedProfiles,
+                                  Collection<String> activatedProfiles,
                                   @Nullable NativeMavenProjectHolder nativeMavenProject,
                                   Collection<MavenProjectProblem> readingProblems,
                                   Set<MavenId> unresolvedArtifactIds) {
index ad302348bb8e518909c7d46905ff66dbb129ce5b..88647d1b8d026f60fe4d1052b8cdadc491c2cca5 100644 (file)
@@ -383,7 +383,7 @@ public class MavenProjectsTree {
     Collection<String> active = includeActive ? new THashSet<String>() : null;
     for (MavenProject each : getProjects()) {
       if (available != null) available.addAll(each.getProfilesIds());
-      if (active != null) active.addAll(each.getActiveProfilesIds());
+      if (active != null) active.addAll(each.getActivatedProfilesIds());
     }
     return Pair.create(available, active);
   }
index 80e5ced36d2db33b726cf0568578f5d968c8924d..5160573eb00cf1c53a32827736eb7947d219b52b 100644 (file)
@@ -19,11 +19,19 @@ import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.ex.ProjectManagerEx;
 import com.intellij.testFramework.PsiTestUtil;
 
+import java.io.File;
+
 public class MavenNotManagedProjectInspectionsTest extends MavenDomTestCase {
+  @Override
+  protected void setUpInWriteAction() throws Exception {
+    super.setUpInWriteAction();
+    setRepositoryPath(new File(myDir, "repo").getPath());
+  }
+
   public void testWorkForNonMavenProjects() throws Throwable {
     Module m = createModule("module");
     PsiTestUtil.addContentRoot(m, myProjectRoot);
-    
+
     createProjectPom("<groupId>test</groupId>" +
                      "<artifactId>project</artifactId>" +
                      "<version>1</version>" +
@@ -44,7 +52,7 @@ public class MavenNotManagedProjectInspectionsTest extends MavenDomTestCase {
     checkHighlighting(); // should not fail nor highlight errors
   }
 
-  public void testEnabligInspectionForNonMavenProjectsAfterImport() throws Throwable {
+  public void testEnablingInspectionForNonMavenProjectsAfterImport() throws Throwable {
     if (ignore()) return;
     // can not reproduce in tests because of StartupManager.runWhenProjectIsInitialized
     // relies on ProjectManager.isProjectOpen. In tests the project is never being opened.
index cbc32728efe4526171cefd498b7f2f45ee79bd9a..d1282981d6b3c364325c19750dd6f13bb4b56d1c 100644 (file)
@@ -1530,11 +1530,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
   private void assertActiveProfiles(List<String> explicitProfiles, String... expected) {
     MavenProjectReaderResult result =
       readProject(myProjectPom, new NullProjectLocator(), explicitProfiles.toArray(new String[explicitProfiles.size()]));
-    assertUnorderedElementsAreEqual(ContainerUtil.map(result.activatedProfiles, new Function<MavenProfile, String>() {
-      public String fun(MavenProfile profile) {
-        return profile.getId();
-      }
-    }), expected);
+    assertUnorderedElementsAreEqual(result.activatedProfiles, expected);
   }
 
   private static class NullProjectLocator implements MavenProjectReaderProjectLocator {
index 3cab9767ac50fb37571375dcca6464588f3f752a..205c12c1a6544792b65e8d330c77f55fb94113b2 100644 (file)
@@ -70,7 +70,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase {
 
     updateAll(myProjectPom);
     List<MavenProject> roots = myTree.getRootProjects();
-                       
+
     assertEquals(1, roots.size());
     assertEquals(myProjectPom, roots.get(0).getFile());
 
@@ -1941,6 +1941,118 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase {
     assertUnorderedElementsAreEqual(myTree.getAvailableProfiles(), "one", "two", "three");
   }
 
+  public void testCollectingProfilesFromParentsAfterResolve() throws Exception {
+    createModulePom("parent1",
+                    "<groupId>test</groupId>" +
+                    "<artifactId>parent1</artifactId>" +
+                    "<version>1</version>" +
+                    "<packaging>pom</packaging>" +
+
+                    "<profiles>" +
+                    "  <profile>" +
+                    "    <id>parent1Profile</id>" +
+                    "  </profile>" +
+                    "</profiles>");
+
+    createProfilesXml("parent1",
+                      "<profile>" +
+                      "  <id>parent1ProfileXml</id>" +
+                      "</profile>");
+
+    createModulePom("parent2",
+                    "<groupId>test</groupId>" +
+                    "<artifactId>parent2</artifactId>" +
+                    "<version>1</version>" +
+                    "<packaging>pom</packaging>" +
+
+                    "<parent>" +
+                    " <groupId>test</groupId>" +
+                    " <artifactId>parent1</artifactId>" +
+                    " <version>1</version>" +
+                    " <relativePath>../parent1/pom.xml</relativePath>" +
+                    "</parent>" +
+
+                    "<profiles>" +
+                    "  <profile>" +
+                    "    <id>parent2Profile</id>" +
+                    "  </profile>" +
+                    "</profiles>");
+
+    createProfilesXml("parent2",
+                      "<profile>" +
+                      "  <id>parent2ProfileXml</id>" +
+                      "</profile>");
+
+    createProjectPom("<groupId>test</groupId>" +
+                     "<artifactId>project</artifactId>" +
+                     "<version>1</version>" +
+
+                     "<parent>" +
+                     " <groupId>test</groupId>" +
+                     " <artifactId>parent2</artifactId>" +
+                     " <version>1</version>" +
+                     " <relativePath>parent2/pom.xml</relativePath>" +
+                     "</parent>" +
+
+                     "<profiles>" +
+                     "  <profile>" +
+                     "    <id>projectProfile</id>" +
+                     "  </profile>" +
+                     "</profiles>");
+
+    createProfilesXml("<profile>" +
+                      "  <id>projectProfileXml</id>" +
+                      "</profile>");
+
+    updateSettingsXml("<profiles>" +
+                      "  <profile>" +
+                      "    <id>settings</id>" +
+                      "  </profile>" +
+                      "</profiles>");
+
+    updateAll(Arrays.asList("projectProfileXml",
+                            "projectProfile",
+                            "parent1Profile",
+                            "parent1ProfileXml",
+                            "parent2Profile",
+                            "parent2ProfileXml",
+                            "settings",
+                            "xxx"),
+              myProjectPom);
+
+    MavenProject project = myTree.findProject(myProjectPom);
+    assertUnorderedElementsAreEqual(project.getActivatedProfilesIds(),
+                                    "projectProfileXml",
+                                    "projectProfile",
+                                    "parent1Profile",
+                                    "parent1ProfileXml",
+                                    "parent2Profile",
+                                    "parent2ProfileXml",
+                                    "settings");
+
+    MavenEmbeddersManager embeddersManager = new MavenEmbeddersManager(myProject);
+    try {
+      myTree.resolve(project,
+                     getMavenGeneralSettings(),
+                     embeddersManager,
+                     NULL_MAVEN_CONSOLE,
+                     EMPTY_MAVEN_PROCESS,
+                     null);
+    }
+    finally {
+      embeddersManager.release();
+    }
+
+    assertUnorderedElementsAreEqual(project.getActivatedProfilesIds(),
+                                    "projectProfileXml",
+                                    "projectProfile",
+                                    "parent1Profile",
+                                    "parent1ProfileXml",
+                                    "parent2Profile",
+                                    "parent2ProfileXml",
+                                    "settings");
+  }
+
   public void testDeletingAndRestoringActiveProfilesWhenAvailableProfilesChange() throws Exception {
     createProjectPom("<groupId>test</groupId>" +
                      "<artifactId>project</artifactId>" +