OSDN Git Service

Merge "Allow for platform projects to be used with the "debug running app" button."
authorXavier Ducrohet <xav@android.com>
Thu, 1 Jul 2010 16:30:02 +0000 (09:30 -0700)
committerAndroid Code Review <code-review@android.com>
Thu, 1 Jul 2010 16:30:02 +0000 (09:30 -0700)
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java

index c6fda52..1f89a01 100644 (file)
@@ -308,6 +308,27 @@ public class AdtPlugin extends AbstractUIPlugin {
                     AndroidLaunchController.debugRunningApp(project, port);
                     return true;
                 } else {
+                    // check to see if there's a platform project defined by an env var.
+                    String var = System.getenv("ANDROID_PLATFORM_PROJECT"); //$NON-NLS-1$
+                    if (var != null && var.length() > 0) {
+                        boolean auto = "AUTO".equals(var); //$NON-NLS-1$
+
+                        // Get the list of project for the current workspace
+                        IWorkspace workspace = ResourcesPlugin.getWorkspace();
+                        IProject[] projects = workspace.getRoot().getProjects();
+
+                        // look for a project that matches the env var or take the first
+                        // one if in automatic mode.
+                        for (IProject p : projects) {
+                            if (p.isOpen()) {
+                                if (auto || p.getName().equals(var)) {
+                                    AndroidLaunchController.debugRunningApp(p, port);
+                                    return true;
+                                }
+                            }
+                        }
+
+                    }
                     return false;
                 }
             }