Search in sources :

Example 1 with ReportPlugin

use of org.apache.maven.model.ReportPlugin in project maven-plugins by apache.

the class CheckPluginDocumentationMojo method checkConfiguredReportPlugins.

/**
     * Checks the project configured plugins if the required report plugins are present.
     *
     * @param project MavenProject to check
     * @param reporter listener
     * @todo maybe this should be checked default for all project?
     */
private void checkConfiguredReportPlugins(MavenProject project, DocumentationReporter reporter) {
    List<String> expectedPlugins = getRequiredPlugins();
    @SuppressWarnings("unchecked") List<ReportPlugin> reportPlugins = project.getReportPlugins();
    if (reportPlugins != null && reportPlugins.size() > 0) {
        for (ReportPlugin plugin : reportPlugins) {
            expectedPlugins.remove(plugin.getArtifactId());
        }
    } else {
        reporter.error("pom.xml has no report plugins configured.");
    }
    for (String expectedPlugin : expectedPlugins) {
        reporter.error("pom.xml is missing the report plugin: " + expectedPlugin + ".");
    }
}
Also used : ReportPlugin(org.apache.maven.model.ReportPlugin)

Example 2 with ReportPlugin

use of org.apache.maven.model.ReportPlugin in project maven-plugins by apache.

the class AbstractPmdReport method constructXRefLocation.

protected String constructXRefLocation(boolean test) {
    String location = null;
    if (linkXRef) {
        File xrefLoc = test ? xrefTestLocation : xrefLocation;
        String relativePath = PathTool.getRelativePath(outputDirectory.getAbsolutePath(), xrefLoc.getAbsolutePath());
        if (StringUtils.isEmpty(relativePath)) {
            relativePath = ".";
        }
        relativePath = relativePath + "/" + xrefLoc.getName();
        if (xrefLoc.exists()) {
            // XRef was already generated by manual execution of a lifecycle binding
            location = relativePath;
        } else {
            // Not yet generated - check if the report is on its way
            @SuppressWarnings("unchecked") List<ReportPlugin> reportPlugins = project.getReportPlugins();
            for (ReportPlugin plugin : reportPlugins) {
                String artifactId = plugin.getArtifactId();
                if ("maven-jxr-plugin".equals(artifactId) || "jxr-maven-plugin".equals(artifactId)) {
                    location = relativePath;
                }
            }
        }
        if (location == null) {
            getLog().warn("Unable to locate Source XRef to link to - DISABLED");
        }
    }
    return location;
}
Also used : ReportPlugin(org.apache.maven.model.ReportPlugin) File(java.io.File)

Example 3 with ReportPlugin

use of org.apache.maven.model.ReportPlugin 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());
}
Also used : MavenReport(org.apache.maven.reporting.MavenReport) MojoDescriptor(org.apache.maven.plugin.descriptor.MojoDescriptor) ArrayList(java.util.ArrayList) ReportSet(org.apache.maven.model.ReportSet) PluginDescriptor(org.apache.maven.plugin.descriptor.PluginDescriptor) ReportPlugin(org.apache.maven.model.ReportPlugin) StringWriter(java.io.StringWriter) List(java.util.List) ArrayList(java.util.ArrayList) MailingList(org.apache.maven.model.MailingList) File(java.io.File)

Example 4 with ReportPlugin

use of org.apache.maven.model.ReportPlugin in project maven-plugins by apache.

the class MinMavenProjectStub method getReportPlugins.

/** {@inheritDoc} */
public List<ReportPlugin> getReportPlugins() {
    ReportPlugin jxrPlugin = new ReportPlugin();
    jxrPlugin.setArtifactId("maven-jxr-plugin");
    return Collections.singletonList(jxrPlugin);
}
Also used : ReportPlugin(org.apache.maven.model.ReportPlugin)

Example 5 with ReportPlugin

use of org.apache.maven.model.ReportPlugin in project maven-plugins by apache.

the class MultiMavenProjectStub method getReportPlugins.

/** {@inheritDoc} */
public List<ReportPlugin> getReportPlugins() {
    ReportPlugin jxrPlugin = new ReportPlugin();
    jxrPlugin.setArtifactId("maven-jxr-plugin");
    return Collections.singletonList(jxrPlugin);
}
Also used : ReportPlugin(org.apache.maven.model.ReportPlugin)

Aggregations

ReportPlugin (org.apache.maven.model.ReportPlugin)9 File (java.io.File)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 MailingList (org.apache.maven.model.MailingList)1 Plugin (org.apache.maven.model.Plugin)1 ReportSet (org.apache.maven.model.ReportSet)1 MojoDescriptor (org.apache.maven.plugin.descriptor.MojoDescriptor)1 PluginDescriptor (org.apache.maven.plugin.descriptor.PluginDescriptor)1 MavenReport (org.apache.maven.reporting.MavenReport)1 Element (org.jdom.Element)1 Document (org.w3c.dom.Document)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1