use of org.apache.maven.model.ReportSet in project maven-plugins by apache.
the class PdfMojo method generateMavenReports.
/**
* Generate all Maven reports defined in <code>${project.reporting}</code> part
* only if <code>generateReports</code> is enabled.
*
* @param locale not null
* @throws MojoExecutionException if any
* @throws IOException if any
* @since 1.1
*/
private void generateMavenReports(Locale locale) throws MojoExecutionException, IOException {
if (!includeReports) {
getLog().info("Skipped report generation.");
return;
}
if (project.getReporting() == null) {
getLog().info("No report was specified.");
return;
}
for (final ReportPlugin reportPlugin : project.getReporting().getPlugins()) {
final PluginDescriptor pluginDescriptor = getPluginDescriptor(reportPlugin);
if (pluginDescriptor != null) {
List<String> goals = new ArrayList<String>(8);
for (final ReportSet reportSet : reportPlugin.getReportSets()) {
for (String goal : reportSet.getReports()) {
goals.add(goal);
}
}
List mojoDescriptors = pluginDescriptor.getMojos();
for (Object mojoDescriptor1 : mojoDescriptors) {
final MojoDescriptor mojoDescriptor = (MojoDescriptor) mojoDescriptor1;
if (goals.isEmpty() || (!goals.isEmpty() && goals.contains(mojoDescriptor.getGoal()))) {
MavenReport report = getMavenReport(mojoDescriptor);
generateMavenReport(report, mojoDescriptor.getPluginDescriptor().getPluginArtifact(), locale);
}
}
}
}
// generate project-info report
if (!getGeneratedMavenReports(locale).isEmpty()) {
File outDir = new File(getGeneratedSiteDirectoryTmp(), "xdoc");
if (!locale.getLanguage().equals(defaultLocale.getLanguage())) {
outDir = new File(new File(getGeneratedSiteDirectoryTmp(), locale.getLanguage()), "xdoc");
}
outDir.mkdirs();
File piReport = new File(outDir, "project-info.xml");
StringWriter sw = new StringWriter();
PdfSink sink = new PdfSink(sw);
ProjectInfoRenderer r = new ProjectInfoRenderer(sink, getGeneratedMavenReports(locale), i18n, locale);
r.render();
writeGeneratedReport(sw.toString(), piReport);
}
// copy generated site
copySiteDir(getGeneratedSiteDirectoryTmp(), getSiteDirectoryTmp());
copySiteDir(generatedSiteDirectory, getSiteDirectoryTmp());
}
use of org.apache.maven.model.ReportSet in project maven-plugins by apache.
the class MavenJDOMWriter method iterateReportSet.
// -- void iterateReportPlugin(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
* Method iterateReportSet
*
* @param counter
* @param childTag
* @param parentTag
* @param list
* @param parent
*/
protected void iterateReportSet(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) {
boolean shouldExist = list != null && list.size() > 0;
Element element = updateElement(counter, parent, parentTag, shouldExist);
if (shouldExist) {
Iterator it = list.iterator();
Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator();
if (!elIt.hasNext()) {
elIt = null;
}
Counter innerCount = new Counter(counter.getDepth() + 1);
while (it.hasNext()) {
ReportSet value = (ReportSet) it.next();
Element el;
if (elIt != null && elIt.hasNext()) {
el = (Element) elIt.next();
if (!elIt.hasNext()) {
elIt = null;
}
} else {
el = factory.element(childTag, element.getNamespace());
insertAtPreferredLocation(element, el, innerCount);
}
updateReportSet(value, childTag, innerCount, el);
innerCount.increaseCount();
}
if (elIt != null) {
while (elIt.hasNext()) {
elIt.next();
elIt.remove();
}
}
}
}
Aggregations