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;
}
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;
}
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;
}
Aggregations