diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.localserver.test/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/AppEngineTabGroupTest.java b/plugins/com.google.cloud.tools.eclipse.appengine.localserver.test/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/AppEngineTabGroupTest.java index 08679415f1..17b0f715e7 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.localserver.test/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/AppEngineTabGroupTest.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.localserver.test/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/AppEngineTabGroupTest.java @@ -16,6 +16,7 @@ package com.google.cloud.tools.eclipse.appengine.localserver.ui; +import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.junit.Assert; import org.junit.Test; @@ -25,8 +26,11 @@ public class AppEngineTabGroupTest { public void testCreateTabs() { AppEngineTabGroup group = new AppEngineTabGroup(); group.createTabs(null, ""); + for (ILaunchConfigurationTab tab : group.getTabs()) { + Assert.assertNotNull(tab); + } Assert.assertEquals("Server", group.getTabs()[0].getName()); - Assert.assertEquals("Environment", group.getTabs()[1].getName()); + Assert.assertEquals("Arguments", group.getTabs()[1].getName()); } } diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/META-INF/MANIFEST.MF b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/META-INF/MANIFEST.MF index 8e653dbbfb..135602e380 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/META-INF/MANIFEST.MF +++ b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/META-INF/MANIFEST.MF @@ -10,6 +10,9 @@ Bundle-Activator: com.google.cloud.tools.eclipse.appengine.localserver.Activator Bundle-ActivationPolicy: lazy Require-Bundle: com.google.cloud.tools.appengine;bundle-version="0.2.5", com.google.cloud.tools.eclipse.appengine.ui;bundle-version="0.1.0", + com.google.guava;bundle-version="20.0.0", + javax.servlet;bundle-version="2.5.0", + javax.servlet.jsp;bundle-version="2.1.0", org.eclipse.wst.server.core;bundle-version="1.7.0", org.eclipse.wst.server.ui;bundle-version="1.5.201", org.eclipse.wst.common.project.facet.core;bundle-version="1.4.300", @@ -20,11 +23,8 @@ Require-Bundle: com.google.cloud.tools.appengine;bundle-version="0.2.5", org.eclipse.jst.server.generic.ui;bundle-version="1.0.600", org.eclipse.jst.common.project.facet.core;bundle-version="1.4.400", org.eclipse.jst.common.project.facet.ui;bundle-version="1.4.510", - javax.servlet;bundle-version="2.5.0", - javax.servlet.jsp;bundle-version="2.1.0", org.eclipse.core.resources;bundle-version="3.10.1", org.eclipse.debug.core;bundle-version="3.10.0", - com.google.guava;bundle-version="20.0.0", org.eclipse.debug.ui;bundle-version="3.11.101", org.eclipse.core.expressions;bundle-version="3.5.0", org.eclipse.m2e.core;bundle-version="1.6.2", @@ -32,9 +32,7 @@ Require-Bundle: com.google.cloud.tools.appengine;bundle-version="0.2.5", org.eclipse.m2e.wtp;bundle-version="1.2.1", org.eclipse.m2e.jdt;bundle-version="1.6.2", org.eclipse.ui.console;bundle-version="3.6.100", - org.eclipse.ui.ide;bundle-version="3.11.0", - org.eclipse.jdt.core, - org.eclipse.swt + org.eclipse.ui.ide;bundle-version="3.11.0" Export-Package: com.google.cloud.tools.eclipse.appengine.localserver.server Import-Package: com.google.cloud.tools.eclipse.appengine.facets, com.google.cloud.tools.eclipse.appengine.libraries.model, @@ -51,4 +49,9 @@ Import-Package: com.google.cloud.tools.eclipse.appengine.facets, com.google.cloud.tools.eclipse.util.service, com.google.cloud.tools.eclipse.util.status, org.eclipse.e4.core.contexts, - org.eclipse.e4.core.di + org.eclipse.e4.core.di, + org.eclipse.jdt.core, + org.eclipse.jdt.debug.ui.launchConfigurations, + org.eclipse.swt + + diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/server/LocalAppEngineServerBehaviour.java b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/server/LocalAppEngineServerBehaviour.java index 9390415cc9..c292b242b4 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/server/LocalAppEngineServerBehaviour.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/server/LocalAppEngineServerBehaviour.java @@ -246,10 +246,14 @@ public int getServerPort() { /** * Starts the development server. * - * @param runnables the path to directories that contain configuration files like appengine-web.xml + * @param runnables the path to directories that contain configuration files such as + * appengine-web.xml * @param console the stream (Eclipse console) to send development server process output to + * @param arguments JVM arguments to pass to the dev server */ - void startDevServer(List runnables, MessageConsoleStream console) throws CoreException { + void startDevServer(List runnables, MessageConsoleStream console, List vmArguments) + throws CoreException { + checkAndSetPorts(); // Must be called before setting the STARTING state. setServerState(IServer.STATE_STARTING); @@ -263,6 +267,7 @@ void startDevServer(List runnables, MessageConsoleStream console) throws C devServerRunConfiguration.setHost(getServer().getHost()); devServerRunConfiguration.setPort(serverPort); devServerRunConfiguration.setAdminPort(adminPort); + devServerRunConfiguration.setJvmFlags(vmArguments); // Run server try { @@ -276,18 +281,21 @@ void startDevServer(List runnables, MessageConsoleStream console) throws C /** * Starts the development server in debug mode. * - * @param runnables the path to directories that contain configuration files like appengine-web.xml + * @param runnables the path to directories that contain configuration files like + * appengine-web.xml * @param console the stream (Eclipse console) to send development server process output to * @param debugPort the port to attach a debugger to if launch is in debug mode + * @param arguments JVM arguments to pass to the dev server */ - void startDebugDevServer(List runnables, MessageConsoleStream console, int debugPort) + void startDebugDevServer(List runnables, MessageConsoleStream console, int debugPort, + List vmArguments) throws CoreException { checkAndSetPorts(); // Must be called before setting the STARTING state. setServerState(IServer.STATE_STARTING); // Create dev app server instance initializeDevServer(console); - + // Create run configuration DefaultRunConfiguration devServerRunConfiguration = new DefaultRunConfiguration(); devServerRunConfiguration.setAutomaticRestart(false); @@ -302,12 +310,15 @@ void startDebugDevServer(List runnables, MessageConsoleStream console, int List jvmFlags = new ArrayList(); + // todo only real difference between this method and startDevServer are these two extra + // JVM flags. Just set them and call startDevServer if (debugPort <= 0 || debugPort > 65535) { throw new IllegalArgumentException("Debug port is set to " + debugPort //$NON-NLS-1$ + ", should be between 1-65535"); //$NON-NLS-1$ } jvmFlags.add("-Xdebug"); //$NON-NLS-1$ jvmFlags.add("-Xrunjdwp:transport=dt_socket,server=n,suspend=y,quiet=y,address=" + debugPort); //$NON-NLS-1$ + jvmFlags.addAll(vmArguments); devServerRunConfiguration.setJvmFlags(jvmFlags); // Run server diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/server/LocalAppEngineServerLaunchConfigurationDelegate.java b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/server/LocalAppEngineServerLaunchConfigurationDelegate.java index 910889286b..5f5cb5d09a 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/server/LocalAppEngineServerLaunchConfigurationDelegate.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/server/LocalAppEngineServerLaunchConfigurationDelegate.java @@ -32,6 +32,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -82,10 +83,10 @@ private static void validateCloudSdk() throws CoreException { CloudSdk cloudSdk = new CloudSdk.Builder().build(); cloudSdk.validateCloudSdk(); } catch (CloudSdkOutOfDateException ex) { - String detailMessage = Messages.getString("cloudsdk.out.of.date"); - Status status = new Status(IStatus.ERROR, - "com.google.cloud.tools.eclipse.appengine.deploy.ui", detailMessage); - throw new CoreException(status); + String detailMessage = Messages.getString("cloudsdk.out.of.date"); + Status status = new Status(IStatus.ERROR, + "com.google.cloud.tools.eclipse.appengine.deploy.ui", detailMessage); + throw new CoreException(status); } catch (AppEngineException ex) { String detailMessage = Messages.getString("cloudsdk.not.configured"); //$NON-NLS-1$ Status status = new Status(IStatus.ERROR, @@ -101,7 +102,7 @@ public void launch(ILaunchConfiguration configuration, String mode, final ILaunc AnalyticsEvents.APP_ENGINE_LOCAL_SERVER_MODE, mode); validateCloudSdk(); - + IServer server = ServerUtil.getServer(configuration); if (server == null) { String message = "There is no App Engine development server available"; @@ -136,14 +137,18 @@ public void launch(ILaunchConfiguration configuration, String mode, final ILaunc new ServerLaunchMonitor(launch, server).engage(); + String vmArgumentString = getVMArguments(configuration); + // This string is exactly as supplied by the user in the dialog box + + List vmArguments = Arrays.asList(vmArgumentString.split("\\s+")); if (ILaunchManager.DEBUG_MODE.equals(mode)) { int debugPort = getDebugPort(); setupDebugTarget(launch, debugPort, monitor); - serverBehaviour.startDebugDevServer(runnables, console.newMessageStream(), debugPort); + serverBehaviour.startDebugDevServer(runnables, console.newMessageStream(), debugPort, vmArguments); } else { // A launch must have at least one debug target or process, or it otherwise becomes a zombie LocalAppEngineServerDebugTarget.addTarget(launch, serverBehaviour); - serverBehaviour.startDevServer(runnables, console.newMessageStream()); + serverBehaviour.startDevServer(runnables, console.newMessageStream(), vmArguments); } } diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/AppEngineTabGroup.java b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/AppEngineTabGroup.java index 50af127e58..9e62e62006 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/AppEngineTabGroup.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/AppEngineTabGroup.java @@ -18,12 +18,21 @@ import com.google.cloud.tools.eclipse.appengine.localserver.server.LocalAppEngineServerDelegate; import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; -import org.eclipse.debug.ui.EnvironmentTab; import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.swt.widgets.Composite; import org.eclipse.wst.server.ui.ServerLaunchConfigurationTab; +import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab; +/** + * Tabs shown in launch configurations for an App Engine Server. + * To get to these in the UI: + * + * 1. Open Servers view + * 2. Right click on the server to configure + * 3. Open + * 4. Open Launch Configuration + */ public class AppEngineTabGroup extends AbstractLaunchConfigurationTabGroup { private static final String[] SERVER_TYPE_IDS = {LocalAppEngineServerDelegate.SERVER_TYPE_ID}; @@ -33,13 +42,9 @@ public void createTabs(ILaunchConfigurationDialog dialog, String mode) { ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[2]; tabs[0] = new AppEngineServerLaunchConfigurationTab(SERVER_TYPE_IDS); tabs[0].setLaunchConfigurationDialog(dialog); - tabs[1] = new EnvironmentTab(); + tabs[1] = new JavaArgumentsTab(); tabs[1].setLaunchConfigurationDialog(dialog); - // see - // http://git.eclipse.org/c/jetty/org.eclipse.jetty.wtp.git/tree/org.eclipse.jst.server.jetty.ui/src/org/eclipse/jst/server/jetty/ui/internal/JettyLaunchConfigurationTabGroup.java - // for examples of other tabs we might want to add - setTabs(tabs); } diff --git a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/LaunchModes.java b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/LaunchModes.java index 7118f58415..fd5e9ac954 100644 --- a/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/LaunchModes.java +++ b/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ui/LaunchModes.java @@ -30,6 +30,7 @@ */ public class LaunchModes implements IParameterValues { @Override + @SuppressWarnings("rawtypes") public Map getParameterValues() { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); Map modes = new HashMap<>();