use of org.apache.maven.plugin.docck.reports.DocumentationReporter in project maven-plugins by apache.
the class AbstractCheckDocumentationMojo method buildErrorMessages.
private String buildErrorMessages(Map<MavenProject, DocumentationReporter> reporters) {
String messages = "";
StringBuilder buffer = new StringBuilder();
for (Map.Entry<MavenProject, DocumentationReporter> entry : reporters.entrySet()) {
MavenProject project = entry.getKey();
DocumentationReporter reporter = entry.getValue();
if (!reporter.getMessages().isEmpty()) {
buffer.append("\no ").append(project.getName());
buffer.append(" (");
final int numberOfErrors = reporter.getMessagesByType(DocumentationReport.TYPE_ERROR).size();
buffer.append(numberOfErrors).append(" error").append(numberOfErrors == 1 ? "" : "s");
buffer.append(", ");
final int numberOfWarnings = reporter.getMessagesByType(DocumentationReport.TYPE_WARN).size();
buffer.append(numberOfWarnings).append(" warning").append(numberOfWarnings == 1 ? "" : "s");
buffer.append(")");
buffer.append("\n");
for (String error : reporter.getMessages()) {
buffer.append(" ").append(error).append("\n");
}
}
}
if (buffer.length() > 0) {
messages = "The following documentation problems were found:\n" + buffer.toString();
}
return messages;
}
use of org.apache.maven.plugin.docck.reports.DocumentationReporter in project maven-plugins by apache.
the class AbstractCheckDocumentationMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
setupProxy();
if (output != null) {
getLog().info("Writing documentation check results to: " + output);
}
Map<MavenProject, DocumentationReporter> reporters = new LinkedHashMap<MavenProject, DocumentationReporter>();
boolean hasErrors = false;
for (MavenProject project : reactorProjects) {
if (approveProjectPackaging(project.getPackaging())) {
getLog().info("Checking project: " + project.getName());
DocumentationReporter reporter = new DocumentationReporter();
checkProject(project, reporter);
if (!hasErrors && reporter.hasErrors()) {
hasErrors = true;
}
reporters.put(project, reporter);
} else {
getLog().info("Skipping unsupported project: " + project.getName());
}
}
String messages;
messages = buildErrorMessages(reporters);
if (!hasErrors) {
messages += "No documentation errors were found.";
}
try {
writeMessages(messages, hasErrors);
} catch (IOException e) {
throw new MojoExecutionException("Error writing results to output file: " + output);
}
if (hasErrors) {
String logLocation;
if (output == null) {
logLocation = "Please see the console output above for more information.";
} else {
logLocation = "Please see \'" + output + "\' for more information.";
}
throw new MojoFailureException("Documentation problems were found. " + logLocation);
}
}
Aggregations