generate Flex compiler configuration file when importing Flexmojos projects
authorAlexander Doroshko <alexander.doroshko@swiftteams.com>
Fri, 25 Sep 2009 17:02:50 +0000 (21:02 +0400)
committerAlexander Doroshko <alexander.doroshko@swiftteams.com>
Fri, 25 Sep 2009 17:02:50 +0000 (21:02 +0400)
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenEmbeddersManager.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java

index 2c8380c9adda36b43b7c86cfbad2e364e72b833e..703b72e2cb41eb9b8fc3c9d3cb4d06a0a84efa87 100644 (file)
@@ -16,6 +16,7 @@ public class MavenEmbeddersManager {
     FOR_PLUGINS_RESOLVE,
     FOR_FOLDERS_RESOLVE,
     FOR_DOWNLOAD,
+    FOR_FLEX_CONFIG_GENERATION,
   }
 
   private final MavenGeneralSettings myGeneralSettings;
index da32b67607a5d3d81b3b61ef0fe9bc099dbde482..b26122e773a7838f2c9c24175aec2ad83e75729d 100644 (file)
@@ -43,7 +43,7 @@ public class MavenProjectsTree {
   private final Map<MavenProject, MavenProjectTimestamp> myTimestamps = new THashMap<MavenProject, MavenProjectTimestamp>();
   private final Map<VirtualFile, MavenProject> myVirtualFileToProjectMapping = new THashMap<VirtualFile, MavenProject>();
   private final Map<MavenId, MavenProject> myMavenIdToProjectMapping = new THashMap<MavenId, MavenProject>();
-  private final Map<MavenId, VirtualFile> myMavenIdToFileMapping  = new THashMap<MavenId, VirtualFile>();
+  private final Map<MavenId, VirtualFile> myMavenIdToFileMapping = new THashMap<MavenId, VirtualFile>();
   private final Map<MavenProject, List<MavenProject>> myAggregatorToModuleMapping = new THashMap<MavenProject, List<MavenProject>>();
   private final Map<MavenProject, MavenProject> myModuleToAggregatorMapping = new THashMap<MavenProject, MavenProject>();
 
@@ -830,7 +830,7 @@ public class MavenProjectsTree {
     return findProject(new MavenId(artifact));
   }
 
-  public Map<MavenId, VirtualFile> getProjectIdToFileMapping() {
+  private Map<MavenId, VirtualFile> getProjectIdToFileMapping() {
     readLock();
     try {
       return new THashMap<MavenId, VirtualFile>(myMavenIdToFileMapping);
@@ -931,7 +931,7 @@ public class MavenProjectsTree {
                       Object message) throws MavenProcessCanceledException {
     MavenEmbedderWrapper embedder = embeddersManager.getEmbedder(MavenEmbeddersManager.EmbedderKind.FOR_DEPENDENCIES_RESOLVE);
     embedder.customizeForResolve(getProjectIdToFileMapping(), console, process);
-    
+
     try {
       process.checkCanceled();
       process.setText(ProjectBundle.message("maven.resolving.pom", mavenProject.getDisplayName()));
@@ -970,32 +970,32 @@ public class MavenProjectsTree {
     }
   }
 
-  public void resolveFolders(MavenProject mavenProject,
-                             MavenImportingSettings importingSettings,
-                             MavenEmbeddersManager embeddersManager,
-                             MavenConsole console,
-                             MavenProgressIndicator process,
-                             Object message) throws MavenProcessCanceledException {
-    MavenEmbedderWrapper embedder = embeddersManager.getEmbedder(MavenEmbeddersManager.EmbedderKind.FOR_FOLDERS_RESOLVE);
-    embedder.customizeForStrictResolve(getProjectIdToFileMapping(), console, process);
-    embedder.clearCachesFor(mavenProject);
-
-    try {
-      process.checkCanceled();
-      process.setText(ProjectBundle.message("maven.updating.folders.pom", mavenProject.getDisplayName()));
-      process.setText2("");
-
-      Pair<Boolean, MavenProjectChanges> resolveResult = mavenProject.resolveFolders(embedder,
-                                                                                     importingSettings,
-                                                                                     new MavenProjectReader(),
-                                                                                     console);
-      if (resolveResult.first) {
-        fireFoldersResolved(Pair.create(mavenProject, resolveResult.second), message);
-      }
-    }
-    finally {
-      embeddersManager.release(embedder);
-    }
+  public void resolveFolders(final MavenProject mavenProject,
+                             final MavenImportingSettings importingSettings,
+                             final MavenEmbeddersManager embeddersManager,
+                             final MavenConsole console,
+                             final MavenProgressIndicator process,
+                             final Object message) throws MavenProcessCanceledException {
+    doWithEmbedder(mavenProject,
+                   embeddersManager,
+                   MavenEmbeddersManager.EmbedderKind.FOR_FOLDERS_RESOLVE,
+                   console,
+                   process,
+                   new EmbedderTask() {
+                     public void run(MavenEmbedderWrapper embedder) throws MavenProcessCanceledException {
+                       process.checkCanceled();
+                       process.setText(ProjectBundle.message("maven.updating.folders.pom", mavenProject.getDisplayName()));
+                       process.setText2("");
+
+                       Pair<Boolean, MavenProjectChanges> resolveResult = mavenProject.resolveFolders(embedder,
+                                                                                                      importingSettings,
+                                                                                                      new MavenProjectReader(),
+                                                                                                      console);
+                       if (resolveResult.first) {
+                         fireFoldersResolved(Pair.create(mavenProject, resolveResult.second), message);
+                       }
+                     }
+                   });
   }
 
   public void downloadArtifacts(MavenProject mavenProject,
@@ -1037,6 +1037,23 @@ public class MavenProjectsTree {
     }
   }
 
+  public void doWithEmbedder(MavenProject mavenProject,
+                             MavenEmbeddersManager embeddersManager,
+                             MavenEmbeddersManager.EmbedderKind embedderKind,
+                             MavenConsole console,
+                             MavenProgressIndicator process,
+                             EmbedderTask task) throws MavenProcessCanceledException {
+    MavenEmbedderWrapper embedder = embeddersManager.getEmbedder(embedderKind);
+    embedder.customizeForStrictResolve(getProjectIdToFileMapping(), console, process);
+    embedder.clearCachesFor(mavenProject);
+    try {
+      task.run(embedder);
+    }
+    finally {
+      embeddersManager.release(embedder);
+    }
+  }
+
   public <Result> Result visit(Visitor<Result> visitor) {
     for (MavenProject each : getRootProjects()) {
       if (visitor.isDone()) break;
@@ -1152,6 +1169,10 @@ public class MavenProjectsTree {
     }
   }
 
+  public interface EmbedderTask {
+    void run(MavenEmbedderWrapper embedder) throws MavenProcessCanceledException;
+  }
+
   public static abstract class Visitor<Result> {
     private Result result;