开发者

Customizing Maven Reporting Plugins for a Confluence Wiki

I've developed a Maven reporting plugin for internal use at our company. It's designed to work in standalone mode so that it can be run against a given project without having to be configured in the <reporting> section of the pom.

However, the format of the document is currently in xhtml and all of our project docs are currently stored on Confluence. It would be a great convenience to generate the document in Confluence markup. There already exist ConfluenceSink and ConfluenceSinkFactory classes that would generate the proper markup, but I don't see an obvious way to set the sinks used by subclasses of AbstractMavenReport.

The approach I'm currently taking is:

  • Overriding the execute method as this currently hardcodes the use of SiteRendererSink, which outputs xhtml.
  • Finding an alternative to SiteRenderer.generateDocument(), as this method requires the above-mentioned SiteRendererSink.

Has anyone tackled these issues? Appreciate the feedback.

Finally, can I just note for the record that the API documentation for Maven is atrociou开发者_如何学编程s? I don't need a hand-holding tutorial -- just some basic javadocs and a sprinkling of insightful comments would be a huge help in getting anything done with this codebase.


So I managed to cook up a working solution. I was on the right track, I was just making things more complicated than they needed to be -- again, better documentation would have saved me sifting through various plugins looking for an example.

So, if anyone wants to do something similar, first get your plugin working at producing xhtml. I found this link to be fairly helpful in that regard. To change the output format, you'll have to override the execute() method and provide the generate() method with the appropriate Sink and SinkFactory implementations.

Here's an example for output in Confluence markup:

@Override
public void execute()
    throws MojoExecutionException
{
    try
    {
        File outputDirectory = new File(getOutputDirectory());

        String filename = getOutputName() + ".cf";

        Locale locale = Locale.getDefault();

        ConfluenceSinkFactory factory = new ConfluenceSinkFactory();
        Sink sink = factory.createSink(outputDirectory, filename);

        generate(sink, factory, locale);
    }
    catch ( IOException e )
    {
        throw new MojoExecutionException(e);
    }
    catch ( MavenReportException e )
    {
        throw new MojoExecutionException(e);
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜