开发者

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

开发者 https://www.devze.com 2023-04-01 23:11 出处:网络
I\'ve been trying to write my own maven reporting plugin to generate info about tests when running \'mvn site\'. The

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 = getSin开发者_如何学JAVAk();
    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.

0

精彩评论

暂无评论...
验证码 换一张
取 消