Search in sources :

Example 6 with JavadocOptions

use of org.apache.maven.plugins.javadoc.options.JavadocOptions in project maven-plugins by apache.

the class AbstractJavadocMojo method buildJavadocOptions.

/**
 * Generate a javadoc-options XML file, for either bundling with a javadoc-resources artifact OR
 * supplying to a distro module in a includeDependencySources configuration, so the javadoc options
 * from this execution can be reconstructed and merged in the distro build.
 *
 * @return {@link JavadocOptions}
 * @throws IOException {@link IOException}
 * @since 2.7
 */
protected final JavadocOptions buildJavadocOptions() throws IOException {
    JavadocOptions options = new JavadocOptions();
    options.setBootclasspathArtifacts(toList(bootclasspathArtifacts));
    options.setDocfilesSubdirsUsed(docfilessubdirs);
    options.setDocletArtifacts(toList(docletArtifact, docletArtifacts));
    options.setExcludedDocfilesSubdirs(excludedocfilessubdir);
    options.setExcludePackageNames(toList(excludePackageNames));
    options.setGroups(toList(groups));
    options.setLinks(links);
    options.setOfflineLinks(toList(offlineLinks));
    options.setResourcesArtifacts(toList(resourcesArtifacts));
    options.setTagletArtifacts(toList(tagletArtifact, tagletArtifacts));
    options.setTaglets(toList(taglets));
    options.setTags(toList(tags));
    if (getProject() != null && getJavadocDirectory() != null) {
        options.setJavadocResourcesDirectory(toRelative(getProject().getBasedir(), getJavadocDirectory().getAbsolutePath()));
    }
    File optionsFile = getJavadocOptionsFile();
    try (Writer writer = WriterFactory.newXmlWriter(optionsFile)) {
        new JavadocOptionsXpp3Writer().write(writer, options);
    }
    return options;
}
Also used : JavadocOptions(org.apache.maven.plugins.javadoc.options.JavadocOptions) JavadocOptionsXpp3Writer(org.apache.maven.plugins.javadoc.options.io.xpp3.JavadocOptionsXpp3Writer) File(java.io.File) Writer(java.io.Writer) JavadocOptionsXpp3Writer(org.apache.maven.plugins.javadoc.options.io.xpp3.JavadocOptionsXpp3Writer)

Example 7 with JavadocOptions

use of org.apache.maven.plugins.javadoc.options.JavadocOptions in project maven-plugins by apache.

the class AbstractJavadocMojo method collectLinks.

private Set<String> collectLinks() throws MavenReportException {
    Set<String> links = new LinkedHashSet<>();
    if (includeDependencySources) {
        try {
            resolveDependencyBundles();
        } catch (IOException e) {
            throw new MavenReportException("Failed to resolve javadoc bundles from dependencies: " + e.getMessage(), e);
        }
        if (isNotEmpty(dependencyJavadocBundles)) {
            for (JavadocBundle bundle : dependencyJavadocBundles) {
                JavadocOptions options = bundle.getOptions();
                if (options != null && isNotEmpty(options.getLinks())) {
                    links.addAll(options.getLinks());
                }
            }
        }
    }
    if (isNotEmpty(this.links)) {
        links.addAll(this.links);
    }
    links.addAll(getDependenciesLinks());
    return links;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) JavadocBundle(org.apache.maven.plugins.javadoc.resolver.JavadocBundle) JavadocOptions(org.apache.maven.plugins.javadoc.options.JavadocOptions) IOException(java.io.IOException) MavenReportException(org.apache.maven.reporting.MavenReportException)

Example 8 with JavadocOptions

use of org.apache.maven.plugins.javadoc.options.JavadocOptions in project maven-plugins by apache.

the class ResourceResolver method resolveBundleFromProject.

private static List<JavadocBundle> resolveBundleFromProject(SourceResolverConfig config, MavenProject project, Artifact artifact) throws IOException {
    List<JavadocBundle> bundles = new ArrayList<>();
    List<String> classifiers = new ArrayList<>();
    if (config.includeCompileSources()) {
        classifiers.add(AbstractJavadocMojo.JAVADOC_RESOURCES_ATTACHMENT_CLASSIFIER);
    }
    if (config.includeTestSources()) {
        classifiers.add(AbstractJavadocMojo.TEST_JAVADOC_RESOURCES_ATTACHMENT_CLASSIFIER);
    }
    for (String classifier : classifiers) {
        File optionsFile = new File(project.getBuild().getDirectory(), "javadoc-bundle-options/javadoc-options-" + classifier + ".xml");
        if (!optionsFile.exists()) {
            continue;
        }
        FileInputStream stream = null;
        try {
            stream = new FileInputStream(optionsFile);
            JavadocOptions options = new JavadocOptionsXpp3Reader().read(stream);
            stream.close();
            stream = null;
            bundles.add(new JavadocBundle(options, new File(project.getBasedir(), options.getJavadocResourcesDirectory())));
        } catch (XmlPullParserException e) {
            IOException error = new IOException("Failed to read javadoc options from: " + optionsFile + "\nReason: " + e.getMessage());
            error.initCause(e);
            throw error;
        } finally {
            close(stream);
        }
    }
    return bundles;
}
Also used : JavadocOptionsXpp3Reader(org.apache.maven.plugins.javadoc.options.io.xpp3.JavadocOptionsXpp3Reader) JavadocOptions(org.apache.maven.plugins.javadoc.options.JavadocOptions) ArrayList(java.util.ArrayList) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

JavadocOptions (org.apache.maven.plugins.javadoc.options.JavadocOptions)8 IOException (java.io.IOException)7 File (java.io.File)5 JavadocBundle (org.apache.maven.plugins.javadoc.resolver.JavadocBundle)5 LinkedHashSet (java.util.LinkedHashSet)4 MavenReportException (org.apache.maven.reporting.MavenReportException)4 ArrayList (java.util.ArrayList)3 FileInputStream (java.io.FileInputStream)2 Artifact (org.apache.maven.artifact.Artifact)2 JavadocOptionsXpp3Reader (org.apache.maven.plugins.javadoc.options.io.xpp3.JavadocOptionsXpp3Reader)2 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)2 Writer (java.io.Writer)1 AbstractMap (java.util.AbstractMap)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)1 ArtifactNotFoundException (org.apache.maven.artifact.resolver.ArtifactNotFoundException)1 ArtifactResolutionException (org.apache.maven.artifact.resolver.ArtifactResolutionException)1 BootclasspathArtifact (org.apache.maven.plugins.javadoc.options.BootclasspathArtifact)1