From 19a809d3e5481042e150d26c65f52a504995ab80 Mon Sep 17 00:00:00 2001 From: ewaterlander <102143930+ewaterlander@users.noreply.github.com> Date: Thu, 12 Sep 2024 23:16:25 +0200 Subject: [PATCH] Launchbar build button always starts a build. (#812) Fixed the problem that the LaunchBar build button was not working when auto build was disabled in the launch configuration. Fixes #765 --- .../org.eclipse.launchbar.ui/META-INF/MANIFEST.MF | 3 ++- .../commands/BuildActiveCommandHandler.java | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/launchbar/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF b/launchbar/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF index 296b59ccba3..88063cda849 100644 --- a/launchbar/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF +++ b/launchbar/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF @@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui, org.eclipse.ui.ide, org.eclipse.debug.ui, - org.eclipse.launchbar.core + org.eclipse.launchbar.core, + org.eclipse.cdt.debug.core;bundle-version="8.8.400" Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/launchbar/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/BuildActiveCommandHandler.java b/launchbar/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/BuildActiveCommandHandler.java index 5ca972b1385..de91986f0c5 100644 --- a/launchbar/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/BuildActiveCommandHandler.java +++ b/launchbar/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/BuildActiveCommandHandler.java @@ -18,6 +18,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; @@ -33,6 +34,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchDelegate; import org.eclipse.debug.core.ILaunchMode; import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; @@ -100,6 +102,12 @@ public class BuildActiveCommandHandler extends AbstractHandler { if (delegate == null) delegate = config.getType().getDelegates(modes)[0]; ILaunchConfigurationDelegate configDel = delegate.getDelegate(); + /* This build is started manually by pressing the LaunchBar build button. + * Always build, regardless if auto build is disabled in the launch configuration. + */ + ILaunchConfigurationWorkingCopy configCopy = config.copy(config.getName() + "Copy"); //$NON-NLS-1$ + configCopy.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, + ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED); if (configDel instanceof ILaunchConfigurationTargetedDelegate) { ILaunchConfigurationTargetedDelegate configDel2 = (ILaunchConfigurationTargetedDelegate) configDel; boolean ret; @@ -107,7 +115,7 @@ public class BuildActiveCommandHandler extends AbstractHandler { if (!ret) { return Status.CANCEL_STATUS; } - if (!configDel2.buildForLaunch(config, mode, target, monitor)) { + if (!configDel2.buildForLaunch(configCopy, mode, target, monitor)) { return Status.OK_STATUS; } } else if (configDel instanceof ILaunchConfigurationDelegate2) { @@ -117,7 +125,8 @@ public class BuildActiveCommandHandler extends AbstractHandler { if (!ret) { return Status.CANCEL_STATUS; } - if (!configDel2.buildForLaunch(config, mode, monitor)) { + + if (!configDel2.buildForLaunch(configCopy, mode, monitor)) { return Status.OK_STATUS; } }