use of com.thoughtworks.gauge.exception.GaugeNotFoundException 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.exception.GaugeNotFoundException 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.exception.GaugeNotFoundException in project Intellij-Plugin by getgauge.
the class GaugeInspectionHelper method getErrors.
@NotNull
static List<GaugeError> getErrors(File directory) {
try {
GaugeSettingsModel settings = getGaugeSettings();
ProcessBuilder processBuilder = new ProcessBuilder(settings.getGaugePath(), Constants.VALIDATE);
GaugeUtil.setGaugeEnvironmentsTo(processBuilder, settings);
processBuilder.directory(directory);
Process process = processBuilder.start();
process.waitFor();
String[] errors = GaugeUtil.getOutput(process.getInputStream(), "\n").split("\n");
return Arrays.stream(errors).map(GaugeError::getInstance).filter(Objects::nonNull).collect(Collectors.toList());
} catch (IOException | InterruptedException | GaugeNotFoundException e) {
e.printStackTrace();
}
return new ArrayList<>();
}
use of com.thoughtworks.gauge.exception.GaugeNotFoundException in project Intellij-Plugin by getgauge.
the class GaugeUtil method getSettingsFromPATH.
private static GaugeSettingsModel getSettingsFromPATH(GaugeSettingsModel model) throws GaugeNotFoundException {
String path = EnvironmentUtil.getValue("PATH");
LOG.info("PATH => " + path);
if (!StringUtils.isEmpty(path)) {
for (String entry : path.split(File.pathSeparator)) {
File file = new File(entry, gaugeExecutable());
if (isValidGaugeExec(file)) {
LOG.info("executable path from `PATH`: " + file.getAbsolutePath());
return new GaugeSettingsModel(file.getAbsolutePath(), model.getHomePath(), model.useIntelliJTestRunner());
}
}
}
String msg = "Could not find executable in `PATH`. Please make sure Gauge is installed." + "\nIf Gauge is installed then set the Gauge executable path in settings -> tools -> gauge.";
throw new GaugeNotFoundException(msg);
}
Aggregations