Top Description Inners Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class Javadoc

extends Task
Class Inheritance
Imports
java.io.BufferedReader, .BufferedWriter, .File, .FileNotFoundException, .FileReader, .FileWriter, .IOException, .InputStream, .InputStreamReader, .OutputStreamWriter, java.net.MalformedURLException, .URL, java.nio.charset.StandardCharsets, java.nio.file.Files, java.util.ArrayList, .Collections, .Enumeration, .HashSet, .Iterator, .List, .Locale, .Set, .StringTokenizer, .Vector, java.util.stream.Collectors, org.apache.tools.ant.BuildException, .DirectoryScanner, .MagicNames, .Project, .ProjectComponent, .Task, org.apache.tools.ant.types.Commandline, .DirSet, .EnumeratedAttribute, .FileSet, .Path, .PatternSet, .Reference, .Resource, .ResourceCollection, org.apache.tools.ant.types.resources.FileProvider, org.apache.tools.ant.util.FileUtils, .JavaEnvUtils

Generates Javadoc documentation for a collection of source code.

Current known limitations are:

If no doclet is set, then the version and author are by default "yes".

Note

This task is run on another VM because the Javadoc code calls System.exit() which would break Ant functionality.

Since
Ant 1.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Javadoc.AccessType

EnumeratedAttribute implementation supporting the Javadoc scoping values.

public class
Javadoc.DocletInfo

This class stores info about doclets.

public class
Javadoc.DocletParam

Inner class used to manage doclet parameters.

public static class
Javadoc.ExtensionInfo

A project aware class used for Javadoc extensions which take a name and a path such as doclet and taglet arguments.

public class
Javadoc.GroupArgument

A class corresponding to the group nested element.

public static class
Javadoc.Html

An HTML element in the Javadoc.

private class
public class
Javadoc.LinkArgument

Represents a link triplet (href, whether link is offline, location of the package list if off line)

public static class
Javadoc.PackageName

Used to track info about the packages to be javadoc'd

public class
Javadoc.ResourceCollectionContainer

Holds a collection of ResourceCollections.

public static class
Javadoc.SourceFile

This class is used to manage the source files to be processed.

public class
Javadoc.TagArgument

Class representing a -tag argument.

Field Summary

Modifier and TypeField and Description
private boolean
private Path
private Javadoc.Html
private boolean
private Path
private final Commandline
cmd

The command line built to execute Javadoc.

private File
private String
private boolean
private Javadoc.DocletInfo
private Javadoc.Html
private String
private final List<Javadoc.PackageName>
private String
private boolean
failOnError

Flag which indicates if the task should fail if there is a Javadoc error.

private boolean
failOnWarning

Flag which indicates if the task should fail if there is a Javadoc warning.

private static final FileUtils
private Javadoc.Html
private String
private final List<Javadoc.GroupArgument>
private Javadoc.Html
private boolean
private final List<Javadoc.LinkArgument>
private boolean
private static final String
private static final int
private final List<Javadoc.PackageName>
private Path
private Path
private final Javadoc.ResourceCollectionContainer
private String
private String
private final List<Javadoc.PackageName>
private final List<DirSet>
private boolean
pack-priv static final String[]
SCOPE_ELEMENTS

Scope element verbose names.

private String
private final List<Javadoc.SourceFile>
private Path
private final List<Object>
private boolean
private boolean
private boolean
Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
addArgIf(final boolean
the flag which controls if the argument is added.
b
,
final String
the argument value.
arg
)

Utility method to add an argument to the command line conditionally based on the given flag.

private void
addArgIfNotEmpty(final String
the argument name.
key
,
final String
the argument value.
value
)

Utility method to add a Javadoc argument.

public void
addBottom(final Javadoc.Html
the bottom text.
text
)

Set the text to be placed at the bottom of each output file.

public void
addDoctitle(final Javadoc.Html
the HTML element containing the document title.
text
)

Add a document title to use for the overview page.

public void
addExcludePackage(final Javadoc.PackageName
the name of the package (wildcards are not permitted).
pn
)

Add a package to be excluded from the Javadoc run.

public void
addFileset(final FileSet
a file set
fs
)

Adds a fileset.

public void
addFooter(final Javadoc.Html
the footer text.
text
)

Set the footer text to be placed at the bottom of each output file.

public void
addHeader(final Javadoc.Html
the header text
text
)

Set the header text to be placed at the top of each output file.

public void
addModule(final Javadoc.PackageName
the module name
mn
)

Add a single module to be processed.

public void
addPackage(final Javadoc.PackageName
the package name, possibly wildcarded.
pn
)

Add a single package to be processed.

public void
addPackageset(final DirSet
a directory set
packageSet
)

Adds a packageset.

public void
addSource(final Javadoc.SourceFile
the source file to be processed.
sf
)

Add a single source file.

private void
addSourceFiles(final List<Javadoc.SourceFile> sf)

Add the files matched by the nested source files to the Vector as SourceFile instances.

public void
addTaglet(final Javadoc.ExtensionInfo
information about the taglet.
tagletInfo
)

Add a taglet

private void
private void
checkPackages(final List<String> packagesToDoc, final Path sourceDirs)

private void
checkPackagesToDoc(final List<String> packagesToDoc, final List<Javadoc.SourceFile> sourceFilesToDoc)

private void
private boolean
public Commandline.Argument

Returns:

a command-line argument to configure
createArg
()

Adds a command-line argument.

public Path

Returns:

a new Path instance to be configured with the boot classpath.
createBootclasspath
()

Create a Path to be configured with the boot classpath

public Path

Returns:

a new Path instance to be configured with the classpath.
createClasspath
()

Create a Path to be configured with the classpath to use

public Javadoc.DocletInfo

Returns:

a new DocletInfo instance to be configured.
createDoclet
()

Create a doclet to be used in the documentation generation.

public Javadoc.GroupArgument

Returns:

a group argument to be configured
createGroup
()

Separates packages on the overview page into whatever groups you specify, one group per table.

public Path

Returns:

a new Path instance to be configured by the Ant core.
createModulePath
()

Create a path to be configured with the locations of the module files.

public Path

Returns:

a new Path instance to be configured by the Ant core.
createModuleSourcePath
()

Create a path to be configured with the locations of the module source files.

public Javadoc.ResourceCollectionContainer

Returns:

the source files to configure.
createSourceFiles
()

Adds a container for resource collections.

public Path

Returns:

a new Path instance to be configured by the Ant core.
createSourcepath
()

Create a path to be configured with the locations of the source files.

public Javadoc.TagArgument

Returns:

tag argument to be configured
createTag
()

Creates and adds a -tag argument.

private void
doBootPath(final Commandline toExecute)

private void
doDocFilesSubDirs(final Commandline toExecute)

private void
doDoclet(final Commandline toExecute)

private void
doGroup(final Commandline toExecute)

private void
doGroups(final Commandline toExecute)

private void
doLinkSource(final Commandline toExecute)

private void
private void
doNoqualifier(final Commandline toExecute)

private void
doSource(final Commandline toExecute)

private void
doSourceAndPackageNames(final Commandline toExecute, final List<String> packagesToDoc, final List<Javadoc.SourceFile> sourceFilesToDoc, final boolean useExternalFile, final File tmpList, final BufferedWriter srcListWriter)

private void
doSourcePath(final Commandline toExecute, final Path sourceDirs)

private void
doTags(final Commandline toExecute)

public void
execute()

Overrides org.apache.tools.ant.Task.execute.

Execute the task.
protected String

Returns:

the converted string
expand
(final String
the string to expand
content
)

Convenience method to expand properties.

private String
fixLineFeeds(final String orig)

private void
private void
parsePackages(final List<String> pn, final Path sp)

Add the directories matched by the nested dirsets to the Vector and the base directories of the dirsets to the Path.

private String
patchContent(final String fileContents, final String fixData)

private int
postProcess(final File file, final String fixData)

private void
private String

Returns:

the quoted string, if there is no need to quote the string, return the original string.
quoteString
(final String
the string to quote
str
)

Quote a string to place in a @ file.

private String
quoteString(final String str, final char delim)

public void
setAccess(final Javadoc.AccessType
the scope to be processed.
at
)

Set the scope to be processed.

public void
setAdditionalparam(final String
the additional command line parameter for the javadoc task.
add
)

Set an additional parameter on the command line

public void
setAuthor(final boolean
true if the author tag should be included.
b
)

Include the author tag in the generated documentation.

public void
setBootclasspath(final Path
the boot classpath.
path
)

Set the boot classpath to use.

public void
setBootClasspathRef(final Reference
the reference to an instance defining the bootclasspath.
r
)

Adds a reference to a CLASSPATH defined elsewhere.

public void
setBottom(final String
the bottom text.
bottom
)

Set the text to be placed at the bottom of each output file.

public void
setBreakiterator(final boolean
a String value
b
)

Enables the -linksource switch, will be ignored if Javadoc is not the 1.4 version.

public void
setCharset(final String
the name of the charset
src
)

Charset for cross-platform viewing of generated documentation.

public void
setClasspath(final Path
an Ant Path object containing the compilation classpath.
path
)

Set the classpath to be used for this Javadoc run.

public void
setClasspathRef(final Reference
the reference to an instance defining the classpath.
r
)

Adds a reference to a CLASSPATH defined elsewhere.

public void
setDefaultexcludes(final boolean
"true"|"on"|"yes" when default exclusions should be used, "false"|"off"|"no" when they shouldn't be used.
useDefaultExcludes
)

Sets whether default exclusions should be used or not.

public void
setDestdir(final File
the destination directory.
dir
)

Set the directory where the Javadoc output will be generated.

public void
setDocencoding(final String
name of the encoding to use.
enc
)

Output file encoding name.

public void
setDocFilesSubDirs(final boolean
boolean
b
)

Enables deep-copying of doc-files directories.

public void
setDoclet(final String
the name of the doclet class.
docletName
)

Set the class that starts the doclet used in generating the documentation.

public void
setDocletPath(final Path
the doclet classpath.
docletPath
)

Set the classpath used to find the doclet class.

public void
setDocletPathRef(final Reference
the reference to the Path instance to use as the doclet classpath.
r
)

Set the classpath used to find the doclet class by reference.

public void
setDoctitle(final String
the Document title.
doctitle
)

Set the title of the generated overview page.

public void
setEncoding(final String
the name of the encoding for the source files.
enc
)

Set the encoding name of the source files,

public void
setExcludeDocFilesSubDir(final String
String
s
)

Colon-separated list of doc-files subdirectories to skip if docFilesSubDirs is true.

public void
setExcludePackageNames(final String
a comma separated list of packages to be excluded. This may not include wildcards.
packages
)

Set the list of packages to be excluded.

public void
setExecutable(final String
the command to invoke.
executable
)

Sets the actual executable command to invoke, instead of the binary javadoc found in Ant's JDK.

public void
setExtdirs(final String
the string version of the path.
path
)

Deprecated since 1.5.x. Use the setExtdirs(Path) version.
Set the location of the extensions directories.
public void
setExtdirs(final Path
a path containing the extension directories.
path
)

Set the location of the extensions directories.

public void
setFailonerror(final boolean
a boolean value
b
)

Should the build process fail if Javadoc fails (as indicated by a non zero return code)?

public void
setFailonwarning(final boolean
a boolean value
b
)

Should the build process fail if Javadoc warns (as indicated by the word "warning" on stdout)?

public void
setFooter(final String
the footer text.
footer
)

Set the footer text to be placed at the bottom of each output file.

public void
setGroup(final String
the group packages - a command separated list of group specs, each one being a group name and package specification separated by a space.
src
)

Group specified packages together in overview page.

public void
setHeader(final String
the header text
header
)

Set the header text to be placed at the top of each output file.

public void
setHelpfile(final File
the file containing help content.
f
)

Specifies the HTML help file to use.

public void
setIncludeNoSourcePackages(final boolean
a boolean value.
b
)

If set to true, Ant will also accept packages that only hold package.html files but no Java sources.

public void
setLinkoffline(final String
the offline link specification (url and package list)
src
)

Link to docs at "url" using package list at "url2" - separate the URLs by using a space character.

public void
setLinksource(final boolean
a String value
b
)

Enables the -linksource switch, will be ignored if Javadoc is not the 1.4 version.

public void
setLocale(final String
the locale to use.
locale
)

Set the local to use in documentation generation.

public void
setMaxmemory(final String
a string indicating the maximum memory according to the JVM conventions (e.g. 128m is 128 Megabytes)
max
)

Set the maximum memory to be used by the javadoc process

public void
setModulenames(final String
a comma separated list of module names
modules
)

Set the module names to be processed.

public void
setModulePath(final Path
a Path instance containing the modules.
mp
)

Specify where to find modules

public void
setModulePathref(final Reference
the reference containing the module path definition.
r
)

Adds a reference to a path defined elsewhere that defines the module path.

public void
setModuleSourcePath(final Path
a Path instance containing the sources for modules.
mp
)

Specify where to find sources for modules

public void
setModuleSourcePathref(final Reference
the reference containing the module source path definition.
r
)

Adds a reference to a path defined elsewhere that defines the module source path.

public void
setNodeprecated(final boolean
If true, do not include deprecated information.
b
)

Control deprecation information

public void
setNodeprecatedlist(final boolean
if true, do not generate deprecated list.
b
)

Control deprecated list generation

public void
setNohelp(final boolean
if true, do not generate help link
b
)

Control generation of help link.

public void
setNoindex(final boolean
if true, do not generate index.
b
)

Control generation of index.

public void
setNonavbar(final boolean
if true, do not generate navigation bar.
b
)

Control generation of the navigation bar.

public void
setNoqualifier(final String
the parameter to the -noqualifier switch
noqualifier
)

Enables the -noqualifier switch, will be ignored if Javadoc is not the 1.4 version.

public void
setNotree(final boolean
if true, do not generate class hierarchy.
b
)

Control class tree generation.

public void
setOld(final boolean
if true attempt to generate old style documentation.
b
)

Indicate whether Javadoc should produce old style (JDK 1.1) documentation.

public void
setOverview(final File
the file containing the overview.
f
)

Specify the file containing the overview to be included in the generated documentation.

public void
setPackage(final boolean
true if scope is to be package level.
b
)

Indicate whether only package, protected and public classes and members are to be included in the scope processed

public void
setPackageList(final String
the file containing the package list.
src
)

The name of a file containing the packages to process.

public void
setPackagenames(final String
a comma separated list of packages specs (may be wildcarded).
packages
)

Set the package names to be processed.

public void
setPostProcessGeneratedJavadocs(final boolean
boolean
b
)

Whether to post-process the generated javadocs in order to mitigate CVE-2013-1571.

public void
setPrivate(final boolean
true if scope is to be private level.
b
)

Indicate whether all classes and members are to be included in the scope processed

public void
setProtected(final boolean
true if scope is to be protected.
b
)

Indicate whether only protected and public classes and members are to be included in the scope processed

public void
setPublic(final boolean
true if scope is to be public.
b
)

Indicate whether only public classes and members are to be included in the scope processed

public void
setSerialwarn(final boolean
if true, generate warning about the serial tag.
b
)

Control warnings about serial tag.

public void
setSource(final String
a String value
source
)

Enables the -source switch, will be ignored if Javadoc is not the 1.4 version.

public void
setSourcefiles(final String
a comma separated list of source files.
src
)

Set the list of source files to process.

public void
setSourcepath(final Path
a Path instance containing the various source directories.
src
)

Specify where to find source file

public void
setSourcepathRef(final Reference
the reference containing the source path definition.
r
)

Adds a reference to a CLASSPATH defined elsewhere.

public void
setSplitindex(final boolean
true if the index should be split into a file per letter.
b
)

Generate a split index

public void
setStylesheetfile(final File
the file with the CSS to use.
f
)

Specifies the CSS stylesheet file to use.

public void
setUse(final boolean
true if the use page should be generated.
b
)

Generate the "use" page for each package.

public void
setUseExternalFile(final boolean
true if an external file is to be used.
b
)

Work around command line length limit by using an external file for the sourcefiles.

public void
setVerbose(final boolean
true if operation is to be verbose.
b
)

Run javadoc in verbose mode

public void
setVersion(final boolean
true if the version tag should be included.
b
)

Include the version tag in the generated documentation.

public void
setWindowtitle(final String
the window title to use.
title
)

Set the title to be placed in the HTML <title> tag of the generated documentation.

private void
writeExternalArgs(final Commandline toExecute)

Inherited from org.apache.tools.ant.Task:
bindToOwnergetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputinitisInvalidloglogloglogmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType