挖掘一下,我發現我的答案: 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,但有不同的輸入和不同的語法。我實際上找到了我的答案(見下面的答案)。謝謝! –