use of org.apache.maven.reporting.MavenReportException in project maven-plugins by apache.
the class JavadocReport method doExecute.
/** {@inheritDoc} */
public void doExecute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping javadoc generation");
return;
}
try {
RenderingContext context = new RenderingContext(outputDirectory, getOutputName() + ".html");
SiteRendererSink sink = new SiteRendererSink(context);
Locale locale = Locale.getDefault();
generate(sink, locale);
} catch (MavenReportException e) {
failOnError("An error has occurred in " + getName(Locale.ENGLISH) + " report generation", e);
} catch (RuntimeException e) {
failOnError("An error has occurred in " + getName(Locale.ENGLISH) + " report generation", e);
}
}
use of org.apache.maven.reporting.MavenReportException in project maven-plugins by apache.
the class InvokerReport method executeReport.
protected void executeReport(Locale locale) throws MavenReportException {
DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale);
percentFormat = new DecimalFormat(getText(locale, "report.invoker.format.percent"), symbols);
secondsFormat = new DecimalFormat(getText(locale, "report.invoker.format.seconds"), symbols);
Sink sink = getSink();
sink.head();
sink.title();
sink.text(getText(locale, "report.invoker.result.title"));
sink.title_();
sink.head_();
sink.body();
sink.section1();
sink.sectionTitle1();
sink.text(getText(locale, "report.invoker.result.title"));
sink.sectionTitle1_();
sink.paragraph();
sink.text(getText(locale, "report.invoker.result.description"));
sink.paragraph_();
sink.section1_();
// ----------------------------------
// build buildJob beans
// ----------------------------------
File[] reportFiles = ReportUtils.getReportFiles(reportsDirectory);
if (reportFiles.length <= 0) {
getLog().info("no invoker report files found, skip report generation");
return;
}
List<BuildJob> buildJobs = new ArrayList<BuildJob>(reportFiles.length);
for (File reportFile : reportFiles) {
try {
BuildJobXpp3Reader reader = new BuildJobXpp3Reader();
buildJobs.add(reader.read(ReaderFactory.newXmlReader(reportFile)));
} catch (XmlPullParserException e) {
throw new MavenReportException("Failed to parse report file: " + reportFile, e);
} catch (IOException e) {
throw new MavenReportException("Failed to read report file: " + reportFile, e);
}
}
// ----------------------------------
// summary
// ----------------------------------
constructSummarySection(buildJobs, locale);
// ----------------------------------
// per file/it detail
// ----------------------------------
sink.section2();
sink.sectionTitle2();
sink.text(getText(locale, "report.invoker.detail.title"));
sink.sectionTitle2_();
sink.section2_();
// detail tests table header
sink.table();
sink.tableRow();
// -------------------------------------------
// name | Result | time | message
// -------------------------------------------
sinkTableHeader(sink, getText(locale, "report.invoker.detail.name"));
sinkTableHeader(sink, getText(locale, "report.invoker.detail.result"));
sinkTableHeader(sink, getText(locale, "report.invoker.detail.time"));
sinkTableHeader(sink, getText(locale, "report.invoker.detail.message"));
sink.tableRow_();
for (BuildJob buildJob : buildJobs) {
renderBuildJob(buildJob, locale);
}
sink.table_();
sink.body_();
sink.flush();
sink.close();
}
use of org.apache.maven.reporting.MavenReportException in project maven-plugins by apache.
the class AbstractJavadocMojo method collectOfflineLinks.
private Set<OfflineLink> collectOfflineLinks() throws MavenReportException {
Set<OfflineLink> result = new LinkedHashSet<OfflineLink>();
OfflineLink javaApiLink = getDefaultJavadocApiLink();
if (javaApiLink != null) {
result.add(javaApiLink);
}
if (includeDependencySources) {
try {
resolveDependencyBundles();
} catch (IOException e) {
throw new MavenReportException("Failed to resolve javadoc bundles from dependencies: " + e.getMessage(), e);
}
if (isNotEmpty(dependencyJavadocBundles)) {
for (JavadocBundle bundle : dependencyJavadocBundles) {
JavadocOptions options = bundle.getOptions();
if (options != null && isNotEmpty(options.getOfflineLinks())) {
result.addAll(options.getOfflineLinks());
}
}
}
}
if (this.offlineLinks != null && this.offlineLinks.length > 0) {
result.addAll(Arrays.asList(this.offlineLinks));
}
return result;
}
use of org.apache.maven.reporting.MavenReportException in project maven-plugins by apache.
the class AbstractCheckstyleReport method executeReport.
/** {@inheritDoc} */
public void executeReport(Locale locale) throws MavenReportException {
checkDeprecatedParameterUsage(sourceDirectory, "sourceDirectory", "sourceDirectories");
checkDeprecatedParameterUsage(testSourceDirectory, "testSourceDirectory", "testSourceDirectories");
locator.addSearchPath(FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath());
locator.addSearchPath("url", "");
locator.setOutputDirectory(new File(project.getBuild().getDirectory()));
// for when we start using maven-shared-io and maven-shared-monitor...
// locator = new Locator( new MojoLogMonitorAdaptor( getLog() ) );
// locator = new Locator( getLog(), new File( project.getBuild().getDirectory() ) );
ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
try {
CheckstyleExecutorRequest request = createRequest().setLicenseArtifacts(collectArtifacts("license")).setConfigurationArtifacts(collectArtifacts("configuration")).setOmitIgnoredModules(omitIgnoredModules);
CheckstyleResults results = checkstyleExecutor.executeCheckstyle(request);
ResourceBundle bundle = getBundle(locale);
generateReportStatics();
generateMainReport(results, bundle);
if (enableRSS) {
CheckstyleRssGeneratorRequest checkstyleRssGeneratorRequest = new CheckstyleRssGeneratorRequest(this.project, this.getCopyright(), outputDirectory, getLog());
checkstyleRssGenerator.generateRSS(results, checkstyleRssGeneratorRequest);
}
} catch (CheckstyleException e) {
throw new MavenReportException("Failed during checkstyle configuration", e);
} catch (CheckstyleExecutorException e) {
throw new MavenReportException("Failed during checkstyle execution", e);
} finally {
//be sure to restore original context classloader
Thread.currentThread().setContextClassLoader(currentClassLoader);
}
}
use of org.apache.maven.reporting.MavenReportException in project maven-plugins by apache.
the class AbstractCheckstyleReport method getListener.
/**
* Creates and returns the report generation listener.
*
* @return The audit listener.
* @throws MavenReportException If something goes wrong.
*/
protected AuditListener getListener() throws MavenReportException {
AuditListener listener = null;
if (StringUtils.isNotEmpty(outputFileFormat)) {
File resultFile = outputFile;
OutputStream out = getOutputStream(resultFile);
if ("xml".equals(outputFileFormat)) {
listener = new XMLLogger(out, true);
} else if ("plain".equals(outputFileFormat)) {
listener = new DefaultLogger(out, true);
} else {
// TODO: failure if not a report
throw new MavenReportException("Invalid output file format: (" + outputFileFormat + "). Must be 'plain' or 'xml'.");
}
}
return listener;
}
Aggregations