private static void runScanExercise(Map<String, Path> paths) { // Exercise name, should it be something else than directory name? String exerciseName = paths.get(EXERCISE_PATH).toFile().getName(); Optional<ExerciseDesc> exerciseDesc = Optional.absent(); try { exerciseDesc = executor.scanExercise(paths.get(EXERCISE_PATH), exerciseName); if (!exerciseDesc.isPresent()) { log.error("Absent exercise description after running scanExercise"); printErrAndExit("ERROR: Could not scan the exercises."); } } catch (NoLanguagePluginFoundException e) { log.error("No suitable language plugin for project at {}", paths.get(EXERCISE_PATH), e); printErrAndExit( "ERROR: Could not find suitable language plugin for the given " + "exercise path."); } try { JsonWriter.writeObjectIntoJsonFormat(exerciseDesc.get(), paths.get(OUTPUT_PATH)); System.out.println( "Exercises scanned successfully, results can be found in " + paths.get(OUTPUT_PATH).toString()); } catch (IOException e) { log.error("Could not write output to {}", paths.get(OUTPUT_PATH), e); printErrAndExit("ERROR: Could not write the results to the given file."); } }
private static void runTests(Map<String, Path> paths) { RunResult runResult = null; try { runResult = executor.runTests(paths.get(EXERCISE_PATH)); } catch (NoLanguagePluginFoundException e) { log.error("No suitable language plugin for project at {}", paths.get(EXERCISE_PATH), e); printErrAndExit( "ERROR: Could not find suitable language plugin for the given " + "exercise path."); } try { JsonWriter.writeObjectIntoJsonFormat(runResult, paths.get(OUTPUT_PATH)); System.out.println("Test results can be found in " + paths.get(OUTPUT_PATH)); } catch (IOException e) { log.error("Could not write output to {}", paths.get(OUTPUT_PATH), e); printErrAndExit("ERROR: Could not write the results to the given file."); } }
private static void runCheckCodeStyle(Map<String, Path> paths) { ValidationResult validationResult = null; try { validationResult = executor.runCheckCodeStyle(paths.get(EXERCISE_PATH)); } catch (NoLanguagePluginFoundException e) { log.error( "Could not find a language plugin for the project at {}", paths.get(EXERCISE_PATH), e); printErrAndExit( "ERROR: Could not find suitable language plugin for the given exercise " + "path."); } try { JsonWriter.writeObjectIntoJsonFormat(validationResult, paths.get(OUTPUT_PATH)); System.out.println("Codestyle report can be found at " + paths.get(OUTPUT_PATH)); } catch (IOException e) { log.error("Could not write result into {}", paths.get(OUTPUT_PATH), e); printErrAndExit("ERROR: Could not write the results to the given file."); } }