Search in sources :

Example 6 with JavadocOptions

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

the class AbstractJavadocMojo method getExcludedPackages.

/**
     * Method to get the packages specified in the <code>excludePackageNames</code> parameter. The packages are split
     * with ',', ':', or ';' and then formatted.
     *
     * @return an array of String objects that contain the package names
     * @throws MavenReportException
     */
private String[] getExcludedPackages() throws MavenReportException {
    Set<String> excluded = new LinkedHashSet<String>();
    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.getExcludePackageNames())) {
                    excluded.addAll(options.getExcludePackageNames());
                }
            }
        }
    }
    // for the specified excludePackageNames
    if (StringUtils.isNotEmpty(excludePackageNames)) {
        List<String> packageNames = Arrays.asList(excludePackageNames.split("[,:;]"));
        excluded.addAll(trimValues(packageNames));
    }
    String[] result = new String[excluded.size()];
    if (isNotEmpty(excluded)) {
        int idx = 0;
        for (String exclude : excluded) {
            result[idx] = exclude.replace('.', File.separatorChar);
            idx++;
        }
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) JavadocBundle(org.apache.maven.plugin.javadoc.resolver.JavadocBundle) JavadocOptions(org.apache.maven.plugin.javadoc.options.JavadocOptions) IOException(java.io.IOException) MavenReportException(org.apache.maven.reporting.MavenReportException)

Example 7 with JavadocOptions

use of org.apache.maven.plugin.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();
    Writer writer = null;
    try {
        writer = WriterFactory.newXmlWriter(optionsFile);
        new JavadocOptionsXpp3Writer().write(writer, options);
    } finally {
        close(writer);
    }
    return options;
}
Also used : JavadocOptions(org.apache.maven.plugin.javadoc.options.JavadocOptions) JavadocOptionsXpp3Writer(org.apache.maven.plugin.javadoc.options.io.xpp3.JavadocOptionsXpp3Writer) File(java.io.File) JavadocOptionsXpp3Writer(org.apache.maven.plugin.javadoc.options.io.xpp3.JavadocOptionsXpp3Writer) Writer(java.io.Writer)

Example 8 with JavadocOptions

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

the class AbstractJavadocMojo method copyJavadocResources.

/**
     * Method that copy all <code>doc-files</code> directories from <code>javadocDirectory</code> of
     * the current project or of the projects in the reactor to the <code>outputDirectory</code>.
     *
     * @param anOutputDirectory the output directory
     * @throws java.io.IOException if any
     * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/whatsnew-1.2.html#docfiles">Reference
     *      Guide, Copies new "doc-files" directory for holding images and examples</a>
     * @see #docfilessubdirs
     */
private void copyJavadocResources(File anOutputDirectory) throws IOException {
    if (anOutputDirectory == null || !anOutputDirectory.exists()) {
        throw new IOException("The outputDirectory " + anOutputDirectory + " doesn't exists.");
    }
    if (includeDependencySources) {
        resolveDependencyBundles();
        if (isNotEmpty(dependencyJavadocBundles)) {
            for (JavadocBundle bundle : dependencyJavadocBundles) {
                File dir = bundle.getResourcesDirectory();
                JavadocOptions options = bundle.getOptions();
                if (dir != null && dir.isDirectory()) {
                    JavadocUtil.copyJavadocResources(anOutputDirectory, dir, options == null ? null : options.getExcludedDocfilesSubdirs());
                }
            }
        }
    }
    if (getJavadocDirectory() != null) {
        JavadocUtil.copyJavadocResources(anOutputDirectory, getJavadocDirectory(), excludedocfilessubdir);
    }
    if (isAggregator() && project.isExecutionRoot()) {
        for (MavenProject subProject : reactorProjects) {
            if (subProject != project && getJavadocDirectory() != null) {
                String javadocDirRelative = PathUtils.toRelative(project.getBasedir(), getJavadocDirectory().getAbsolutePath());
                File javadocDir = new File(subProject.getBasedir(), javadocDirRelative);
                JavadocUtil.copyJavadocResources(anOutputDirectory, javadocDir, excludedocfilessubdir);
            }
        }
    }
}
Also used : JavadocBundle(org.apache.maven.plugin.javadoc.resolver.JavadocBundle) JavadocOptions(org.apache.maven.plugin.javadoc.options.JavadocOptions) MavenProject(org.apache.maven.project.MavenProject) IOException(java.io.IOException) File(java.io.File)

Aggregations

JavadocOptions (org.apache.maven.plugin.javadoc.options.JavadocOptions)8 IOException (java.io.IOException)7 File (java.io.File)5 JavadocBundle (org.apache.maven.plugin.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.plugin.javadoc.options.io.xpp3.JavadocOptionsXpp3Reader)2 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)2 Writer (java.io.Writer)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.plugin.javadoc.options.BootclasspathArtifact)1 DocletArtifact (org.apache.maven.plugin.javadoc.options.DocletArtifact)1 JavadocPathArtifact (org.apache.maven.plugin.javadoc.options.JavadocPathArtifact)1 OfflineLink (org.apache.maven.plugin.javadoc.options.OfflineLink)1 ResourcesArtifact (org.apache.maven.plugin.javadoc.options.ResourcesArtifact)1