简体   繁体   中英

How to get a maven reporting plugin to generate report with the doxia API?

I've been trying to write my own maven reporting plugin to generate info about tests when running 'mvn site'. The file test_report.html is created by the code below, but the page does not contain any title or text with the doxia sink API.

public class TestDocMojo extends AbstractMavenReport {

  public String getOutputName() {
      return "test_report";
  }

  public void executeReport(Locale locale) throws MavenReportException {
    Sink sink = getSink();
    sink.head();
    sink.title("My maven site report");
        sink.text("Content here.");
    sink.flush();
    sink.close();
  }
}

I have been looking at this example: http://docs.codehaus.org/display/MAVENUSER/Write+your+own+report+plugin

you've made some small mistakes. Mainly closing stuff out.

  1. title() just opens to the title for writing in doxia.

      sink.title(); sink.text("Hello"); sink.title_(); 

Will write the title.

Now for the body.

        sink.body();
        sink.rawText("Hello World");
        sink.body_();

Finally the full example :-

        Sink sink = getSink();
        sink.head();
        sink.title();

        sink.text("Hello");
        sink.title_();
        sink.head_();

        sink.body();
        sink.rawText("Hello World");

        sink.body_();
        sink.flush();
        sink.close();

I think that the best answer to this question is for you to read the source of several working examples of reporting plugins. The 'classics' are part of the maven-project-info-reports-plugin, and then there are lots of others. You can find the source of that at:

http://svn.apache.org/viewvc/maven/plugins/tags/maven-project-info-reports-plugin-2.4

When you figure out what you missed, please improve the codehaus doc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM