Class Javadoc

  • All Implemented Interfaces:
    java.lang.Comparable<Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, Named, ExtensionAware, Task, PatternFilterable, Configurable<Task>

    public abstract class Javadoc
    extends SourceTask

    Generates HTML API documentation for Java classes.

    If you create your own Javadoc tasks remember to specify the 'source' property! Without source the Javadoc task will not create any documentation. Example:

     plugins {
         id 'java'
     task myJavadocs(type: Javadoc) {
       source = sourceSets.main.allJava

    An example how to create a task that runs a custom doclet implementation:

     plugins {
         id 'java'
     configurations {
     dependencies {
       //jaxDoclet "some.interesting:Dependency:1.0"
     task generateRestApiDocs(type: Javadoc) {
       source = sourceSets.main.allJava
       destinationDir = reporting.file("rest-api-docs")
       options.docletpath = configurations.jaxDoclet.files.asType(List)
       options.doclet = "com.lunatech.doclets.jax.jaxrs.JAXRSDoclet"
       options.addStringOption("jaxrscontext", "http://localhost:8080/myapp")
    • Constructor Detail

      • Javadoc

        public Javadoc()
    • Method Detail

      • generate

        protected void generate()
      • getSource

        public FileTree getSource()
        Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.

        The PathSensitivity for the sources is configured to be PathSensitivity.ABSOLUTE. If your sources are less strict, please change it accordingly by overriding this method in your subclass.

        getSource in class SourceTask
        The source.
      • getJavadocTool

        public Property<JavadocTool> getJavadocTool()
        Configures the javadoc executable to be used to generate javadoc documentation.
      • getDestinationDir

        public getDestinationDir()

        Returns the directory to generate the documentation into.

        The directory.
      • getOutputDirectory

        protected getOutputDirectory()
      • setDestinationDir

        public void setDestinationDir​( destinationDir)

        Sets the directory to generate the documentation into.

      • getMaxMemory

        public java.lang.String getMaxMemory()
        Returns the amount of memory allocated to this task.
      • setMaxMemory

        public void setMaxMemory​(java.lang.String maxMemory)
        Sets the amount of memory allocated to this task.
        maxMemory - The amount of memory
      • getTitle

        public java.lang.String getTitle()

        Returns the title for the generated documentation.

        The title, possibly null.
      • setTitle

        public void setTitle​(@Nullable
                             java.lang.String title)

        Sets the title for the generated documentation.

      • isVerbose

        public boolean isVerbose()
        Returns whether Javadoc generation is accompanied by verbose output.
        See Also:
      • setVerbose

        public void setVerbose​(boolean verbose)
        Sets whether Javadoc generation is accompanied by verbose output or not. The verbose output is done via println (by the underlying Ant task). Thus it is not handled by our logging.
        verbose - Whether the output should be verbose.
      • getClasspath

        public FileCollection getClasspath()
        Returns the classpath to use to resolve type references in the source code.
        The classpath.
      • setClasspath

        public void setClasspath​(FileCollection classpath)
        Sets the classpath to use to resolve type references in this source code.
        classpath - The classpath. Must not be null.
      • getModularity

        public ModularitySpec getModularity()
        Returns the module path handling of this javadoc task.
      • getOptions

        public MinimalJavadocOptions getOptions()
        Returns the Javadoc generation options.
        The options. Never returns null.
      • options

        public void options​(@DelegatesTo(MinimalJavadocOptions.class)
                            Closure<?> block)
        Convenience method for configuring Javadoc generation options.
        block - The configuration block for Javadoc generation options.
      • options

        public void options​(Action<? super MinimalJavadocOptions> action)
        Convenience method for configuring Javadoc generation options.
        action - The action for Javadoc generation options.
      • isFailOnError

        public boolean isFailOnError()
        Specifies whether this task should fail when errors are encountered during Javadoc generation. When true, this task will fail on Javadoc error. When false, this task will ignore Javadoc errors.
      • setFailOnError

        public void setFailOnError​(boolean failOnError)
      • getOptionsFile

        public getOptionsFile()
      • getExecutable

        public java.lang.String getExecutable()
        Returns the Javadoc executable to use to generate the Javadoc. When null, the Javadoc executable for the current JVM is used or from the toolchain if configured.
        The executable. May be null.
        See Also:
      • setExecutable

        public void setExecutable​(@Nullable
                                  java.lang.String executable)
      • getDeleter

        protected org.gradle.internal.file.Deleter getDeleter()
      • getProjectLayout

        protected ProjectLayout getProjectLayout()
      • getObjectFactory

        protected ObjectFactory getObjectFactory()
      • getJavaModuleDetector

        protected org.gradle.internal.jvm.JavaModuleDetector getJavaModuleDetector()
      • getProviderFactory

        protected ProviderFactory getProviderFactory()