Search in sources :

Example 1 with ExtractionException

use of org.apache.maven.tools.plugin.extractor.ExtractionException in project maven-plugins by apache.

the class CheckPluginDocumentationMojo method checkPackagingSpecificDocumentation.

protected void checkPackagingSpecificDocumentation(MavenProject project, DocumentationReporter reporter) {
    PluginDescriptor descriptor = new PluginDescriptor();
    try {
        mojoScanner.populatePluginDescriptor(project, descriptor);
    } catch (InvalidPluginDescriptorException e) {
        reporter.error("Failed to parse mojo descriptors.\nError: " + e.getMessage());
        descriptor = null;
    } catch (ExtractionException e) {
        reporter.error("Failed to parse mojo descriptors.\nError: " + e.getMessage());
        descriptor = null;
    }
    if (descriptor != null) {
        @SuppressWarnings("unchecked") List<MojoDescriptor> mojos = descriptor.getMojos();
        // ensure that all mojo classes are documented
        if (mojos != null && !mojos.isEmpty()) {
            for (MojoDescriptor mojo : mojos) {
                String mojoDescription = mojo.getDescription();
                if (mojoDescription == null || mojoDescription.trim().length() < MIN_DESCRIPTION_LENGTH) {
                    reporter.error("Mojo: \'" + mojo.getGoal() + "\' is missing a description.");
                }
                @SuppressWarnings("unchecked") List<Parameter> params = mojo.getParameters();
                // ensure that all parameters are documented
                if (params != null && !params.isEmpty()) {
                    for (Parameter param : params) {
                        if (param.getRequirement() == null && param.isEditable()) {
                            String paramDescription = param.getDescription();
                            if (paramDescription == null || paramDescription.trim().length() < MIN_DESCRIPTION_LENGTH) {
                                reporter.error("Parameter: \'" + param.getName() + "\' in mojo: \'" + mojo.getGoal() + "\' is missing a description.");
                            }
                        }
                    }
                }
            }
        }
    }
    checkConfiguredReportPlugins(project, reporter);
    checkProjectSite(project, reporter);
}
Also used : PluginDescriptor(org.apache.maven.plugin.descriptor.PluginDescriptor) ExtractionException(org.apache.maven.tools.plugin.extractor.ExtractionException) MojoDescriptor(org.apache.maven.plugin.descriptor.MojoDescriptor) InvalidPluginDescriptorException(org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException) Parameter(org.apache.maven.plugin.descriptor.Parameter)

Aggregations

InvalidPluginDescriptorException (org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException)1 MojoDescriptor (org.apache.maven.plugin.descriptor.MojoDescriptor)1 Parameter (org.apache.maven.plugin.descriptor.Parameter)1 PluginDescriptor (org.apache.maven.plugin.descriptor.PluginDescriptor)1 ExtractionException (org.apache.maven.tools.plugin.extractor.ExtractionException)1