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.");
}
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;
}
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);
}
Aggregations