use of org.apache.maven.doxia.sink.impl.SinkAdapter in project maven-plugins by apache.
the class PdfMojo method isValidGeneratedReport.
/**
* Parsing the generated report to see if it is correct or not. Log the error for the user.
*
* @param mojoDescriptor not null
* @param generatedReport not null
* @param localReportName not null
* @return <code>true</code> if Doxia is able to parse the generated report, <code>false</code> otherwise.
* @since 1.1
*/
private boolean isValidGeneratedReport(Artifact pluginArtifact, File generatedReport, String localReportName) {
SinkAdapter sinkAdapter = new SinkAdapter();
Reader reader = null;
try {
reader = ReaderFactory.newXmlReader(generatedReport);
doxia.parse(reader, generatedReport.getParentFile().getName(), sinkAdapter);
reader.close();
reader = null;
} catch (ParseException e) {
StringBuilder sb = new StringBuilder(1024);
sb.append(EOL).append(EOL);
sb.append("Error when parsing the generated report: ").append(generatedReport.getAbsolutePath());
sb.append(EOL);
sb.append(e.getMessage());
sb.append(EOL).append(EOL);
sb.append("You could:").append(EOL);
sb.append(" * exclude all reports using -DincludeReports=false").append(EOL);
sb.append(" * remove the ");
sb.append(pluginArtifact.getGroupId());
sb.append(":");
sb.append(pluginArtifact.getArtifactId());
sb.append(":");
sb.append(pluginArtifact.getVersion());
sb.append(" from the <reporting/> part. To not affect the site generation, ");
sb.append("you could create a PDF profile.").append(EOL);
sb.append(EOL);
MavenProject pluginProject = getReportPluginProject(pluginArtifact);
if (pluginProject == null) {
sb.append("You could also contact the Plugin team.").append(EOL);
} else {
sb.append("You could also contact the Plugin team:").append(EOL);
if (pluginProject.getMailingLists() != null && !pluginProject.getMailingLists().isEmpty()) {
boolean appended = false;
for (Object o : pluginProject.getMailingLists()) {
MailingList mailingList = (MailingList) o;
if (StringUtils.isNotEmpty(mailingList.getName()) && StringUtils.isNotEmpty(mailingList.getPost())) {
if (!appended) {
sb.append(" Mailing Lists:").append(EOL);
appended = true;
}
sb.append(" ").append(mailingList.getName());
sb.append(": ").append(mailingList.getPost());
sb.append(EOL);
}
}
}
if (StringUtils.isNotEmpty(pluginProject.getUrl())) {
sb.append(" Web Site:").append(EOL);
sb.append(" ").append(pluginProject.getUrl());
sb.append(EOL);
}
if (pluginProject.getIssueManagement() != null && StringUtils.isNotEmpty(pluginProject.getIssueManagement().getUrl())) {
sb.append(" Issue Tracking:").append(EOL);
sb.append(" ").append(pluginProject.getIssueManagement().getUrl());
sb.append(EOL);
}
}
sb.append(EOL).append("Ignoring the \"").append(localReportName).append("\" report in the PDF.").append(EOL);
getLog().error(sb.toString());
getLog().debug(e);
return false;
} catch (ParserNotFoundException e) {
getLog().error("ParserNotFoundException: " + e.getMessage());
getLog().debug(e);
return false;
} catch (IOException e) {
getLog().error("IOException: " + e.getMessage());
getLog().debug(e);
return false;
} finally {
IOUtil.close(reader);
}
return true;
}
use of org.apache.maven.doxia.sink.impl.SinkAdapter in project maven-plugins by apache.
the class PdfMojo method isValidGeneratedReportXdoc.
/**
* Parsing the generated report to see if it is correct or not. Log the error for the user.
*
* @param fullGoal not null
* @param generatedReport not null
* @param localReportName not null
* @return <code>true</code> if Doxia is able to parse the generated report, <code>false</code> otherwise.
* @since 1.1
*/
private boolean isValidGeneratedReportXdoc(String fullGoal, File generatedReport, String localReportName) {
SinkAdapter sinkAdapter = new SinkAdapter();
Reader reader = null;
try {
reader = ReaderFactory.newXmlReader(generatedReport);
doxia.parse(reader, generatedReport.getParentFile().getName(), sinkAdapter);
reader.close();
reader = null;
} catch (ParseException e) {
StringBuilder sb = new StringBuilder(1024);
sb.append(EOL);
sb.append("Error when parsing the generated report xdoc file: ");
sb.append(generatedReport.getAbsolutePath());
sb.append(EOL);
sb.append(e.getMessage());
sb.append(EOL);
sb.append("You could:").append(EOL);
sb.append(" * exclude all reports using -DincludeReports=false").append(EOL);
sb.append(" * remove the ");
sb.append(fullGoal);
sb.append(" from the <reporting/> part. To not affect the site generation, ");
sb.append("you could create a PDF profile.");
sb.append(EOL).append("Ignoring the \"").append(localReportName).append("\" report in the PDF.").append(EOL);
getLog().error(sb.toString());
getLog().debug(e);
return false;
} catch (ParserNotFoundException e) {
getLog().error("ParserNotFoundException: " + e.getMessage());
getLog().debug(e);
return false;
} catch (IOException e) {
getLog().error("IOException: " + e.getMessage());
getLog().debug(e);
return false;
} finally {
IOUtil.close(reader);
}
return true;
}
Aggregations