Search in sources :

Example 1 with CliPaths

use of com.github.checkstyle.data.CliPaths in project contribution by checkstyle.

the class Main method main.

/**
 * Executes all three processing stages according to CLI options.
 *
 * @param args
 *        cli arguments.
 * @throws Exception
 *         on failure to execute stages.
 */
public static void main(final String... args) throws Exception {
    System.out.println("patch-diff-report-tool execution started.");
    final CommandLine commandLine = parseCli(args);
    if (commandLine.hasOption(OPTION_HELP)) {
        System.out.println(MSG_HELP);
    } else {
        final CliPaths paths = getCliPaths(commandLine);
        final DiffReport diffReport;
        if (paths.getCompareMode() == CompareMode.XML) {
            // XML parsing stage
            System.out.println("XML parsing is started.");
            diffReport = CheckstyleReportsParser.parse(paths.getBaseReportPath(), paths.getPatchReportPath(), XML_PARSE_PORTION_SIZE);
        } else {
            // file parsing stage
            System.out.println("File parsing is started.");
            diffReport = CheckstyleTextParser.parse(paths.getBaseReportPath(), paths.getPatchReportPath());
        }
        // Configuration processing stage.
        MergedConfigurationModule diffConfiguration = null;
        if (paths.configurationPresent()) {
            System.out.println("Creation of configuration report is started.");
            diffConfiguration = CheckstyleConfigurationsParser.parse(paths.getBaseConfigPath(), paths.getPatchConfigPath());
        } else {
            System.out.println("Configuration processing skipped: " + "no configuration paths provided.");
        }
        // Site and XREF generation stage
        System.out.println("Creation of diff html site is started.");
        try {
            exportResources(paths);
            SiteGenerator.generate(diffReport, diffConfiguration, paths);
        } finally {
            for (String message : JxrDummyLog.getLogs()) {
                System.out.println(message);
            }
        }
        System.out.println("Creation of the result site succeed.");
    }
    System.out.println("patch-diff-report-tool execution finished.");
}
Also used : DiffReport(com.github.checkstyle.data.DiffReport) MergedConfigurationModule(com.github.checkstyle.data.MergedConfigurationModule) CommandLine(org.apache.commons.cli.CommandLine) CliPaths(com.github.checkstyle.data.CliPaths)

Example 2 with CliPaths

use of com.github.checkstyle.data.CliPaths in project contribution by checkstyle.

the class Main method getCliPaths.

/**
 * Generates a CliPaths instance from commandLine and checks it for
 * validity.
 *
 * @param commandLine
 *        CLI arguments.
 * @return CliPaths instance.
 */
private static CliPaths getCliPaths(CommandLine commandLine) {
    final CliPaths paths = parseCliToPojo(commandLine);
    CliArgsValidator.checkPaths(paths);
    return paths;
}
Also used : CliPaths(com.github.checkstyle.data.CliPaths)

Example 3 with CliPaths

use of com.github.checkstyle.data.CliPaths in project contribution by checkstyle.

the class Main method parseCliToPojo.

/**
 * Forms POJO containing input paths.
 *
 * @param commandLine
 *        parsed CLI.
 * @return POJO instance.
 * @throws IllegalArgumentException
 *         on failure to find necessary arguments.
 */
private static CliPaths parseCliToPojo(CommandLine commandLine) throws IllegalArgumentException {
    final CompareMode compareMode = getCompareMode(OPTION_COMPARE_MODE, commandLine, CompareMode.XML);
    final Path xmlBasePath = getPath(OPTION_BASE_REPORT_PATH, commandLine, null);
    final Path xmlPatchPath = getPath(OPTION_PATCH_REPORT_PATH, commandLine, null);
    final Path refFilesPath = getPath(OPTION_REFFILES_PATH, commandLine, null);
    final Path defaultResultPath = Paths.get(System.getProperty("user.home")).resolve("XMLDiffGen_report_" + new SimpleDateFormat("yyyy.MM.dd_HH_mm_ss").format(Calendar.getInstance().getTime()));
    final Path outputPath = getPath(OPTION_OUTPUT_PATH, commandLine, defaultResultPath);
    final Path configBasePath = getPath(OPTION_BASE_CONFIG_PATH, commandLine, null);
    final Path configPatchPath = getPath(OPTION_PATCH_CONFIG_PATH, commandLine, null);
    final boolean shortFilePaths = commandLine.hasOption(OPTION_SHORT_PATHS);
    return new CliPaths(compareMode, xmlBasePath, xmlPatchPath, refFilesPath, outputPath, configBasePath, configPatchPath, shortFilePaths);
}
Also used : Path(java.nio.file.Path) CompareMode(com.github.checkstyle.data.CompareMode) SimpleDateFormat(java.text.SimpleDateFormat) CliPaths(com.github.checkstyle.data.CliPaths)

Aggregations

CliPaths (com.github.checkstyle.data.CliPaths)3 CompareMode (com.github.checkstyle.data.CompareMode)1 DiffReport (com.github.checkstyle.data.DiffReport)1 MergedConfigurationModule (com.github.checkstyle.data.MergedConfigurationModule)1 Path (java.nio.file.Path)1 SimpleDateFormat (java.text.SimpleDateFormat)1 CommandLine (org.apache.commons.cli.CommandLine)1