use of org.apache.maven.doxia.sink.Sink in project revapi by revapi.
the class ReportMojo method executeReport.
@Override
protected void executeReport(Locale locale) throws MavenReportException {
ensureAnalyzed(locale);
if (skip) {
return;
}
if (oldAPI == null || newAPI == null) {
getLog().warn("Could not determine the artifacts to compare. If you're comparing the" + " currently built version, have you run the package goal?");
return;
}
if (generateSiteReport) {
Sink sink = getSink();
ResourceBundle bundle = getBundle(locale);
ReportTimeReporter reporter = analysisResult.getExtensions().getFirstExtension(ReportTimeReporter.class, null);
startReport(sink, bundle);
reportBody(reporter, oldAPI, newAPI, sink, bundle);
endReport(sink);
}
}
use of org.apache.maven.doxia.sink.Sink in project jewelcli by lexicalscope.
the class JewelCliReportMojo method executeReport.
@Override
protected void executeReport(final Locale locale) throws MavenReportException {
final ClassLoader classLoader = getClassLoader();
final Class<?> interfaceClass = interfaceClass(classLoader);
final Cli<?> cli = CliFactory.createCli(interfaceClass);
getLog().debug("cli interface with " + cli);
final Sink sink = getSink();
sink.head();
sink.title();
sink.text(getName(locale));
sink.title_();
sink.head_();
sink.body();
sink.section1();
sink.sectionTitle1();
sink.text(getBundle(locale).getString("report.jewelcli.title") + " " + getProject().getName());
sink.sectionTitle1_();
sink.lineBreak();
sink.text("Command line interface for " + " " + getProject().getName());
sink.lineBreak();
sink.lineBreak();
cli.describeTo(new HelpMessage() {
@Override
public void startOfOptions() {
sink.table();
sink.tableRow();
sink.tableHeaderCell();
sink.text("Mandatory");
sink.tableHeaderCell_();
sink.tableHeaderCell();
sink.text("Long Form");
sink.tableHeaderCell_();
sink.tableHeaderCell();
sink.text("Short Form");
sink.tableHeaderCell_();
sink.tableHeaderCell();
sink.text("Pattern");
sink.tableHeaderCell_();
sink.tableHeaderCell();
sink.text("Description");
sink.tableHeaderCell_();
sink.tableRow_();
}
@Override
public OptionHelpMessage option() {
return new OptionHelpMessage() {
@Override
public void startOptionalOption() {
sink.tableRow();
sink.tableCell("true");
}
@Override
public void startMandatoryOption() {
sink.tableRow();
sink.tableCell();
sink.text("true");
sink.tableCell_();
}
@Override
public void singleValuedWithCustomPattern(final String pattern) {
sink.tableCell();
sink.text("/" + pattern + "/");
sink.tableCell_();
}
@Override
public void singleValued() {
sink.tableCell();
sink.text("/.*/");
sink.tableCell_();
}
@Override
public void noValued() {
sink.tableCell();
sink.tableCell_();
}
@Override
public void shortName(final List<String> shortNames) {
sink.tableCell();
sink.text(join(convert(shortNames, new AddDash()), ", "));
sink.tableCell_();
}
@Override
public void multiValuedWithCustomPattern() {
sink.tableCell();
sink.text("/.*/...");
sink.tableCell_();
}
@Override
public void multiValuedWithCustomPattern(final String pattern) {
sink.tableCell();
sink.text("/" + pattern + "/...");
sink.tableCell_();
}
@Override
public void longName(final List<String> longNames) {
sink.tableCell();
sink.text(join(convert(longNames, new AddDashDash()), ", "));
sink.tableCell_();
}
@Override
public void endOptionalOption(final String description) {
sink.tableCell();
sink.text(description);
sink.tableCell_();
sink.tableRow_();
}
@Override
public void endOptionalOption() {
sink.tableCell();
sink.tableCell_();
sink.tableRow_();
}
@Override
public void endMandatoryOption(final String description) {
sink.tableCell();
sink.text(description);
sink.tableCell_();
sink.tableRow_();
}
@Override
public void endMandatoryOption() {
sink.tableCell();
sink.tableCell_();
sink.tableRow_();
}
};
}
@Override
public void noUsageInformation() {
// nothing
}
@Override
public void hasUsageInformation() {
sink.text("Usage: ");
}
@Override
public void hasUsageInformation(final String applicationName) {
sink.text("Usage: " + applicationName + " ");
}
@Override
public void hasUnparsedOption(final String valueName) {
sink.text(valueName);
}
@Override
public void hasUnparsedMultiValuedOption(final String valueName) {
sink.text(valueName + "...");
}
@Override
public void hasSomeMandatoryOptions() {
sink.text("options ");
}
@Override
public void hasOnlyOptionalOptions() {
sink.text("[options] ");
}
@Override
public void endOfOptions() {
sink.table_();
}
});
sink.lineBreak();
sink.section1_();
sink.body_();
sink.flush();
sink.close();
}
use of org.apache.maven.doxia.sink.Sink 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.doxia.sink.Sink in project maven-plugins by apache.
the class InvokerReport method constructSummarySection.
private void constructSummarySection(List<? extends BuildJob> buildJobs, Locale locale) {
Sink sink = getSink();
sink.section2();
sink.sectionTitle2();
sink.text(getText(locale, "report.invoker.summary.title"));
sink.sectionTitle2_();
sink.section2_();
// ------------------------------------------------------------------------
// Building a table with
// it number | succes nb | failed nb | Success rate | total time | avg time
// ------------------------------------------------------------------------
sink.table();
sink.tableRow();
sinkTableHeader(sink, getText(locale, "report.invoker.summary.number"));
sinkTableHeader(sink, getText(locale, "report.invoker.summary.success"));
sinkTableHeader(sink, getText(locale, "report.invoker.summary.failed"));
sinkTableHeader(sink, getText(locale, "report.invoker.summary.skipped"));
sinkTableHeader(sink, getText(locale, "report.invoker.summary.success.rate"));
sinkTableHeader(sink, getText(locale, "report.invoker.summary.time.total"));
sinkTableHeader(sink, getText(locale, "report.invoker.summary.time.avg"));
int number = buildJobs.size();
int success = 0;
int failed = 0;
int skipped = 0;
double totalTime = 0;
for (BuildJob buildJob : buildJobs) {
if (BuildJob.Result.SUCCESS.equals(buildJob.getResult())) {
success++;
} else if (BuildJob.Result.SKIPPED.equals(buildJob.getResult())) {
skipped++;
} else {
failed++;
}
totalTime += buildJob.getTime();
}
sink.tableRow_();
sink.tableRow();
sinkCell(sink, Integer.toString(number));
sinkCell(sink, Integer.toString(success));
sinkCell(sink, Integer.toString(failed));
sinkCell(sink, Integer.toString(skipped));
if (success + failed > 0) {
sinkCell(sink, percentFormat.format((double) success / (success + failed)));
} else {
sinkCell(sink, "");
}
sinkCell(sink, secondsFormat.format(totalTime));
sinkCell(sink, secondsFormat.format(totalTime / number));
sink.tableRow_();
sink.table_();
}
use of org.apache.maven.doxia.sink.Sink in project maven-plugins by apache.
the class SiteMap method generate.
/**
* Generates a sitemap.xml in targetDir/xdoc/.
* This is a valid xdoc document that can be processed by a Doxia parser.
* The file lists all the menus and menu items of the DecorationModel in expanded form.
*
* @param model the DecorationModel to extract the menus from.
* @param targetDir the target output directory. The file will be created in targetDir/xdoc/.
* @param locale the Locale for the result.
*
* @throws IOException if the file cannot be ceated.
*/
public void generate(DecorationModel model, File targetDir, Locale locale) throws IOException {
File outputDir = new File(targetDir, "xdoc");
Sink sink = new XdocSinkFactory().createSink(outputDir, "sitemap.xml", encoding);
try {
extract(model, sink, locale);
} finally {
sink.close();
}
}
Aggregations