diff --git a/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF b/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF
index 150ddecc..eea9b2d1 100644
--- a/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF
+++ b/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF
@@ -48,15 +48,7 @@ Import-Package: org.eclipse.cdt.launch.ui,
org.eclipse.osgi.service.debug,
org.eclipse.osgi.util,
org.eclipse.swt.custom,
- org.eclipse.tm.internal.terminal.provisional.api,
- org.eclipse.tm.terminal.connector.local.launcher,
- org.eclipse.tm.terminal.view.core,
- org.eclipse.tm.terminal.view.core.interfaces,
- org.eclipse.tm.terminal.view.core.interfaces.constants,
- org.eclipse.tm.terminal.view.ui.interfaces,
- org.eclipse.tm.terminal.view.ui.launcher,
- org.eclipse.tm.terminal.view.ui.manager,
- org.eclipse.tm.terminal.view.ui.tabs,
+ org.eclipse.ui.console,
org.gradle.tooling,
org.gradle.tooling.model,
org.gradle.tooling.model.eclipse,
diff --git a/bundles/io.openliberty.tools.eclipse.ui/plugin.xml b/bundles/io.openliberty.tools.eclipse.ui/plugin.xml
index c5f29bed..7b151c6a 100644
--- a/bundles/io.openliberty.tools.eclipse.ui/plugin.xml
+++ b/bundles/io.openliberty.tools.eclipse.ui/plugin.xml
@@ -1,6 +1,6 @@
-
-
-
-
runningJobs = new ConcurrentHashMap();
/**
- * Project terminal tab controller instance.
+ * Process controller instance.
*/
- private ProjectTabController projectTabController;
+ private ProcessController processController;
/**
* Dashboard object reference.
@@ -120,7 +122,7 @@ public class DevModeOperations {
* Constructor.
*/
public DevModeOperations() {
- projectTabController = ProjectTabController.getInstance();
+ processController = ProcessController.getInstance();
projectModel = new WorkspaceProjectsModel();
pathEnv = System.getenv("PATH");
debugModeHandler = new DebugModeHandler(this);
@@ -160,7 +162,8 @@ public static DevModeOperations getInstance() {
/**
* @param iProject The project instance to associate with this action.
* @param parms The configuration parameters to be used when starting dev mode.
- * @param javaHomePath The configuration java installation home to be set in the terminal running dev mode.
+ * @param javaHomePath The configuration java installation home to be set in the process running dev mode.
+ * @param launch The launch associated with this run.
* @param mode The configuration mode.
*/
public void start(IProject iProject, String parms, String javaHomePath, ILaunch launch, String mode) {
@@ -178,34 +181,8 @@ public void start(IProject iProject, String parms, String javaHomePath, ILaunch
return;
}
- // Check if the start action has already been issued.
String projectName = iProject.getName();
- // Check if the start action has already been issued.
- State terminalState = projectTabController.getTerminalState(projectName);
- if (terminalState != null && terminalState == ProjectTab.State.STARTED) {
- // Check if the terminal tab associated with this call was marked as closed. This scenario may occur if a previous
- // attempt to start the server in dev mode was issued successfully, but there was a failure in the process or
- // there was an unexpected case that caused the terminal process to end. If that is the case, cleanup the objects
- // associated with the previous instance to allow users to restart dev mode.
- if (projectTabController.isProjectTabMarkedClosed(projectName)) {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_TOOLS,
- "The start request was already processed on project " + projectName
- + ". The terminal tab for this project is marked as closed. Cleaning up. ProjectTabController: "
- + projectTabController);
- }
- projectTabController.processTerminalTabCleanup(projectName);
- } else {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_TOOLS, "The start request was already issued on project " + projectName
- + ". No-op. ProjectTabController: " + projectTabController);
- }
- ErrorHandler.processErrorMessage(NLS.bind(Messages.start_already_issued, projectName), true);
- return;
- }
- }
-
Project project = null;
try {
@@ -231,21 +208,39 @@ public void start(IProject iProject, String parms, String javaHomePath, ILaunch
startParms = userParms;
}
+ // Append color styling to start parms
+ BuildType buildType = project.getBuildType();
+ if (buildType == Project.BuildType.MAVEN) {
+
+ StringBuffer updateStartParms = new StringBuffer(startParms);
+ updateStartParms.append(" ");
+
+ boolean ansiSupported = Platform.getPreferencesService().getBoolean(ANSI_SUPPORT_QUALIFIER, ANSI_SUPPORT_KEY, true, null);
+
+ if (ansiSupported) {
+ updateStartParms.append("-Dstyle.color=always");
+ } else {
+ updateStartParms.append("-Dstyle.color=never");
+ }
+
+ startParms = updateStartParms.toString();
+ }
+
// Prepare the Liberty plugin container dev mode command.
String cmd = "";
- BuildType buildType = project.getBuildType();
+
if (buildType == Project.BuildType.MAVEN) {
cmd = CommandBuilder.getMavenCommandLine(projectPath, "io.openliberty.tools:liberty-maven-plugin:dev " + startParms,
- pathEnv, true);
+ pathEnv);
} else if (buildType == Project.BuildType.GRADLE) {
- cmd = CommandBuilder.getGradleCommandLine(projectPath, "libertyDev " + startParms, pathEnv, true);
+ cmd = CommandBuilder.getGradleCommandLine(projectPath, "libertyDev " + startParms, pathEnv);
} else {
throw new Exception("Unexpected project build type: " + buildType + ". Project " + projectName
+ "does not appear to be a Maven or Gradle built project.");
}
- // Start a terminal and run the application in dev mode.
- startDevMode(cmd, projectName, projectPath, javaHomePath);
+ // Run the application in dev mode.
+ startDevMode(cmd, projectName, projectPath, javaHomePath, launch);
// If there is a debugPort, start the job to attach the debugger to the Liberty server JVM.
if (debugPort != null) {
@@ -275,7 +270,8 @@ public void start(IProject iProject, String parms, String javaHomePath, ILaunch
*
* @param iProject The project instance to associate with this action.
* @param parms The configuration parameters to be used when starting dev mode.
- * @param javaHomePath The configuration java installation home to be set in the terminal running dev mode.
+ * @param javaHomePath The configuration java installation home to be set in the process running dev mode.
+ * @param launch The launch associated with this run.
* @param mode The configuration mode.
*/
public void startInContainer(IProject iProject, String parms, String javaHomePath, ILaunch launch, String mode) {
@@ -293,34 +289,8 @@ public void startInContainer(IProject iProject, String parms, String javaHomePat
return;
}
- // Check if the start action has already been issued.
String projectName = iProject.getName();
- // Check if the start action has already been issued.
- State terminalState = projectTabController.getTerminalState(projectName);
- if (terminalState != null && terminalState == ProjectTab.State.STARTED) {
- // Check if the terminal tab associated with this call was marked as closed. This scenario may occur if a previous
- // attempt to start the server in dev mode was issued successfully, but there was a failure in the process or
- // there was an unexpected case that caused the terminal process to end. If that is the case, cleanup the objects
- // associated with the previous instance to allow users to restart dev mode.
- if (projectTabController.isProjectTabMarkedClosed(projectName)) {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_TOOLS,
- "The start in container request was already processed on project " + projectName
- + ". The terminal tab for this project is marked as closed. Cleaning up. ProjectTabController: "
- + projectTabController);
- }
- projectTabController.processTerminalTabCleanup(projectName);
- } else {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_TOOLS, "The start in container request was already issued on project " + projectName
- + ". No-op. ProjectTabController: " + projectTabController);
- }
- ErrorHandler.processErrorMessage(NLS.bind(Messages.start_container_already_issued, projectName), true);
- return;
- }
- }
-
Project project = null;
try {
@@ -346,21 +316,38 @@ public void startInContainer(IProject iProject, String parms, String javaHomePat
startParms = userParms;
}
+ // Append color styling to start parms
+ BuildType buildType = project.getBuildType();
+ if (buildType == Project.BuildType.MAVEN) {
+
+ StringBuffer updateStartParms = new StringBuffer(startParms);
+ updateStartParms.append(" ");
+
+ boolean ansiSupported = Platform.getPreferencesService().getBoolean(ANSI_SUPPORT_QUALIFIER, ANSI_SUPPORT_KEY, true, null);
+
+ if (ansiSupported) {
+ updateStartParms.append("-Dstyle.color=always");
+ } else {
+ updateStartParms.append("-Dstyle.color=never");
+ }
+
+ startParms = updateStartParms.toString();
+ }
+
// Prepare the Liberty plugin container dev mode command.
String cmd = "";
- BuildType buildType = project.getBuildType();
if (buildType == Project.BuildType.MAVEN) {
cmd = CommandBuilder.getMavenCommandLine(projectPath, "io.openliberty.tools:liberty-maven-plugin:devc " + startParms,
- pathEnv, true);
+ pathEnv);
} else if (buildType == Project.BuildType.GRADLE) {
- cmd = CommandBuilder.getGradleCommandLine(projectPath, "libertyDevc " + startParms, pathEnv, true);
+ cmd = CommandBuilder.getGradleCommandLine(projectPath, "libertyDevc " + startParms, pathEnv);
} else {
throw new Exception("Unexpected project build type: " + buildType + ". Project " + projectName
+ "does not appear to be a Maven or Gradle built project.");
}
- // Start a terminal and run the application in dev mode.
- startDevMode(cmd, projectName, projectPath, javaHomePath);
+ // Run the application in dev mode.
+ startDevMode(cmd, projectName, projectPath, javaHomePath, launch);
// If there is a debugPort, start the job to attach the debugger to the Liberty server JVM.
if (debugPort != null) {
@@ -409,41 +396,19 @@ public void stop(IProject inputProject) {
String projectName = iProject.getName();
// Check if the stop action has already been issued of if a start action was never issued before.
- if (projectTabController.getProjectConnector(projectName) == null) {
+ if (!processController.isProcessStarted(projectName)) {
String msg = NLS.bind(Messages.stop_already_issued, projectName);
handleStopActionError(projectName, msg);
return;
}
- // Check if the terminal tab associated with this call was marked as closed. This scenario may occur if a previous
- // attempt to start the server in dev mode failed due to an invalid custom start parameter, dev mode was terminated manually,
- // dev mode is already running outside of the Liberty Tools session, or there was an unexpected case that caused
- // the terminal process to end. Note that objects associated with the previous start attempt will be cleaned up on
- // the next restart attempt.
- if (projectTabController.isProjectTabMarkedClosed(projectName)) {
- String msg = NLS.bind(Messages.stop_terminal_not_active, projectName);
- handleStopActionError(projectName, msg);
-
- return;
- }
-
try {
- // Issue the command on the terminal.
- projectTabController.writeToTerminalStream(projectName, DEVMODE_COMMAND_EXIT.getBytes());
-
- // The command to exit dev mode was issued. Set the internal project tab state to STOPPED as
- // indication that the stop command was issued. The project's terminal tab UI will be marked as closed (title and state
- // updates) when dev mode exits.
- projectTabController.setTerminalState(projectName, ProjectTab.State.STOPPED);
-
- // Cleanup internal objects. This maybe done a bit prematurely at this point because the operations triggered by
- // the action of writing to the terminal are asynchronous. However, there is no good way to listen for terminal tab
- // state changes (avoid loops or terminal internal class references). Furthermore, if errors are experienced during
- // dev mode exit, those errors may not be easily solved by re-trying the stop command.
- // If there are any errors during cleanup or if cleanup does not happen at all here, cleanup will be attempted
- // when the associated terminal view tab is closed/disposed.
- projectTabController.processTerminalTabCleanup(projectName);
+ // Issue the command to the process.
+ processController.writeToProcessStream(projectName, DEVMODE_COMMAND_EXIT);
+
+ // Cleanup internal objects.
+ cleanupProcess(projectName);
} catch (Exception e) {
String msg = NLS.bind(Messages.stop_general_error, projectName);
@@ -457,6 +422,10 @@ public void stop(IProject inputProject) {
}
}
+ public void cleanupProcess(String projectName) {
+ processController.cleanup(projectName);
+ }
+
/**
* Runs the tests provided by the application.
*
@@ -486,35 +455,19 @@ public void runTests(IProject inputProject) {
String projectName = iProject.getName();
// Check if the stop action has already been issued of if a start action was never issued before.
- if (projectTabController.getProjectConnector(projectName) == null) {
+ if (!processController.isProcessStarted(projectName)) {
String msg = "No start request was issued first or the stop request was already issued on project " + projectName
+ ". Issue a start request before you issue the run tests request.";
if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op. ProjectTabController: " + projectTabController);
+ Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op. ProcessController: " + processController);
}
ErrorHandler.processErrorMessage(NLS.bind(Messages.run_tests_no_prior_start, projectName), true);
return;
}
- // Check if the terminal tab associated with this call was marked as closed. This scenario may occur if a previous
- // attempt to start the server in dev mode was issued successfully, but there was a failure in the process or
- // there was an unexpected case that caused the terminal process to end. Note that objects associated with the previous
- // start attempt will be cleaned up on the next restart attempt.
- if (projectTabController.isProjectTabMarkedClosed(projectName)) {
- String msg = "The terminal tab that is running project " + projectName
- + " is not active due to an unexpected error or external action. Review the terminal output for more details. "
- + "Once the circumstance that caused the terminal tab to be inactive is determined and resolved, "
- + "issue a start request before you issue the run tests request.";
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_TOOLS, msg + " No-op. ProjectTabController: " + projectTabController);
- }
- ErrorHandler.processErrorMessage(NLS.bind(Messages.run_tests_terminal_not_active, projectName), true);
- return;
- }
-
try {
- // Issue the command on the terminal.
- projectTabController.writeToTerminalStream(projectName, DEVMODE_COMMAND_RUN_TESTS.getBytes());
+ // Issue the command on the console.
+ processController.writeToProcessStream(projectName, DEVMODE_COMMAND_RUN_TESTS);
} catch (Exception e) {
String msg = "An error was detected when the run tests request was processed on project " + projectName + ".";
if (Trace.isEnabled()) {
@@ -758,7 +711,7 @@ public void openTestReport(String projectName, Path path, String browserId, Stri
}
/**
- * Runs the specified command on a terminal.
+ * Runs the specified command.
*
* @param cmd The command to run.
* @param projectName The name of the project currently being processed.
@@ -766,8 +719,8 @@ public void openTestReport(String projectName, Path path, String browserId, Stri
*
* @throws Exception If an error occurs while running the specified command.
*/
- public void startDevMode(String cmd, String projectName, String projectPath, String javaInstallPath) throws Exception {
- // Determine the environment properties to be set in the terminal prior to running dev mode.
+ public void startDevMode(String cmd, String projectName, String projectPath, String javaInstallPath, ILaunch launch) throws Exception {
+ // Determine the environment properties to be set in the process running dev mode.
List envs = new ArrayList(1);
// The value for JAVA_HOME comes from the underlying configuration. The configuration allows
@@ -784,7 +737,9 @@ public void startDevMode(String cmd, String projectName, String projectPath, Str
envs.add("MAVEN_CONFIG=--log-file " + logFileName);
}
- projectTabController.runOnTerminal(projectName, projectPath, cmd, envs);
+ Process process = processController.runProcess(projectName, projectPath, cmd, envs, true);
+
+ DebugPlugin.newProcess(launch, process, projectName);
}
/**
@@ -834,10 +789,10 @@ private void issueLPStopCommand(String projectName) {
String buildTypeName;
BuildType buildType = project.getBuildType();
if (buildType == Project.BuildType.MAVEN) {
- cmd = CommandBuilder.getMavenCommandLine(projectPath, "io.openliberty.tools:liberty-maven-plugin:stop", pathEnv, false);
+ cmd = CommandBuilder.getMavenCommandLine(projectPath, "io.openliberty.tools:liberty-maven-plugin:stop", pathEnv);
buildTypeName = "Maven";
} else if (buildType == Project.BuildType.GRADLE) {
- cmd = CommandBuilder.getGradleCommandLine(projectPath, "libertyStop", pathEnv, false);
+ cmd = CommandBuilder.getGradleCommandLine(projectPath, "libertyStop", pathEnv);
buildTypeName = "Gradle";
} else {
throw new Exception("Unexpected project build type: " + buildType + ". Project " + projectName
@@ -952,7 +907,9 @@ public void run() {
job.setUser(true);
runningJobs.put(job, Boolean.TRUE);
job.schedule();
- } catch (Exception e) {
+ } catch (
+
+ Exception e) {
String msg = "An error was detected while processing the Liberty Maven or Gradle stop command on project " + projectName;
if (Trace.isEnabled()) {
Trace.getTracer().trace(Trace.TRACE_TOOLS, msg, e);
@@ -1106,34 +1063,14 @@ public void setDashboardView(DashboardView dashboardView) {
}
/**
- * Returns true if the terminal tab associated with the input project was marked closed. False, otherwise.
+ * Returns true if the start process for the project is active. False, otherwise.
*
* @param projectName The name of the project.
*
- * @return true if the terminal tab associated with the input project was marked closed. False, otherwise.
- */
- public boolean isProjectTerminalTabMarkedClosed(String projectName) {
- return projectTabController.isProjectTabMarkedClosed(projectName);
- }
-
- /**
- * Registers the input terminal listener.
- *
- * @param projectName The name of the project for which the listener is registered.
- * @param listener The listener implementation.
- */
- public void registerTerminalListener(String projectName, TerminalListener listener) {
- projectTabController.registerTerminalListener(projectName, listener);
- }
-
- /**
- * Unregisters the input terminal listener.
- *
- * @param projectName The name of the project the input listener is registered for.
- * @param listener The listener implementation.
+ * @return true if the start process for the project is active. False, otherwise.
*/
- public void unregisterTerminalListener(String projectName, TerminalListener listener) {
- projectTabController.unregisterTerminalListener(projectName, listener);
+ public boolean isProjectStarted(String projectName) {
+ return processController.isProcessStarted(projectName);
}
/**
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/LibertyDevPlugin.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/LibertyDevPlugin.java
index d7a8f939..5555f02f 100644
--- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/LibertyDevPlugin.java
+++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/LibertyDevPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2022, 2023 IBM Corporation and others.
+* Copyright (c) 2022, 2025 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -20,28 +20,11 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.debug.DebugOptionsListener;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabFolder2Adapter;
-import org.eclipse.swt.custom.CTabFolder2Listener;
-import org.eclipse.swt.custom.CTabFolderEvent;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.tm.terminal.view.ui.interfaces.ITerminalsView;
-import org.eclipse.tm.terminal.view.ui.interfaces.IUIConstants;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import io.openliberty.tools.eclipse.logging.Trace;
-import io.openliberty.tools.eclipse.ui.launch.StartTab;
-import io.openliberty.tools.eclipse.ui.terminal.ProjectTab;
-import io.openliberty.tools.eclipse.ui.terminal.ProjectTabController;
-import io.openliberty.tools.eclipse.utils.Utils;
/**
* The activator class controls the plug-in life cycle
@@ -60,15 +43,6 @@ public class LibertyDevPlugin extends AbstractUIPlugin {
/** Resource Change listener instance. */
private IResourceChangeListener resourceChangeListener;
- /** Terminal view part listener instance. */
- private IPartListener2 viewPartListener;
-
- /** Terminal tab folder listener instance. */
- private CTabFolder2Listener tabFolderListener;
-
- /** Workbench page instance used to register the terminal part listener. */
- IWorkbenchPage iWorkbenchPage;
-
/**
* Constructor.
*/
@@ -116,13 +90,6 @@ public static LibertyDevPlugin getDefault() {
private void registerListeners() {
PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
registerResourceChangeListener();
- registerPartListener();
-
- // If the terminal tab is active on start, register the tab folder listener here; Otherwise,
- // the tab folder listener is registered when the terminal tab is opened.
- if (getTerminalViewTabFolder() != null) {
- registerCTabFolderListener();
- }
});
}
@@ -131,7 +98,6 @@ private void registerListeners() {
*/
private void unregisterListeners() {
unregisterResourceChangeListener();
- unregisterPartListener();
}
/**
@@ -151,132 +117,6 @@ private void registerResourceChangeListener() {
}
}
- /**
- * Registers a part listener to process Terminal tab view termination cleanup prior to terminal disposal. It processes all the
- * active terminal tabs when the terminal view is closed.
- */
- public void registerPartListener() {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_TOOLS, new Object[] { viewPartListener });
- }
-
- ProjectTabController tabController = ProjectTabController.getInstance();
- viewPartListener = new IPartListener2() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void partOpened(IWorkbenchPartReference partRef) {
- if (IUIConstants.ID.equals(partRef.getId())) {
- tabController.refreshViewPart();
- registerCTabFolderListener();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void partClosed(IWorkbenchPartReference partRef) {
- if (IUIConstants.ID.equals(partRef.getId())) {
- unregisterCTabFolderListener();
- tabController.processTerminalViewCleanup();
-
- }
- }
- };
-
- IWorkbench iwb = PlatformUI.getWorkbench();
- IWorkbenchWindow activeWindow = iwb.getActiveWorkbenchWindow();
- if (activeWindow != null) {
- iWorkbenchPage = activeWindow.getActivePage();
- if (iWorkbenchPage != null) {
- iWorkbenchPage.addPartListener(viewPartListener);
- }
- }
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_TOOLS, Utils.objectsToString(activeWindow, iWorkbenchPage, viewPartListener));
- }
- }
-
- /**
- * Registers a part listener to process Terminal tab view item termination cleanup prior to terminal disposal. It processes a
- * single active terminal tab closures.
- */
- public void registerCTabFolderListener() {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_TOOLS, new Object[] { tabFolderListener });
- }
-
- ProjectTabController tabController = ProjectTabController.getInstance();
- tabFolderListener = new CTabFolder2Adapter() {
-
- /**
- * {@inheritDoc}
- */
- public void close(CTabFolderEvent event) {
-
- CTabItem item = (CTabItem) event.item;
- if (item != null && !item.isDisposed()) {
- String projectName = null;
- try {
- projectName = (String) item.getData(StartTab.PROJECT_NAME);
- ProjectTab projectTab = tabController.getProjectTab(projectName);
- tabController.exitDevModeOnTerminalTab(projectName, projectTab);
- } catch (Exception e) {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_TOOLS, "Unable to close Tab item associated with project " + projectName,
- e);
- }
- }
- }
- }
- };
-
- CTabFolder tabFolder = getTerminalViewTabFolder();
- if (tabFolder != null) {
- tabFolder.addCTabFolder2Listener(tabFolderListener);
- }
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_TOOLS, Utils.objectsToString(tabFolder, tabFolderListener));
- }
- }
-
- /**
- * Returns the terminal tab view folder instance containing all active terminal tab items.
- *
- * @return The terminal tab view folder instance containing all active terminal tab items.
- */
- private CTabFolder getTerminalViewTabFolder() {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_TOOLS);
- }
-
- CTabFolder tabFolder = null;
- IWorkbench iwb = PlatformUI.getWorkbench();
- IWorkbenchWindow activeWindow = iwb.getActiveWorkbenchWindow();
- if (activeWindow != null) {
-
- IWorkbenchPage activePage = activeWindow.getActivePage();
- if (activePage != null) {
- IViewPart iViewPart = activePage.findView(IUIConstants.ID);
- if (iViewPart != null || (iViewPart instanceof ITerminalsView)) {
- ITerminalsView terminalView = (ITerminalsView) iViewPart;
- tabFolder = terminalView.getAdapter(CTabFolder.class);
- }
- }
- }
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_TOOLS, Utils.objectsToString(activeWindow, tabFolder));
- }
-
- return tabFolder;
- }
-
/**
* Removes the resource change listener registered with the Eclipse workspace.
*/
@@ -292,37 +132,4 @@ public void unregisterResourceChangeListener() {
Trace.getTracer().traceExit(Trace.TRACE_TOOLS, iWorkspace);
}
}
-
- /**
- * Removes the listener registered with the Eclipse terminal view folder.
- */
- public void unregisterCTabFolderListener() {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_TOOLS, tabFolderListener);
- }
-
- ProjectTabController tabController = ProjectTabController.getInstance();
- tabController.unregisterCTabFolder2Listener(tabFolderListener);
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_TOOLS, tabController);
- }
- }
-
- /**
- * Removes the listener registered to process terminal tab view item termination cleanup.
- */
- public void unregisterPartListener() {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_TOOLS, viewPartListener);
- }
-
- if (iWorkbenchPage != null) {
- iWorkbenchPage.removePartListener(viewPartListener);
- }
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_TOOLS, iWorkbenchPage);
- }
- }
}
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/DebugModeHandler.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/DebugModeHandler.java
index cbb5abf6..d61bd6bb 100644
--- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/DebugModeHandler.java
+++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/DebugModeHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2022, 2023 IBM Corporation and others.
+* Copyright (c) 2022, 2025 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -64,8 +64,6 @@
import io.openliberty.tools.eclipse.Project.BuildType;
import io.openliberty.tools.eclipse.logging.Trace;
import io.openliberty.tools.eclipse.ui.dashboard.DashboardView;
-import io.openliberty.tools.eclipse.ui.terminal.ProjectTabController;
-import io.openliberty.tools.eclipse.ui.terminal.TerminalListener;
import io.openliberty.tools.eclipse.utils.ErrorHandler;
public class DebugModeHandler {
@@ -290,24 +288,10 @@ protected IStatus run(IProgressMonitor monitor) {
}
};
- // Register a listener with the terminal tab controller. This listener handles cleanup when the terminal or terminal tab is
- // terminated while actively processing work.
- TerminalListener terminalListener = new TerminalListener() {
- /**
- * {@inheritDoc}
- */
- @Override
- public void cleanup() {
- job.cancel();
- }
- };
- devModeOps.registerTerminalListener(project.getIProject().getName(), terminalListener);
-
// Register a job change listener. This listener performs job completion processing.
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
- devModeOps.unregisterTerminalListener(projectName, terminalListener);
IStatus result = event.getResult();
IWorkbench workbench = PlatformUI.getWorkbench();
Display display = workbench.getDisplay();
@@ -453,7 +437,7 @@ private VirtualMachine attachJVM(String hostName, int port, AttachingConnector c
}
/**
- * Opens the debug perspective with the terminal and liberty dashboard views.
+ * Opens the debug perspective with the liberty dashboard view.
*/
private void openDebugPerspective() {
// Open the debug perspective.
@@ -473,22 +457,8 @@ private void openDebugPerspective() {
}
}
- // Open the terminal view.
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- try {
- IViewPart terminalView = activePage.findView(ProjectTabController.TERMINAL_VIEW_ID);
- if (terminalView == null) {
- activePage.showView(ProjectTabController.TERMINAL_VIEW_ID);
- }
- } catch (Exception e) {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, e.getMessage(), e);
- }
-
- ErrorHandler.processErrorMessage(e.getMessage(), e, false);
- }
-
// Open the dashboard view.
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
IViewPart dashboardView = activePage.findView(DashboardView.ID);
if (dashboardView == null) {
@@ -601,7 +571,6 @@ private String waitForSocketActivation(Project project, String host, String port
byte[] handshakeString = "JDWP-Handshake".getBytes(StandardCharsets.US_ASCII);
int retryLimit = 180;
- int envReadInterval = 2;
for (int retryCount = 0; retryCount < retryLimit; retryCount++) {
@@ -610,24 +579,9 @@ private String waitForSocketActivation(Project project, String host, String port
return null;
}
- // Check if the terminal was marked as closed, but to reduce contention on the UI thread,
- // not every time through the loop. We don't have a clean callback/notification that the
- // terminal session has been marked closed; we're actually going to read the UI element text
- if (retryCount % envReadInterval == 0) {
- IWorkbench workbench = PlatformUI.getWorkbench();
- Display display = workbench.getDisplay();
- DataHolder data = new DataHolder();
-
- display.syncExec(new Runnable() {
- public void run() {
- boolean isClosed = devModeOps.isProjectTerminalTabMarkedClosed(project.getIProject().getName());
- data.closed = isClosed;
- }
- });
-
- if (data.closed == true) {
- return null;
- }
+ // Abort if the project has stopped
+ if (!devModeOps.isProjectStarted(project.getIProject().getName())) {
+ return null;
}
try (Socket socket = new Socket(host, Integer.valueOf(port))) {
@@ -639,7 +593,7 @@ public void run() {
}
throw new Exception("Timed out trying to attach the debugger to JVM on host: " + host + " and port: " + port
- + ". If the server starts later you might try to manually create a Remote Java Application debug configuration and attach to the server. You can confirm the debug port used in the terminal output looking for a message like 'Liberty debug port: [ 63624 ]'.");
+ + ". If the server starts later you might try to manually connect the debugger from the launch in the Debug view You can confirm the debug port used in the console output looking for a message like 'Liberty debug port: [ 63624 ]'.");
}
/**
@@ -668,6 +622,6 @@ private Project getLibertyServerProject(Project project) throws Exception {
}
private class DataHolder {
- boolean closed;
+ boolean started;
}
}
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugReconnectActionDelegate.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugReconnectActionDelegate.java
index 7edc2b3e..4c81182c 100644
--- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugReconnectActionDelegate.java
+++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertyDebugReconnectActionDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2024 IBM Corporation and others.
+* Copyright (c) 2025 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -15,7 +15,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IDebugTarget;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate;
import org.eclipse.osgi.util.NLS;
@@ -34,16 +34,20 @@ public class LibertyDebugReconnectActionDelegate extends AbstractDebugActionDele
@Override
protected void doAction(Object object) {
- // This action can be performed from either a launch or debug target.
- // The object param will therefore either be an ILaunch or IDebugTarget object.
ILaunch launch = null;
IDebugTarget debugTarget = null;
+
+ // This action can be performed from a launch, a process, or a debug target.
+ // The object param will therefore be an ILaunch, an IProcess, or IDebugTarget object.
if (object instanceof ILaunch) {
launch = (ILaunch) object;
debugTarget = launch.getDebugTarget();
+ } else if (object instanceof IProcess) {
+ launch = ((IProcess) object).getLaunch();
+ debugTarget = launch.getDebugTarget();
} else {
debugTarget = (IDebugTarget) object;
- launch = DebugUIPlugin.getLaunch(object);
+ launch = debugTarget.getLaunch();
}
if (launch != null) {
@@ -64,13 +68,15 @@ protected void doAction(Object object) {
Project project = devModeOps.getProjectModel().getProject(projectName);
// Reconnect debugger
- if (!devModeOps.isProjectTerminalTabMarkedClosed(projectName)) {
+ if (devModeOps.isProjectStarted(projectName)) {
DebugModeHandler debugModeHandler = devModeOps.getDebugModeHandler();
debugModeHandler.startDebugAttacher(project, launch, null);
}
// Remove old debug target
- launch.removeDebugTarget(debugTarget);
+ if (debugTarget != null) {
+ launch.removeDebugTarget(debugTarget);
+ }
}
}
}
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.java
index 4b471bc2..5de9cabc 100644
--- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.java
+++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2023 IBM Corporation and others.
+ * Copyright (c) 2023, 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,12 +31,10 @@ public class Messages extends NLS {
public static String stop_no_project_found;
public static String stop_already_issued;
- public static String stop_terminal_not_active;
public static String stop_general_error;
public static String run_tests_no_project_found;
public static String run_tests_no_prior_start;
- public static String run_tests_terminal_not_active;
public static String run_tests_general_error;
public static String mvn_int_test_report_no_project_found;
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.properties b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.properties
index f1133792..a453c360 100644
--- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.properties
+++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/messages/Messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2023 IBM Corporation and others.
+# Copyright (c) 2023, 2025 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -25,12 +25,10 @@ start_container_general_error=An error was detected during the start in containe
stop_no_project_found=An error was detected when the stop request was processed. The object that represents the selected project was not found. When you use the Run Configuration launcher, be sure to select a project or project content first.
stop_already_issued=Unable to process the stop request on the {0} project, either because Liberty Tools did not previously issue a start request or because a stop request was already issued.
-stop_terminal_not_active=The terminal tab associated with the {0} project is not active.
stop_general_error=An error was detected when the stop request was processed on the {0} project.
run_tests_no_project_found=An error was detected when the run tests request was processed. The object that represents the selected project was not found. When you use the Run Configuration launcher, be sure to select a project or project content first.
run_tests_no_prior_start=Either no start request was issued first or the stop request was already issued on the {0} project. Issue a start request before you issue the run tests request.
-run_tests_terminal_not_active=The terminal tab that is running the {0} project is not active due to an unexpected error or external action. Review the terminal output for more details. After the circumstance that caused the terminal tab to be inactive is determined and resolved, issue a start request before you issue the run tests request.
run_tests_general_error=An error was detected when the run tests request was processed on the {0} project.
mvn_int_test_report_no_project_found=An error was detected when the view integration test report request was processed. The object that represents the selected project was not found. When you use the Run Configuration launcher, be sure to select a project or project content first.
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/process/LibertyDebugEventListener.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/process/LibertyDebugEventListener.java
new file mode 100644
index 00000000..14de1a52
--- /dev/null
+++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/process/LibertyDebugEventListener.java
@@ -0,0 +1,38 @@
+package io.openliberty.tools.eclipse.process;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.model.IProcess;
+
+import io.openliberty.tools.eclipse.DevModeOperations;
+
+public class LibertyDebugEventListener implements IDebugEventSetListener {
+
+ private String projectName;
+
+ public LibertyDebugEventListener(String projectName) {
+ this.projectName = projectName;
+ }
+
+ @Override
+ public void handleDebugEvents(DebugEvent[] events) {
+ for (int i = 0; i < events.length; i++) {
+ Object source = events[i].getSource();
+
+ if (source instanceof IProcess && events[i].getKind() == DebugEvent.TERMINATE) {
+
+ // This is an IProcess terminate event. Check if the IProcess matches
+ IProcess iProcess = (IProcess) source;
+ if (projectName.equals(iProcess.getLabel())) {
+ // We match - cleanup
+ DevModeOperations devModeOps = DevModeOperations.getInstance();
+ devModeOps.cleanupProcess(projectName);
+
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ }
+ }
+ }
+ }
+
+}
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/process/ProcessController.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/process/ProcessController.java
new file mode 100644
index 00000000..6a2982eb
--- /dev/null
+++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/process/ProcessController.java
@@ -0,0 +1,188 @@
+/*******************************************************************************
+* Copyright (c) 2022, 2025 IBM Corporation and others.
+*
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v. 2.0 which is available at
+* http://www.eclipse.org/legal/epl-2.0.
+*
+* SPDX-License-Identifier: EPL-2.0
+*
+* Contributors:
+* IBM Corporation - initial implementation
+*******************************************************************************/
+package io.openliberty.tools.eclipse.process;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.eclipse.debug.core.DebugPlugin;
+
+import io.openliberty.tools.eclipse.logging.Trace;
+import io.openliberty.tools.eclipse.utils.Utils;
+
+/**
+ * Manages the set up running dev mode processes.
+ */
+public class ProcessController {
+
+ /** The set of processes associated with different application projects. */
+ private static final ConcurrentHashMap projectProcessMap = new ConcurrentHashMap();
+
+ /** Instance of this class */
+ private static ProcessController instance;
+
+ /**
+ * Constructor.
+ */
+ private ProcessController() {
+ }
+
+ /**
+ * Returns a singleton instance of this class.
+ *
+ * @return A singleton instance of this class.
+ */
+ public static ProcessController getInstance() {
+ if (instance == null) {
+ instance = new ProcessController();
+ }
+
+ return instance;
+ }
+
+ /**
+ * Runs the specified command as a system process.
+ *
+ * @param projectName The application project name.
+ * @param projectPath The application project path.
+ * @param command The command to execute.
+ * @param envs The environment properties to be set for the process.
+ *
+ * @throws IOException
+ */
+ public Process runProcess(String projectName, String projectPath, String command, List envs, boolean printCmd)
+ throws IOException {
+
+ List commandList = new ArrayList();
+
+ // Add exec statements and print commands
+ if (Utils.isWindows()) {
+ commandList.add("cmd.exe");
+ commandList.add("/c");
+ if (printCmd) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("echo && ");
+ sb.append("echo Liberty Tools running command: " + command);
+ sb.append(" from directory: " + projectPath + " && ");
+ sb.append(command);
+ command = sb.toString();
+ }
+
+ } else {
+ commandList.add("/bin/sh");
+ if (printCmd) {
+ commandList.add("-xc");
+ } else {
+ commandList.add("-c");
+ }
+ }
+
+ commandList.add(command);
+
+ ProcessBuilder builder = new ProcessBuilder(commandList);
+
+ builder.directory(new File(projectPath));
+
+ // Add environment variables
+ Map environment = builder.environment();
+
+ for (String env : envs) {
+ String[] keyValues = env.split("=");
+ String key = keyValues[0];
+ String value = keyValues[1];
+ environment.put(key, value);
+ }
+
+ Process process = builder.start();
+
+ projectProcessMap.put(projectName, process);
+
+ addTerminateListener(projectName);
+
+ return process;
+ }
+
+ private void addTerminateListener(String projectName) {
+
+ DebugPlugin.getDefault().addDebugEventListener(new LibertyDebugEventListener(projectName));
+
+ }
+
+ /**
+ * Writes the input data to the running process associated with the input project name.
+ *
+ * @param projectName The application project name.
+ * @param content The data to write.
+ *
+ * @throws Exception
+ */
+ public void writeToProcessStream(String projectName, String data) throws Exception {
+ Process process = projectProcessMap.get(projectName);
+
+ if (process == null) {
+ String msg = "Unable to write to the process associated with project " + projectName
+ + ". Internal process object not found.";
+ if (Trace.isEnabled()) {
+ Trace.getTracer().trace(Trace.TRACE_UI, msg + ". Data to write: " + new String(data));
+ }
+ throw new Exception(msg);
+ }
+
+ PrintWriter writer = new PrintWriter(process.getOutputStream());
+ writer.println(data);
+ writer.flush();
+ }
+
+ /**
+ * Returns true if there is a process associated with this project and the
+ * process is alive.
+ *
+ * @param projectName - The name of the project to check.
+ *
+ * @return True if the process is alive. False otherwise.
+ */
+ public boolean isProcessStarted(String projectName) {
+ Process process = projectProcessMap.get(projectName);
+ if (process != null) {
+ return process.isAlive();
+ }
+
+ return false;
+ }
+
+ /**
+ * Cleans up any objects associated with this project.
+ *
+ * @param projectName - The name of the project to clean up.
+ */
+ public void cleanup(String projectName) {
+ projectProcessMap.remove(projectName);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Class: ").append(instance.getClass().getName()).append(": ");
+ sb.append("projectProcessMap size: ").append(projectProcessMap.size()).append(", ");
+ sb.append("projectProcessMap: ").append(projectProcessMap);
+ return sb.toString();
+ }
+}
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/StartTab.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/StartTab.java
index 7273a15b..0df51592 100644
--- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/StartTab.java
+++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/StartTab.java
@@ -218,6 +218,16 @@ public boolean isValid(ILaunchConfiguration config) {
return false;
}
}
+
+ // Check if project is already started
+ if (devModeOps.isProjectStarted(configProjectName)) {
+ if (Trace.isEnabled()) {
+ Trace.getTracer().trace(Trace.TRACE_TOOLS, "The start request was already issued on project " + configProjectName);
+ }
+
+ super.setErrorMessage(NLS.bind(Messages.start_already_issued, configProjectName));
+ return false;
+ }
} catch (CoreException ce) {
String msg = "Error getting project name";
if (Trace.isEnabled()) {
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartAction.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartAction.java
index d572e699..647e20ed 100644
--- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartAction.java
+++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartAction.java
@@ -104,6 +104,17 @@ public static void run(IProject iProject, String mode) throws Exception {
DevModeOperations devModeOps = DevModeOperations.getInstance();
devModeOps.verifyProjectSupport(iProject);
+ // Check if project is already started
+ String projectName = iProject.getName();
+ if (devModeOps.isProjectStarted(projectName)) {
+
+ if (Trace.isEnabled()) {
+ Trace.getTracer().trace(Trace.TRACE_TOOLS, "The start request was already issued on project " + projectName);
+ }
+ ErrorHandler.processErrorMessage(NLS.bind(Messages.start_already_issued, projectName), true);
+ return;
+ }
+
// Determine what configuration to use.
LaunchConfigurationHelper launchConfigHelper = LaunchConfigurationHelper.getInstance();
ILaunchConfiguration configuration = launchConfigHelper.getLaunchConfiguration(iProject, mode, RuntimeEnv.LOCAL);
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartInContainerAction.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartInContainerAction.java
index 533fe833..6b258c51 100644
--- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartInContainerAction.java
+++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartInContainerAction.java
@@ -107,6 +107,17 @@ public static void run(IProject iProject, String mode) throws Exception {
DevModeOperations devModeOps = DevModeOperations.getInstance();
devModeOps.verifyProjectSupport(iProject);
+ // Check if project is already started
+ String projectName = iProject.getName();
+ if (devModeOps.isProjectStarted(projectName)) {
+
+ if (Trace.isEnabled()) {
+ Trace.getTracer().trace(Trace.TRACE_TOOLS, "The start in container request was already issued on project " + projectName);
+ }
+ ErrorHandler.processErrorMessage(NLS.bind(Messages.start_container_already_issued, projectName), true);
+ return;
+ }
+
// Determine what configuration to use.
LaunchConfigurationHelper launchConfigHelper = LaunchConfigurationHelper.getInstance();
ILaunchConfiguration configuration = launchConfigHelper.getLaunchConfiguration(iProject, mode, RuntimeEnv.CONTAINER);
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/LocalDevModeLauncherDelegate.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/LocalDevModeLauncherDelegate.java
deleted file mode 100644
index 1a02ff84..00000000
--- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/LocalDevModeLauncherDelegate.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2022, 2023 IBM Corporation and others.
-*
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v. 2.0 which is available at
-* http://www.eclipse.org/legal/epl-2.0.
-*
-* SPDX-License-Identifier: EPL-2.0
-*
-* Contributors:
-* IBM Corporation - initial implementation
-*******************************************************************************/
-package io.openliberty.tools.eclipse.ui.terminal;
-
-import java.util.Map;
-
-import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
-import org.eclipse.tm.terminal.connector.local.launcher.LocalLauncherDelegate;
-import org.eclipse.tm.terminal.view.core.interfaces.constants.ITerminalsConnectorConstants;
-import org.eclipse.tm.terminal.view.ui.launcher.LauncherDelegateManager;
-
-import io.openliberty.tools.eclipse.logging.Trace;
-
-/**
- * Local launcher delegate extension.
- */
-public class LocalDevModeLauncherDelegate extends LocalLauncherDelegate {
-
- /**
- * LocalDevModeLauncherDelegate extension id.
- */
- public static final String id = "io.openliberty.tools.eclipse.ui.terminal.local.devmode.launcher.delegate";
-
- /**
- * Returns an instance of the LocalTerminalLauncherDelegate. Note that there should only be a single delegate instance being used.
- * TerminalService.createTerminalConnector by default does not require the delegate instances to be unique, but the first instance
- * created is returned.
- *
- * @return An instance of the LocalTerminalLauncherDelegate
- */
- public static LocalDevModeLauncherDelegate getInstance() {
- return (LocalDevModeLauncherDelegate) LauncherDelegateManager.getInstance().getLauncherDelegate(id, false);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ITerminalConnector createTerminalConnector(Map properties) {
- ITerminalConnector connector = null;
- String projectName = (String) properties.get(ITerminalsConnectorConstants.PROP_DATA);
-
- if (projectName != null) {
- ProjectTabController ptc = ProjectTabController.getInstance();
- connector = ptc.getProjectConnector(projectName);
-
- if (connector == null) {
- connector = super.createTerminalConnector(properties);
- ptc.setProjectConnector(projectName, connector);
-
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI,
- "New terminal connection created for project: " + projectName + ". Connector: " + connector);
- }
-
- }
- } else {
- Trace.getTracer().trace(Trace.TRACE_UI,
- "The project name was not found in the list of properties received from the caller. This maybe a recovery case currently not supported. Properties: "
- + properties);
- }
-
- return connector;
- }
-}
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/ProjectTab.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/ProjectTab.java
deleted file mode 100644
index dd944db3..00000000
--- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/ProjectTab.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2022, 2023 IBM Corporation and others.
-*
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v. 2.0 which is available at
-* http://www.eclipse.org/legal/epl-2.0.
-*
-* SPDX-License-Identifier: EPL-2.0
-*
-* Contributors:
-* IBM Corporation - initial implementation
-*******************************************************************************/
-package io.openliberty.tools.eclipse.ui.terminal;
-
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
-import org.eclipse.tm.terminal.view.core.TerminalServiceFactory;
-import org.eclipse.tm.terminal.view.core.interfaces.ITerminalService;
-import org.eclipse.tm.terminal.view.core.interfaces.constants.ITerminalsConnectorConstants;
-import org.eclipse.tm.terminal.view.ui.interfaces.ITerminalsView;
-import org.eclipse.tm.terminal.view.ui.interfaces.IUIConstants;
-import org.eclipse.tm.terminal.view.ui.tabs.TabFolderManager;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
-
-import io.openliberty.tools.eclipse.logging.Trace;
-import io.openliberty.tools.eclipse.ui.dashboard.DashboardView;
-import io.openliberty.tools.eclipse.ui.launch.StartTab;
-import io.openliberty.tools.eclipse.utils.Utils;
-
-/**
- * Represents a terminal tab item within the terminal view associated with a running application project.
- */
-public class ProjectTab {
-
- /** The name of the application project associated with this terminal. */
- private String projectName;
-
- /**
- * Terminal connector instance set by the LocalDevModeLauncherDelegate when the connector is created during initial connection.
- */
- private ITerminalConnector connector;
-
- /** Terminal view tab item associated with the running application project. */
- private CTabItem projectTab;
-
- /** Terminal service. */
- private ITerminalService terminalService;
-
- /** Terminal tab listener associated with this terminal tab. */
- private TerminalTabListenerImpl tabListener;
-
- /** State of this object. */
- private State state;
-
- /** Tab image */
- private Image libertyImage;
-
- /** States. */
- public static enum State {
- INACTIVE, STARTED, STOPPED
- };
-
- /** The NIX shell on which the terminal commands are processed. */
- private final String NIX_SHELL_COMMAND = "/bin/sh";
-
- /**
- * Constructor.
- *
- * @param projectName The application project name.
- */
- public ProjectTab(String projectName) {
- this.projectName = projectName;
- this.terminalService = TerminalServiceFactory.getService();
- this.tabListener = new TerminalTabListenerImpl(projectName);
- this.libertyImage = Utils.getImage(PlatformUI.getWorkbench().getDisplay(), DashboardView.LIBERTY_LOGO_PATH);
-
- state = State.INACTIVE;
- }
-
- /**
- * Sets the connector associated with this terminal.
- *
- * @param connector The terminal connector for terminal interaction.
- */
- public void setConnector(ITerminalConnector connector) {
- this.connector = connector;
- }
-
- /**
- * Returns the connector associated with this terminal.
- *
- * @return The connector associated with this terminal.
- */
- public ITerminalConnector getConnector() {
- return connector;
- }
-
- /**
- * Launches a terminal and runs the input command.
- *
- * @param projectPath The application project path.
- * @param command The command to run on the terminal.
- * @param envs The list of environment properties to be set on the terminal.
- */
- public void runCommand(String projectPath, String command, List envs) {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_UI, new Object[] { projectPath, command, envs });
- }
-
- ITerminalService.Done done = new ITerminalService.Done() {
- @Override
- public void done(IStatus status) {
- // The console tab for the associated project opened.
- if (status.getCode() == IStatus.OK) {
-
- // Save the object representing the currently active console tab instance.
- projectTab = getActiveProjectTab();
-
- // Update the tab image with the Liberty logo.
- updateImage();
-
- // Register a terminal tab disposed listener.
- terminalService.addTerminalTabListener(tabListener);
-
- // Update the state.
- setState(State.STARTED);
-
- // Save the project name in the project tab item object. This is needed to be
- // able to reliably identify this project tab item during cleanup.
- projectTab.setData(StartTab.PROJECT_NAME, projectName);
- }
- }
- };
-
- terminalService.openConsole(getProperties(projectPath, envs, command), done);
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_UI);
- }
- }
-
- /**
- * Returns a map of properties needed to launch a terminal.
- *
- * @param projectPath The application project path.
- * @param envs Environment variables to be set.
- * @param command The command to execute.
- *
- * @return A map of properties needed to launch a terminal.
- */
- private Map getProperties(String projectPath, List envs, String command) {
- HashMap properties = new HashMap();
- properties.put(ITerminalsConnectorConstants.PROP_TITLE, projectName);
- properties.put(ITerminalsConnectorConstants.PROP_ENCODING, "UTF-8");
- properties.put(ITerminalsConnectorConstants.PROP_DELEGATE_ID, LocalDevModeLauncherDelegate.id);
- properties.put(ITerminalsConnectorConstants.PROP_DATA, projectName);
- properties.put(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT, Boolean.TRUE);
- properties.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, Boolean.TRUE);
- properties.put(ITerminalsConnectorConstants.PROP_DATA_NO_RECONNECT, Boolean.TRUE);
- properties.put(ITerminalsConnectorConstants.PROP_PROCESS_ARGS, command);
- properties.put(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT, envs.toArray(new String[envs.size()]));
- properties.put(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR, projectPath);
-
- // WIN: Terminal command is run using whatever is specified under the ComSpec environment variable, or cmd.exe by default.
- // NIX: Terminal command is run using the system shell.
- if (!Utils.isWindows()) {
- properties.put(ITerminalsConnectorConstants.PROP_PROCESS_PATH, NIX_SHELL_COMMAND);
- }
-
- return properties;
- }
-
- /**
- * Updates the tab image with the Liberty logo.
- */
- private void updateImage() {
- projectTab.getDisplay().asyncExec(() -> {
- projectTab.setImage(libertyImage);
- });
- }
-
- /**
- * Writes to the terminal's output stream.
- *
- * @param content The bytes to be written to the terminal.
- * @param cleanup Indicates whether or not this call was made as part of cleanup or not.
- *
- * @throws Exception
- */
- public void writeToStream(byte[] content, boolean cleanup) throws Exception {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_UI, new Object[] { new String(content), cleanup });
- }
-
- if (connector == null) {
- String msg = "Unable to write to terminal. Terminal connector associated with project " + projectName + " was not found.";
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, msg + "Content: " + new String(content));
- }
- throw new Exception(msg);
- }
-
- OutputStream terminalStream = connector.getTerminalToRemoteStream();
- if (terminalStream == null) {
- String msg = "Unable to write to terminal. Terminal remote stream associated with project " + projectName + " was not found.";
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, msg + " Connector: " + connector);
- }
- throw new Exception(msg);
- }
-
- if (!cleanup) {
- showTerminalView();
- }
-
- terminalStream.write(content);
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_UI);
- }
- }
-
- /**
- * Returns the active CTabItem object associated with the currently active terminal tab.
- *
- * @return The active CTabItem object associated with the currently active terminal tab.
- */
- private CTabItem getActiveProjectTab() {
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- if (activePage == null) {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, "No active page found. No-op.");
- }
- return null;
- }
-
- IViewPart viewPart = activePage.findView(IUIConstants.ID);
- if (viewPart == null || !(viewPart instanceof ITerminalsView)) {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, "No terminal view found. No-op. Active view label: " + activePage.getLabel());
- }
- return null;
- }
-
- ITerminalsView view = (ITerminalsView) viewPart;
- TabFolderManager manager = view.getAdapter(TabFolderManager.class);
-
- if (manager == null) {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, "No tab folder manager found. No-op. Active view title: " + view.getTitle());
- }
- return null;
- }
-
- CTabItem item = manager.getActiveTabItem();
-
- return item;
- }
-
- /**
- * Returns the tab's title text.
- *
- * @return The tab's title text.
- */
- public String getTitle() {
- String title = null;
- if (projectTab != null) {
- title = projectTab.getText();
- }
-
- return title;
- }
-
- /**
- * Returns the current state.
- *
- * @return the current state.
- */
- public State getState() {
- return state;
- }
-
- /**
- * Sets the state of this object.
- *
- * @param newState The new state.
- */
- public synchronized void setState(State newState) {
- this.state = newState;
- }
-
- /**
- * Performs cleanup.
- */
- public void cleanup() {
- // Remove the registered listener from the calling service.
- terminalService.removeTerminalTabListener(tabListener);
-
- // Dispose of the liberty image associated with this tab.
- if (libertyImage != null) {
- libertyImage.dispose();
- }
- }
-
- /**
- * Shows the terminal view in the foreground and focuses on it.
- */
- public void showTerminalView() {
- // Bring the main terminal view to the front.
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- if (activePage == null) {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, "No active page found. No-op.");
- }
- return;
- }
-
- IViewPart viewPart = null;
- try {
- viewPart = activePage.showView(IUIConstants.ID, null, IWorkbenchPage.VIEW_ACTIVATE);
- if (viewPart == null) {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, "No terminal view found. No-op. Active view label: " + activePage.getLabel());
- }
- return;
- }
- activePage.bringToTop(viewPart);
-
- } catch (Exception e) {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, "Error while attempting to show terminal view. Active view title: "
- + ((viewPart != null) ? viewPart.getTitle() : "null"));
- }
- return;
- }
-
- // Bring tab item associated with the application project to the front.
- if (viewPart instanceof ITerminalsView) {
- ITerminalsView view = (ITerminalsView) viewPart;
- TabFolderManager manager = view.getAdapter(TabFolderManager.class);
-
- if (manager == null) {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI,
- "No tab folder manager found. No-op. Terminal view tab title: " + view.getTitle());
- }
- return;
- }
-
- manager.bringToTop(projectTab);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("Class: ").append(this.getClass().getName()).append(": ");
- sb.append("projectName: ").append(projectName).append(", ");
- sb.append("State: ").append(state).append(", ");
- sb.append("Connector: ").append(connector).append(", ");
- sb.append("TabListener: ").append(tabListener);
- return sb.toString();
- }
-}
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/ProjectTabController.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/ProjectTabController.java
deleted file mode 100644
index 37d612e0..00000000
--- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/ProjectTabController.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2022, 2024 IBM Corporation and others.
-*
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v. 2.0 which is available at
-* http://www.eclipse.org/legal/epl-2.0.
-*
-* SPDX-License-Identifier: EPL-2.0
-*
-* Contributors:
-* IBM Corporation - initial implementation
-*******************************************************************************/
-package io.openliberty.tools.eclipse.ui.terminal;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabFolder2Listener;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
-import org.eclipse.tm.terminal.view.ui.interfaces.ITerminalsView;
-import org.eclipse.tm.terminal.view.ui.interfaces.IUIConstants;
-import org.eclipse.tm.terminal.view.ui.manager.ConsoleManager;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-import io.openliberty.tools.eclipse.DevModeOperations;
-import io.openliberty.tools.eclipse.logging.Trace;
-import io.openliberty.tools.eclipse.ui.terminal.ProjectTab.State;
-import io.openliberty.tools.eclipse.utils.Utils;
-
-/**
- * Manages a set of terminal view project tab instances.
- */
-public class ProjectTabController {
-
- /** Terminal view ID. */
- public static final String TERMINAL_VIEW_ID = "org.eclipse.tm.terminal.view.ui.TerminalsView";
-
- /** The set of active Terminal associated with different application projects. */
- private static final ConcurrentHashMap projectTabMap = new ConcurrentHashMap();
-
- /** The set of terminal listeners associated with the different application projects. */
- private static final ConcurrentHashMap> projectTerminalListenerMap = new ConcurrentHashMap>();
-
- /** TerminalManager instance. */
- private static ProjectTabController instance;
-
- /** Terminal console manager instance. */
- private ConsoleManager consoleMgr;
-
- /** The active terminal view part. It is refreshed when the terminal reopens. */
- private IViewPart viewPart;
-
- /**
- * Constructor.
- */
- private ProjectTabController() {
- this.consoleMgr = ConsoleManager.getInstance();
- }
-
- /**
- * Returns a singleton instance of this class.
- *
- * @return A singleton instance of this class.
- */
- public static ProjectTabController getInstance() {
- if (instance == null) {
- instance = new ProjectTabController();
- }
-
- return instance;
- }
-
- /**
- * Runs the specified command on a terminal.
- *
- * @param projectName The application project name.
- * @param projectPath The application project path.
- * @param command The command to execute on the terminal.
- * @param envs The environment properties to be set on the terminal.
- */
- public void runOnTerminal(String projectName, String projectPath, String command, List envs) {
- ProjectTab projectTab = new ProjectTab(projectName);
- projectTabMap.put(projectName, projectTab);
- projectTab.runCommand(projectPath, command, envs);
- }
-
- /**
- * Writes the input data to the terminal tab associated with the input project name.
- *
- * @param projectName The application project name.
- * @param content The data to write.
- *
- * @throws Exception
- */
- public void writeToTerminalStream(String projectName, byte[] data) throws Exception {
- ProjectTab projectTab = projectTabMap.get(projectName);
-
- if (projectTab == null) {
- String msg = "Unable to write to the terminal associated with project " + projectName
- + ". Internal poject tab object not found.";
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, msg + ". Data to write: " + new String(data));
- }
- throw new Exception(msg);
- }
-
- projectTab.writeToStream(data, false);
- }
-
- /**
- * Returns the terminal tab item associated with the specified project name and connector.
- *
- * @param projectName The application project name.
- * @param connector The terminal connector object associated with input project name.
- *
- * @return the terminal tab item associated with the specified project name and connector.
- */
- public CTabItem getTerminalTabItem(String projectName, ITerminalConnector connector) {
- CTabItem item = null;
-
- if (connector != null) {
- item = consoleMgr.findConsole(IUIConstants.ID, null, projectName, connector, null);
- }
-
- return item;
- }
-
- /**
- * Returns the ProjectTab instance associated with the specified project name.
- *
- * @param projectName The application project name.
- *
- * @return the ProjectTab instance associated with the specified project name.
- */
- public ProjectTab getProjectTab(String projectName) {
- return projectTabMap.get(projectName);
- }
-
- public State getTerminalState(String projectName) {
- ProjectTab projectTab = projectTabMap.get(projectName);
- if (projectTab != null) {
- return projectTab.getState();
- } else {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, "Internal project tab object associated with project " + projectName
- + " was not found. ProjectTabMap: " + projectTabMap);
- }
- }
-
- return null;
- }
-
- public void setTerminalState(String projectName, State newState) throws Exception {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_UI, new Object[] { projectName, newState });
- }
-
- ProjectTab projectTab = projectTabMap.get(projectName);
- if (projectTab == null) {
- String msg = "Internal project tab object associated with project: " + projectName + " was not found. Unable to set state.";
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, msg);
- }
- throw new Exception();
- }
-
- projectTab.setState(newState);
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_UI, projectTab.getState());
- }
- }
-
- /**
- * Returns the connector associated with a terminal running the application represented by the input project name.
- *
- * @param projectName The application project name.
- *
- * @return The Connector associated with a terminal running the application represented by the input project name.
- */
- public ITerminalConnector getProjectConnector(String projectName) {
- ITerminalConnector connector = null;
- ProjectTab projectTab = projectTabMap.get(projectName);
-
- if (projectTab != null) {
- connector = projectTab.getConnector();
- } else {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, "Internal project tab object associated with project " + projectName
- + " was not found. Unable to retrieve connector. ProjectTabMap: " + projectTabMap);
- }
- }
-
- return connector;
- }
-
- /**
- * Saves the terminal connector instance on the terminal object represented by the input project name.
- *
- * @param projectName The application project name.
- * @param terminalConnector The terminal connector instance.
- */
- public void setProjectConnector(String projectName, ITerminalConnector terminalConnector) {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_UI, new Object[] { projectName, terminalConnector, projectTabMap.size() });
- }
-
- ProjectTab projectTab = projectTabMap.get(projectName);
- if (projectTab != null) {
- projectTab.setConnector(terminalConnector);
- projectTabMap.put(projectName, projectTab);
- } else {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, "Internal project tab object associated with project " + projectName
- + " was not found. Unable to retrieve connector. ProjectTabMap: " + projectTabMap);
- }
- }
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_UI, projectTabMap.size());
- }
- }
-
- /**
- * Returns true if the tab title associated with the input project name was marked as closed. False, otherwise.
- *
- * @param projectName The application project name.
- *
- * @return true if the tab title associated with the input project name was marked as closed. False, otherwise.
- */
- public boolean isProjectTabMarkedClosed(String projectName) {
- ProjectTab projectTab = projectTabMap.get(projectName);
- if (projectTab != null) {
- String tabTitle = projectTab.getTitle();
- if (tabTitle != null && tabTitle.startsWith("")) {
- return true;
- }
- } else {
- // At this point, the project is no longer in the projectTabMap. Either it was never added (this project
- // was never started) or it has already stopped. In either case, the project tab is unavailable (e.g. "closed")
- // for this project. This is particularly needed during debugger restart processing. If the server has stopped
- // the restart uses this method to indicate it can abort reconnecting.
- return true;
- }
-
- return false;
- }
-
- /**
- * Exits Liberty dev mode running on all active terminal tabs in the view.
- */
- public void processTerminalViewCleanup() {
- for (Map.Entry entry : projectTabMap.entrySet()) {
- String projectName = entry.getKey();
- ProjectTab projectTab = entry.getValue();
- exitDevModeOnTerminalTab(projectName, projectTab);
- }
- }
-
- /**
- * Exits dev mode processing running on a terminal tab.
- *
- * @param projectName The name of the project associated with the dev mode process.
- * @param projectTab The project tab object representing the terminal tab where dev mode is running.
- */
- public void exitDevModeOnTerminalTab(String projectName, ProjectTab projectTab) {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_UI, new Object[] { projectName, projectTab });
- }
-
- if (projectTab != null) {
- try {
- // Run the exit command on the terminal. This will trigger dev mode cleanup processing.
- projectTab.writeToStream(DevModeOperations.DEVMODE_COMMAND_EXIT.getBytes(), true);
-
- // Wait for the command issued to take effect. This also handles some cases where
- // the terminal tab/view is terminated while dev mode is starting, but the command
- // is not processed until dev mode finishes starting. On Mac or Linux, a
- // runtime shutdown hook mechanism will make sure that dev mode cleanup is processed in
- // "all" cases.
- // Note that this is a best effort approach workaround for Windows where the runtime
- // shutdown hooks are not called.
- TimeUnit.MILLISECONDS.sleep(100);
- } catch (Exception e) {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, "Failed to exit dev mode associated with project " + projectName, e);
- }
- }
- }
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_UI, projectName);
- }
-
- }
-
- /**
- * Cleans up the objects associated with the terminal object represented by the specified project name.
- *
- * @param projectName The application project name.
- */
- public void processTerminalTabCleanup(String projectName) {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_UI, new Object[] { projectName, projectTabMap.size() });
- }
-
- // Call the terminal object to do further cleanup.
- ProjectTab projectTab = projectTabMap.get(projectName);
- if (projectTab != null) {
- projectTab.cleanup();
- } else {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, "Internal project tab object associated with project " + projectName
- + " was not found. ProjectTabMap: " + projectTabMap);
- }
- }
-
- // Remove the connector from the connector map cache.
- projectTabMap.remove(projectName);
-
- // Call cleanup on all registered terminal listeners and remove them from the terminal map cache.
- List listeners = projectTerminalListenerMap.get(projectName);
- if (listeners != null) {
- synchronized (listeners) {
- Iterator i = listeners.iterator();
- while (i.hasNext()) {
- i.next().cleanup();
- }
- }
- }
- projectTerminalListenerMap.remove(projectName);
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_UI,
- Utils.objectsToString(projectName, projectTabMap.size(), projectTerminalListenerMap.size()));
- }
- }
-
- /**
- * Registers the input terminal listener.
- *
- * @param projectName The name of the project for which the listener is registered.
- * @param listener The listener implementation.
- */
- public void registerTerminalListener(String projectName, TerminalListener listener) {
- List listeners = projectTerminalListenerMap.get(projectName);
- if (listeners == null) {
- listeners = Collections.synchronizedList(new ArrayList());
- }
-
- listeners.add(listener);
- projectTerminalListenerMap.put(projectName, listeners);
- }
-
- /**
- * Unregisters the input terminal listener.
- *
- * @param projectName The name of the project the input listener is registered for.
- * @param listener The listener implementation.
- */
- public void unregisterTerminalListener(String projectName, TerminalListener listener) {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_UI, new Object[] { projectName, listener, projectTerminalListenerMap.size() });
- }
-
- List listeners = projectTerminalListenerMap.get(projectName);
- if (listeners != null) {
- listeners.remove(listener);
- projectTerminalListenerMap.put(projectName, listeners);
- }
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_UI, projectTerminalListenerMap.size());
- }
- }
-
- /**
- * Removes the listener registered with the Eclipse terminal view folder.
- *
- * @param listener The listener to remove.
- */
- public void unregisterCTabFolder2Listener(CTabFolder2Listener listener) {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_UI, new Object[] { listener, viewPart });
- }
-
- if (viewPart != null || (viewPart instanceof ITerminalsView)) {
- ITerminalsView terminalView = (ITerminalsView) viewPart;
- CTabFolder tabFolder = terminalView.getAdapter(CTabFolder.class);
-
- if (tabFolder != null) {
- tabFolder.removeCTabFolder2Listener(listener);
- }
- }
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_UI);
- }
- }
-
- /**
- * Refreshes the active terminal view part.
- */
- public void refreshViewPart() {
- if (Trace.isEnabled()) {
- Trace.getTracer().traceEntry(Trace.TRACE_UI, viewPart);
- }
-
- IWorkbenchWindow iWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (iWorkbenchWindow != null) {
- IWorkbenchPage activePage = iWorkbenchWindow.getActivePage();
-
- if (activePage != null) {
- viewPart = activePage.findView(IUIConstants.ID);
- }
- }
-
- if (Trace.isEnabled()) {
- Trace.getTracer().traceExit(Trace.TRACE_UI, viewPart);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("Class: ").append(instance.getClass().getName()).append(": ");
- sb.append("projectTabMap size: ").append(projectTabMap.size()).append(", ");
- sb.append("projectTabMap: ").append(projectTabMap);
- return sb.toString();
- }
-}
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/TerminalListener.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/TerminalListener.java
deleted file mode 100644
index bb58bf38..00000000
--- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/TerminalListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2022 IBM Corporation and others.
-*
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v. 2.0 which is available at
-* http://www.eclipse.org/legal/epl-2.0.
-*
-* SPDX-License-Identifier: EPL-2.0
-*
-* Contributors:
-* IBM Corporation - initial implementation
-*******************************************************************************/
-package io.openliberty.tools.eclipse.ui.terminal;
-
-/**
- * Terminal Listener
- */
-public interface TerminalListener {
-
- /**
- * Processes cleanup logic.
- */
- public void cleanup();
-}
diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/TerminalTabListenerImpl.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/TerminalTabListenerImpl.java
deleted file mode 100644
index 8615e282..00000000
--- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/terminal/TerminalTabListenerImpl.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2022, 2023 IBM Corporation and others.
-*
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v. 2.0 which is available at
-* http://www.eclipse.org/legal/epl-2.0.
-*
-* SPDX-License-Identifier: EPL-2.0
-*
-* Contributors:
-* IBM Corporation - initial implementation
-*******************************************************************************/
-package io.openliberty.tools.eclipse.ui.terminal;
-
-import org.eclipse.tm.terminal.view.core.interfaces.ITerminalTabListener;
-
-import io.openliberty.tools.eclipse.logging.Trace;
-
-/**
- * Listens for terminal tab termination.
- */
-public class TerminalTabListenerImpl implements ITerminalTabListener {
-
- /**
- * The name of the project being processed.
- */
- String projectName;
-
- /**
- * Constructor.
- *
- * @param projectName The name of the project to be associated with this listener.
- */
- public TerminalTabListenerImpl(String projectName) {
- this.projectName = projectName;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void terminalTabDisposed(Object source, Object data) {
- // Perform cleanup if the project name associated with the disposed tab matches the project name associated with this
- // listener. Note that, input "data" is the custom data (ITerminalsConnectorConstants.PROP_DATA = project name) provided
- // for opening the console. This is a bit more reliable and easier to use than using the "source" input (CTabItem) on
- // Windows specially due to potential tab title overrides.
- if (data instanceof String) {
- String disposedProjectName = (String) data;
- if (disposedProjectName.equals(projectName)) {
- if (Trace.isEnabled()) {
- Trace.getTracer().trace(Trace.TRACE_UI, "The terminal associated with project " + projectName
- + " was closed. Processing cleanup. Listener: " + this + ". Source: " + source + ". Data: " + data);
- }
- ProjectTabController.getInstance().processTerminalTabCleanup(projectName);
- }
- }
- }
-}
diff --git a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotGradleTest.java b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotGradleTest.java
index f26571f0..60993500 100644
--- a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotGradleTest.java
+++ b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotGradleTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2022, 2023 IBM Corporation and others.
+* Copyright (c) 2022, 2025 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -14,7 +14,6 @@
import static io.openliberty.tools.eclipse.test.it.utils.MagicWidgetFinder.context;
import static io.openliberty.tools.eclipse.test.it.utils.MagicWidgetFinder.go;
-import static io.openliberty.tools.eclipse.test.it.utils.MagicWidgetFinder.goGlobal;
import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.deleteLibertyToolsRunConfigEntriesFromAppRunAs;
import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.enableLibertyTools;
import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.getAppDebugAsMenu;
@@ -334,8 +333,6 @@ public void testDashboardStartAction() {
// Start dev mode.
launchDashboardAction(GRADLE_APP_NAME, DashboardView.APP_MENU_ACTION_START);
- SWTBotView terminal = bot.viewByTitle("Terminal");
- terminal.show();
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(GRADLE_APP_NAME, true, testAppPath + "/build");
@@ -345,13 +342,9 @@ public void testDashboardStartAction() {
// Stop dev mode.
launchDashboardAction(GRADLE_APP_NAME, DashboardView.APP_MENU_ACTION_STOP);
- terminal.show();
// Validate application stopped.
LibertyPluginTestUtils.validateLibertyServerStopped(testAppPath + "/build");
-
- // Close the terminal.
- terminal.close();
}
/**
@@ -362,8 +355,6 @@ public void testDashboardDebugAction() {
// Start dev mode.
launchDashboardAction(GRADLE_APP_NAME, DashboardView.APP_MENU_ACTION_DEBUG);
- SWTBotView terminal = bot.viewByTitle("Terminal");
- terminal.show();
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(GRADLE_APP_NAME, true, testAppPath + "/build");
@@ -373,13 +364,9 @@ public void testDashboardDebugAction() {
// Stop dev mode.
launchDashboardAction(GRADLE_APP_NAME, DashboardView.APP_MENU_ACTION_STOP);
- terminal.show();
// Validate application stopped.
LibertyPluginTestUtils.validateLibertyServerStopped(testAppPath + "/build");
-
- // Close the terminal.
- terminal.close();
}
/**
@@ -395,7 +382,7 @@ public void testDashboardStopExternalServer() throws CommandNotFoundException, I
Path wrapperProject = Paths.get("resources", "applications", "gradle", GRADLE_WRAPPER_APP_NAME).toAbsolutePath();
// Doing a 'clean' first in case server was started previously and terminated abruptly
- String cmd = CommandBuilder.getGradleCommandLine(wrapperProject.toString(), "clean libertyDev", null, false);
+ String cmd = CommandBuilder.getGradleCommandLine(wrapperProject.toString(), "clean libertyDev", null);
String[] cmdParts = cmd.split(" ");
ProcessBuilder pb = new ProcessBuilder(cmdParts).inheritIO().directory(wrapperProject.toFile()).redirectErrorStream(true);
pb.environment().put("JAVA_HOME", JavaRuntime.getDefaultVMInstall().getInstallLocation().getAbsolutePath());
@@ -433,8 +420,6 @@ public void testDashboardStartWithCustomConfigAction() {
launchCustomRunFromDashboard(GRADLE_APP_NAME, "--hotTests");
- goGlobal("Terminal");
-
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(GRADLE_APP_NAME, true, testAppPath + "/build");
@@ -470,8 +455,6 @@ public void testDashboardDebugWithCustomConfigAction() {
launchCustomDebugFromDashboard(GRADLE_APP_NAME, "--hotTests");
- goGlobal("Terminal");
-
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(GRADLE_APP_NAME, true, testAppPath + "/build");
@@ -633,7 +616,6 @@ public void testStartWithDefaultRunAsConfig() {
// Start dev mode.
launchStartWithDefaultRunConfigFromAppRunAs(GRADLE_APP_NAME);
- goGlobal("Terminal");
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(GRADLE_APP_NAME, true, testAppPath + "/build");
@@ -666,7 +648,6 @@ public void testStartWithCustomRunAsConfig() {
// Start dev mode with parms.
launchStartWithNewCustomRunConfig(GRADLE_APP_NAME, "--hotTests");
- goGlobal("Terminal");
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(GRADLE_APP_NAME, true, testAppPath + "/build");
@@ -703,8 +684,6 @@ public void testRunAsShortcutActions() {
// Start dev mode.
launchStartWithRunAsShortcut(GRADLE_APP_NAME);
- SWTBotView terminal = bot.viewByTitle("Terminal");
- terminal.show();
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(GRADLE_APP_NAME, true, testAppPath + "/build");
@@ -724,13 +703,9 @@ public void testRunAsShortcutActions() {
} finally {
// Stop dev mode.
launchStopWithRunAsShortcut(GRADLE_APP_NAME);
- terminal.show();
// Validate application stopped.
LibertyPluginTestUtils.validateLibertyServerStopped(testAppPath + "/build");
-
- // Close the terminal.
- terminal.close();
}
}
@@ -751,7 +726,6 @@ public void testStartWithCustomDebugAsConfig() {
// Start dev mode with parms.
launchStartWithNewCustomDebugConfig(GRADLE_APP_NAME, "--hotTests");
- goGlobal("Terminal");
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(GRADLE_APP_NAME, true, testAppPath + "/build");
@@ -785,7 +759,6 @@ public void testStartWithDebugAsShortcut() {
// Start dev mode.
launchStartWithDebugAsShortcut(GRADLE_APP_NAME);
- goGlobal("Terminal");
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(GRADLE_APP_NAME, true, testAppPath + "/build");
diff --git a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMavenTest.java b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMavenTest.java
index b1a925a9..69632149 100644
--- a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMavenTest.java
+++ b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMavenTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2022, 2023 IBM Corporation and others.
+* Copyright (c) 2022, 2025 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -14,7 +14,6 @@
import static io.openliberty.tools.eclipse.test.it.utils.MagicWidgetFinder.context;
import static io.openliberty.tools.eclipse.test.it.utils.MagicWidgetFinder.go;
-import static io.openliberty.tools.eclipse.test.it.utils.MagicWidgetFinder.goGlobal;
import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.checkRunInContainerCheckBox;
import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.deleteLibertyToolsRunConfigEntriesFromAppRunAs;
import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.enableLibertyTools;
@@ -66,7 +65,6 @@
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
@@ -342,7 +340,7 @@ public void testMavenCommandAssembly() throws IOException, InterruptedException,
String projPath = iProject.getLocation().toOSString();
String opaqueMvnCmd = CommandBuilder.getMavenCommandLine(projPath, "io.openliberty.tools:liberty-maven-plugin:dev -f " + projPath,
- System.getenv("PATH"), true);
+ System.getenv("PATH"));
Assertions.assertTrue(opaqueMvnCmd.contains(getMvnCmdFilename() + " io.openliberty.tools:liberty-maven-plugin:dev"),
"Expected cmd to contain 'mvn io.openliberty.tools...' but cmd = " + opaqueMvnCmd);
}
@@ -353,7 +351,7 @@ public void testMavenWrapperCommandAssembly() throws IOException, InterruptedExc
String projPath = iProject.getLocation().toOSString();
String opaqueMvnwCmd = CommandBuilder.getMavenCommandLine(projPath, "io.openliberty.tools:liberty-maven-plugin:dev -f " + projPath,
- System.getenv("PATH"), true);
+ System.getenv("PATH"));
Assertions.assertTrue(opaqueMvnwCmd.contains("mvnw"), "Expected cmd to contain 'mvnw' but cmd = " + opaqueMvnwCmd);
}
@@ -366,8 +364,6 @@ public void testDashboardStartActionWithWrapper() {
// Start dev mode.
launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_START);
- goGlobal("Terminal");
-
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_WRAPPER_APP_NAME, true,
wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty");
@@ -389,7 +385,6 @@ public void testDashboardStartActionWithWrapper() {
public void testDashboardStartAction() {
// Start dev mode.
launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START);
- goGlobal("Terminal");
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty");
@@ -419,7 +414,7 @@ public void testDashboardStopExternalServer() throws CommandNotFoundException, I
// Doing a 'clean' first in case server was started previously and terminated abruptly. App tests may fail,
// making it look like an "outer", actual test is failing, so we skip the tests.
String cmd = CommandBuilder.getMavenCommandLine(projAbsolutePath.toString(),
- "clean io.openliberty.tools:liberty-maven-plugin:dev -DskipITs=true", null, false);
+ "clean io.openliberty.tools:liberty-maven-plugin:dev -DskipITs=true", null);
String[] cmdParts = cmd.split(" ");
ProcessBuilder pb = new ProcessBuilder(cmdParts).inheritIO().directory(projAbsolutePath.toFile()).redirectErrorStream(true);
pb.environment().put("JAVA_HOME", JavaRuntime.getDefaultVMInstall().getInstallLocation().getAbsolutePath());
@@ -447,7 +442,6 @@ public void testDashboardStopExternalServer() throws CommandNotFoundException, I
public void testDashboardDebugAction() {
// Start dev mode.
launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_DEBUG);
- goGlobal("Terminal");
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty");
@@ -478,8 +472,6 @@ public void testDashboardStartWithCustomConfigAction() {
launchCustomRunFromDashboard(MVN_APP_NAME, "-DhotTests=true");
- goGlobal("Terminal");
-
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty");
@@ -514,8 +506,6 @@ public void testDashboardDebugWithCustomConfigAction() {
launchCustomDebugFromDashboard(MVN_APP_NAME, "-DhotTests=true");
- goGlobal("Terminal");
-
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty");
@@ -554,7 +544,6 @@ public void testDashboardActions() {
// Start dev mode.
launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START);
- goGlobal("Terminal");
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty");
@@ -597,8 +586,6 @@ public void testStartWithDefaultRunAsConfig() {
// Start dev mode.
launchStartWithDefaultRunConfigFromAppRunAs(MVN_APP_NAME);
- goGlobal("Terminal");
-
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty");
@@ -628,7 +615,6 @@ public void testStartWithCustomRunAsConfig() {
// Start dev mode with parms.
launchStartWithNewCustomRunConfig(MVN_APP_NAME, "-DhotTests=true");
- goGlobal("Terminal");
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty");
@@ -665,7 +651,6 @@ public void testRunAsShortcutActions() {
// Start dev mode.
launchStartWithRunAsShortcut(MVN_APP_NAME);
- goGlobal("Terminal");
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty");
@@ -712,7 +697,6 @@ public void testStartWithCustomDebugAsConfig() {
// Start dev mode with parms.
launchStartWithNewCustomDebugConfig(MVN_APP_NAME, "-DhotTests=true");
- goGlobal("Terminal");
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty");
@@ -735,13 +719,9 @@ public void testStartWithCustomDebugAsConfig() {
// Stop dev mode using the Run As stop command.
launchStopWithRunAsShortcut(MVN_APP_NAME);
- // terminal.show();
// Validate application stopped.
LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty");
-
- // Close the terminal.
- // terminal.close();
}
}
@@ -757,8 +737,6 @@ public void testStartWithDebugAsShortcut() {
// Start dev mode.
launchStartWithDebugAsShortcut(MVN_APP_NAME);
- goGlobal("Terminal");
-
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty");
@@ -774,13 +752,8 @@ public void testStartWithDebugAsShortcut() {
// Stop dev mode using the Run As stop command.
launchStopWithRunAsShortcut(MVN_APP_NAME);
- // terminal.show();
-
// Validate application stopped.
LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty");
-
- // Close the terminal.
- // terminal.close();
}
@Test
@@ -812,8 +785,6 @@ public void testStartWithWrapperAndNoPreferencesSet() {
// Start dev mode.
launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_START);
- SWTBotView terminal = bot.viewByTitle("Terminal");
- terminal.show();
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_WRAPPER_APP_NAME, true,
@@ -824,14 +795,10 @@ public void testStartWithWrapperAndNoPreferencesSet() {
// Stop dev mode.
launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_STOP);
- terminal.show();
// Validate application stopped.
LibertyPluginTestUtils.validateLibertyServerStopped(wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty");
- // Close the terminal.
- terminal.close();
-
setBuildCmdPathInPreferences(bot, "Maven");
}
@@ -846,8 +813,6 @@ public void testStartWithNoWrapperAndPreferencesSet() {
// Start dev mode.
launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START);
- SWTBotView terminal = bot.viewByTitle("Terminal");
- terminal.show();
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty");
@@ -857,13 +822,9 @@ public void testStartWithNoWrapperAndPreferencesSet() {
// Stop dev mode.
launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP);
- terminal.show();
// Validate application stopped.
LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty");
-
- // Close the terminal.
- terminal.close();
}
/**
@@ -986,11 +947,10 @@ public void testLaunchConfigurationMatching() {
// Start dev mode. This should start locally.
launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START);
- goGlobal("Terminal");
// Since the app should be started locally, we should be able to validate that the app is up and running.
// Since our tests cannot run docker, any "failed" start would indicate we did not start locally.
- // There is certainly room for improvement here like perhaps reading the Terminal window for "devc" vs "dev" commands, but this is
+ // There is certainly room for improvement here like perhaps reading the Console window for "devc" vs "dev" commands, but this is
// ok for now.
LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty");
diff --git a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMultiModMavenTest.java b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMultiModMavenTest.java
index 76169031..169d51a2 100644
--- a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMultiModMavenTest.java
+++ b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMultiModMavenTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2022, 2023 IBM Corporation and others.
+ * Copyright (c) 2022, 2025 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -39,7 +39,6 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@@ -232,8 +231,6 @@ public void testDashboardStartAction() {
// Start dev mode.
SWTBotPluginOperations.launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START);
- SWTBotView terminal = bot.viewByTitle("Terminal");
- terminal.show();
LibertyPluginTestUtils.validateApplicationOutcomeCustom("http://localhost:9080/converter1/heights.jsp?heightCm=10", true,
"Height in feet and inches", serverModule1Path + "/target/liberty");
@@ -245,16 +242,12 @@ public void testDashboardStartAction() {
// Stop dev mode.
SWTBotPluginOperations.launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP);
- terminal.show();
// Validate application stopped.
LibertyPluginTestUtils.validateLibertyServerStopped(serverModule1Path + "/target/liberty");
// unset the preferences
SWTBotPluginOperations.unsetBuildCmdPathInPreferences(bot, "Maven");
-
- // Close the terminal.
- terminal.close();
}
/**
@@ -272,8 +265,6 @@ public void testStartWithDefaultRunAsConfig() {
// Start dev mode.
launchStartWithDefaultRunConfigFromAppRunAs(MVN_APP_NAME);
- SWTBotView terminal = bot.viewByTitle("Terminal");
- terminal.show();
// Validate application is up and running.
LibertyPluginTestUtils.validateApplicationOutcomeCustom("http://localhost:9080/converter1/heights.jsp?heightCm=30", true,
@@ -284,16 +275,12 @@ public void testStartWithDefaultRunAsConfig() {
// Stop dev mode.
launchStopWithRunAsShortcut(MVN_APP_NAME);
- terminal.show();
// Validate application stopped.
LibertyPluginTestUtils.validateLibertyServerStopped(serverModule1Path + "/target/liberty");
// unset the preferences
unsetBuildCmdPathInPreferences(bot, "Maven");
-
- // Close the terminal.
- terminal.close();
}
/**
diff --git a/tests/src/main/java/io/openliberty/tools/eclipse/test/ut/CommandBuilderTest.java b/tests/src/main/java/io/openliberty/tools/eclipse/test/ut/CommandBuilderTest.java
index 406e85d0..52a3c498 100644
--- a/tests/src/main/java/io/openliberty/tools/eclipse/test/ut/CommandBuilderTest.java
+++ b/tests/src/main/java/io/openliberty/tools/eclipse/test/ut/CommandBuilderTest.java
@@ -27,64 +27,61 @@
public class CommandBuilderTest {
-
-
- /**
- * Tests the CommandBuilder builds a mvn invocation using the mvnw wrapper found in the project, even when the preference
- * is unset
- *
- * @throws Exception
- */
- @Test
- public void testCmdBuilderMvnWrapper() throws Exception {
- // This allows the test to prove the wrapper is in use even when the preference is unset, since an empty string preference would
- // resolve to "" + "/bin/mvn" = "/bin/mvn" and would typically be an actual path on Unix/Mac
+ /**
+ * Tests the CommandBuilder builds a mvn invocation using the mvnw wrapper found in the project, even when the preference
+ * is unset
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testCmdBuilderMvnWrapper() throws Exception {
+ // This allows the test to prove the wrapper is in use even when the preference is unset, since an empty string preference would
+ // resolve to "" + "/bin/mvn" = "/bin/mvn" and would typically be an actual path on Unix/Mac
unsetBuildCmdPathInPreferences(new SWTWorkbenchBot(), "Maven");
- Path projectPath = Paths.get("resources", "applications", "maven", "liberty-maven-test-wrapper-app");
- String retVal = CommandBuilder.getMavenCommandLine(projectPath.toString(), "-a 123", obfuscatedPath(), false);
- assertEquals(projectPath.resolve(mvnwName()) + " -a 123", retVal, "Wrong cmd line");
- }
+ Path projectPath = Paths.get("resources", "applications", "maven", "liberty-maven-test-wrapper-app");
+ String retVal = CommandBuilder.getMavenCommandLine(projectPath.toString(), "-a 123", obfuscatedPath());
+ assertEquals(projectPath.resolve(mvnwName()) + " -a 123", retVal, "Wrong cmd line");
+ }
- /**
- * Tests the CommandBuilder builds a mvn invocation using the mvn found in the path, even when there is an empty path element
- *
- * @throws Exception
- */
- @Test
- public void testCmdBuilderMvn() throws Exception {
- Path projectPath = Paths.get("resources", "applications", "maven", "liberty-maven-test-app");
- Path mvnPath = Paths.get("resources", "execs");
- String pathEnv= obfuscatedPath() + File.pathSeparator + mvnPath.toAbsolutePath().toString();
- String retVal = CommandBuilder.getMavenCommandLine(projectPath.toString(), "-a 123", pathEnv, false);
- assertEquals(mvnPath.toAbsolutePath().resolve(mvnName()) + " -a 123", retVal, "Wrong cmd line");
- }
+ /**
+ * Tests the CommandBuilder builds a mvn invocation using the mvn found in the path, even when there is an empty path element
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testCmdBuilderMvn() throws Exception {
+ Path projectPath = Paths.get("resources", "applications", "maven", "liberty-maven-test-app");
+ Path mvnPath = Paths.get("resources", "execs");
+ String pathEnv = obfuscatedPath() + File.pathSeparator + mvnPath.toAbsolutePath().toString();
+ String retVal = CommandBuilder.getMavenCommandLine(projectPath.toString(), "-a 123", pathEnv);
+ assertEquals(mvnPath.toAbsolutePath().resolve(mvnName()) + " -a 123", retVal, "Wrong cmd line");
+ }
- /**
- * @return A platform-dependent path very unlikely to be used, with an empty element
- */
- private String obfuscatedPath() {
- if (System.getProperty("os.name").contains("Windows")) {
- return "C:\\abc\\xyz\\123\456;;C:\\xyz\\abc\\456\\123";
- } else {
- return "/a/b/c/d1/e/f/g::/x/ya/b2/saa/";
- }
- }
+ /**
+ * @return A platform-dependent path very unlikely to be used, with an empty element
+ */
+ private String obfuscatedPath() {
+ if (System.getProperty("os.name").contains("Windows")) {
+ return "C:\\abc\\xyz\\123\456;;C:\\xyz\\abc\\456\\123";
+ } else {
+ return "/a/b/c/d1/e/f/g::/x/ya/b2/saa/";
+ }
+ }
-
- private String mvnName() {
- if (System.getProperty("os.name").contains("Windows")) {
- return "mvn.cmd";
- } else {
- return "mvn";
- }
- }
+ private String mvnName() {
+ if (System.getProperty("os.name").contains("Windows")) {
+ return "mvn.cmd";
+ } else {
+ return "mvn";
+ }
+ }
- private String mvnwName() {
- if (System.getProperty("os.name").contains("Windows")) {
- return "mvnw.cmd";
- } else {
- return "mvnw";
- }
- }
+ private String mvnwName() {
+ if (System.getProperty("os.name").contains("Windows")) {
+ return "mvnw.cmd";
+ } else {
+ return "mvnw";
+ }
+ }
}