From ecb6e16ff30368ad9950f3af1273730beec06b4c Mon Sep 17 00:00:00 2001 From: "Pierre-Yves B." <10694593+PyvesB@users.noreply.github.com> Date: Sun, 20 Feb 2022 11:28:12 +0100 Subject: [PATCH] Fix gem build and simplify bundle install by running them from directory --- .../launch/run/BundleGemRunShortcut.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/launch/run/BundleGemRunShortcut.java b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/launch/run/BundleGemRunShortcut.java index 5b8430c..2b51711 100644 --- a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/launch/run/BundleGemRunShortcut.java +++ b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/launch/run/BundleGemRunShortcut.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019 Pierre-Yves B. and others. + * Copyright (c) 2019-2022 Pierre-Yves B. and others. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -12,6 +12,8 @@ *******************************************************************************/ package io.github.pyvesb.eclipse_solargraph.launch.run; +import java.io.File; + import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.core.DebugPlugin; @@ -27,16 +29,17 @@ public class BundleGemRunShortcut implements IResourceLaunchShortcut { public void launchResource(IResource resource, String mode) { Launch launch = new Launch(null, ILaunchManager.RUN_MODE, null); DebugPlugin.getDefault().getLaunchManager().addLaunch(launch); - String command = getBaseCommand(resource) + resource.getLocation().toOSString(); + String command = getBaseCommand(resource); String[] absolutePlatformCommand = CommandHelper.getAbsolutePlatformCommand(command); + File workingDirectory = resource.getLocation().removeLastSegments(1).toFile(); Job.create("Running " + command, r -> { - Process process = DebugPlugin.exec(absolutePlatformCommand, null); + Process process = DebugPlugin.exec(absolutePlatformCommand, workingDirectory); DebugPlugin.newProcess(launch, process, command); }).schedule(); } private String getBaseCommand(IResource resource) { - return "Gemfile".equals(resource.getName()) ? "bundle install --gemfile=" : "gem build "; + return "Gemfile".equals(resource.getName()) ? "bundle install" : "gem build"; } }