如何使用 doxia API 获取 Maven 报告插件来生成报告?

发布于 2024-12-02 06:11:48 字数 696 浏览 3 评论 0原文

我一直在尝试编写自己的 Maven 报告插件,以在运行“mvn site”时生成有关测试的信息。这 文件 test_report.html 是由下面的代码创建的,但该页面不包含任何 doxia 接收器 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();
  }
}

我一直在看这个例子: http://docs.codehaus .org/display/MAVENUSER/Write+your+own+report+plugin

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

琴流音 2024-12-09 06:11:48

你犯了一些小错误。主要是把东西关掉。

  1. title() 只是打开在 doxia 中书写的标题。

     sink.title();
        水槽.文本(“你好”);
        水槽.title_();
    

会写标题。

现在来说说身体。

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

最后是完整的例子:-

        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();

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();
无风消散 2024-12-09 06:11:48

我认为这个问题的最佳答案是您阅读报告插件的几个工作示例的源代码。 “经典”是 maven-project-info-reports-plugin 的一部分,还有很多其他的。您可以在以下位置找到其来源:

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

当您弄清楚您错过了什么时,请改进 codehaus 文档。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文