use of com.thoughtworks.gauge.settings.GaugeSettingsModel in project Intellij-Plugin by getgauge.
the class GaugeModuleComponent method initializeGaugeProcess.
private static Process initializeGaugeProcess(int apiPort, Module module) {
try {
GaugeSettingsModel settings = getGaugeSettings();
String port = String.valueOf(apiPort);
ProcessBuilder gauge = new ProcessBuilder(settings.getGaugePath(), Constants.DAEMON, port);
GaugeUtil.setGaugeEnvironmentsTo(gauge, settings);
String cp = classpathForModule(module);
LOG.info(String.format("Setting `%s` to `%s`", Constants.GAUGE_CUSTOM_CLASSPATH, cp));
gauge.environment().put(Constants.GAUGE_CUSTOM_CLASSPATH, cp);
File dir = moduleDir(module);
LOG.info(String.format("Using `%s` as api port to connect to gauge API for project %s", port, dir));
gauge.directory(dir);
Process process = gauge.start();
new GaugeExceptionHandler(process, module.getProject()).start();
return process;
} catch (IOException | GaugeNotFoundException e) {
LOG.error("An error occurred while starting gauge api. \n" + e);
}
return null;
}
use of com.thoughtworks.gauge.settings.GaugeSettingsModel in project Intellij-Plugin by getgauge.
the class GaugeCommandLine method getInstance.
public static GeneralCommandLine getInstance(Module module, Project project) {
GeneralCommandLine commandLine = new GeneralCommandLine();
try {
GaugeSettingsModel settings = GaugeUtil.getGaugeSettings();
commandLine.setExePath(settings.getGaugePath());
Map<String, String> environment = commandLine.getEnvironment();
environment.put(Constants.GAUGE_HOME, settings.getHomePath());
} catch (GaugeNotFoundException e) {
commandLine.setExePath(Constants.GAUGE);
} finally {
commandLine.setWorkDirectory(project.getBasePath());
if (module != null)
commandLine.setWorkDirectory(GaugeUtil.moduleDir(module));
return commandLine;
}
}
use of com.thoughtworks.gauge.settings.GaugeSettingsModel in project Intellij-Plugin by getgauge.
the class GaugeUtil method getGaugeSettings.
public static GaugeSettingsModel getGaugeSettings() throws GaugeNotFoundException {
GaugeSettingsModel settings = GaugeSettingsService.getSettings();
LOG.info(settings.toString());
if (settings.isGaugePathSet()) {
LOG.info("Using Gauge plugin settings to get Gauge executable path.");
return settings;
}
if (gaugeSettings == null)
gaugeSettings = getSettingsFromPATH(settings);
return gaugeSettings;
}
use of com.thoughtworks.gauge.settings.GaugeSettingsModel in project Intellij-Plugin by getgauge.
the class GaugeVersion method getVersion.
public static GaugeVersionInfo getVersion(Boolean update) {
if (!update)
return versionInfo;
GaugeVersionInfo gaugeVersionInfo = new GaugeVersionInfo();
try {
GaugeSettingsModel settings = getGaugeSettings();
ProcessBuilder processBuilder = new ProcessBuilder(settings.getGaugePath(), Constants.VERSION, Constants.MACHINE_READABLE);
GaugeUtil.setGaugeEnvironmentsTo(processBuilder, settings);
Process process = processBuilder.start();
int exitCode = process.waitFor();
if (exitCode == 0) {
String output = GaugeUtil.getOutput(process.getInputStream(), "\n");
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
gaugeVersionInfo = gson.fromJson(output, GaugeVersionInfo.class);
}
} catch (Exception ignored) {
}
versionInfo = gaugeVersionInfo;
return gaugeVersionInfo;
}
use of com.thoughtworks.gauge.settings.GaugeSettingsModel in project Intellij-Plugin by getgauge.
the class SpecFormatter method actionPerformed.
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
final Project project = anActionEvent.getData(LangDataKeys.PROJECT);
if (project == null) {
return;
}
String projectDir = project.getBasePath();
if (projectDir == null) {
return;
}
FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
VirtualFile selectedFile = fileEditorManager.getSelectedFiles()[0];
String fileName = selectedFile.getCanonicalPath();
Document doc = FileDocumentManager.getInstance().getDocument(selectedFile);
if (doc != null) {
FileDocumentManager.getInstance().saveDocument(doc);
}
try {
GaugeSettingsModel settings = getGaugeSettings();
ProcessBuilder processBuilder = new ProcessBuilder(settings.getGaugePath(), Constants.FORMAT, fileName);
GaugeUtil.setGaugeEnvironmentsTo(processBuilder, settings);
processBuilder.directory(new File(projectDir));
Process process = processBuilder.start();
int exitCode = process.waitFor();
if (exitCode != 0) {
String output = String.format("<pre>%s</pre>", GaugeUtil.getOutput(process.getInputStream(), "\n").replace("<", "<").replace(">", ">"));
Notifications.Bus.notify(new Notification("Spec Formatting", "Error: Spec Formatting", output, NotificationType.ERROR));
return;
}
VirtualFileManager.getInstance().syncRefresh();
selectedFile.refresh(false, false);
} catch (Exception e) {
e.printStackTrace();
Messages.showErrorDialog("Error on formatting spec", "Format Error");
}
}
Aggregations