挖掘一下,我发现我的答案: http://maven.apache.org/shared/maven-reporting-impl/index.html
和工作例如: http://svn.apache.org/viewvc/maven/shared/tags/maven-reporting-impl-3.0.0/src/it/setup-reporting-plugin/
所以,基本上,你需要这在的pom.xml:
<dependencies>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>@[email protected]</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
<version>3.0</version>
</dependency>
<!-- plugin API and plugin-tools -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>3.2.0</version>
</dependency>
</dependencies>
然后,你的主类必须扩展AbstractMavenReport
:
import java.util.Locale;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
/**
* Typical code to copy as a reporting plugin start: choose the goal name, then implement getOutputName(),
* getName(Locale), getDescription(Locale) and of course executeReport(Locale).
*/
@Mojo(name = "custom")
public class CustomReport
extends AbstractMavenReport
{
public String getOutputName()
{
return "custom-report";
}
public String getName(Locale locale)
{
return "Custom Maven Report";
}
public String getDescription(Locale locale)
{
return "Custom Maven Report Description";
}
@Override
protected void executeReport(Locale locale)
throws MavenReportException
{
// direct report generation using Doxia: compare with CustomReportRenderer to see the benefits of using
// ReportRenderer
getSink().head();
getSink().title();
getSink().text("Custom Report Title");
getSink().title_();
getSink().head_();
getSink().body();
getSink().section1();
getSink().sectionTitle1();
getSink().text("section");
getSink().sectionTitle1_();
getSink().text("Custom Maven Report content.");
getSink().section1_();
getSink().body_();
}
}
希望这将有助于Maven Reporting插件的未来开发者! ;-)
这里没有很多文档。你能告诉我们你想要做什么样的插件吗?最好的事情就是你所做的。 Whatch现有插件的代码。 如果你告诉我们一些关于你想要做的事情,我们可以建议一个插件来观看代码。 –
我正在尝试构建一个基于项目的某些源代码(用第三方编辑器的专有语言编写)生成参考指南的插件。像Javadoc,但有不同的输入和不同的语法。我实际上找到了我的答案(见下面的答案)。谢谢! –