auto-refresh: Automatically converting on change

Converts documents on change, that is, when one of them is modified, or a new one is added.

This plugin goal is aimed to help writing by removing the need for full rebuild to validate changes. When the output is HTML, you can combine it with a refresh browser extension or use the http goal to preview document changes while editing.


As this is a typical Maven plugin, simply declare the plugin in the <plugins> section of your POM file:

Plugin declaration in pom.xml
            <dependency> (1)
1 The plugin will use the latest AsciidoctorJ version available at release. To change it, set the desired version as a plugin dependency.
Goal setup
            <id>output-html</id>              (1)
            <phase>generate-resources</phase> (2)
                <goal>auto-refresh</goal>     (3)
1 This is simply a unique id for the execution.
2 The asciidoctor-maven-plugin does not run in any phase by default, so one must be specified.
3 The Asciidoctor Maven plugin auto-refresh goal.

Once started, this will keep the maven process running until you type the exit or quit command in the console. Or it is manually killed with Ctrl+C.

Due to some maven limitations, it is possible to run auto-refresh on your current project without changes provided the configuration is at top plugin level. Running mvn asciidoctor:auto-refresh will start, but will ignore <configuration> blocks inside <executions>.

Shared process-asciidoc, auto-refresh configuration example
    <configuration> (1)
        <configuration> (2)
1 Processed configuration.
2 Ignored configuration.


This goal inherits the same parameters as process-asciidoc and adds an additional parameter:


time in milliseconds between checks of the filesystem. Defaults to 2000


regular expression describing additional sources that force a full refresh. Useful when working with included/partial sources that aren’t converted individually. Defaults to empty

Inherited options


path where source files are located. By default checks for ${basedir}/src/docs/asciidoc, ${basedir}/src/asciidoc or ${basedir}/src/main/asciidoc in that order. When a custom value is set, no other paths are checked.

All paths and AsciiDoc documents that start with _ are considered internal and are skipped. That is, AsciiDocs are not converted and resources are not copied from them, but you can include them normally from other AsciiDocs.
This is useful to split your sources in sets of main documents and included parts.


an override to process a single source file; defaults to all files in ${sourceDirectory}.


(named extensions in v1.5.3 and below) a List<String> of non-standard file extensions to convert. Currently, ad, adoc, and asciidoc will be converted by default


list of resource files to copy to the output directory (e.g., images, css). The configuration follows the same patterns as the maven-resources-plugin. If not set, all resources inside ${sourceDirectory} are copied.

Converters that embed resources such as images into the output document need to be able to locate those resources at conversion time. For example, when generating a PDF (or HTML with the data-uri attribute set), all images need to be aggregated under a common root (i.e., image catalog). The imagesdir attribute should be overridden to point to that folder. When converting to HTML, images must be copied to the output location so that the browser can resolve those images when the user views the page.

        <!-- (Mandatory) Directory to copy from. Paths are relative to maven's ${baseDir} -->
        <!-- (Optional) Directory to copy to. By default uses the option `outputDirectory` -->
        <!-- (Optional) NOTE: SVN, GIT and other version control files are excluded by default, there's no need to add them -->
        <!-- (Optional) If not set, includes all files but default exceptions mentioned -->

locations where converted sources and copied resources will be places. Note that relative paths are added to the project root path. Defaults to ${}/generated-docs.


defaults to null, used to override the name of the generated output file, can be a relative or absolute path. Useful for backends that create a single file, e.g. the pdf backend. All output will be redirected to the same file, the same way as the -o, --out-file=OUT_FILE option from the asciidoctor CLI command.


(not Maven’s basedir) enables to set the root path for resources (e.g. included files), defaults to ${sourceDirectory}


set this to true to bypass generation, defaults to false


enables to specify whether the documents should be converted in the same folder structure as in the source directory or not, defaults to false. When true, instead of generating all output in a single folder, output files are generated in the same structure. See the following example

    ├── docs                          ├── docs
    │   ├── examples.adoc             │   ├── examples.html
    │   └── examples            =>    │   └── examples
    │       ├── html.adoc             │       ├── html.html
    │       └── docbook.adoc          │       └── docbook.html
    └── index.adoc                    └── index.html

only used when baseDir is not set, enables to specify that each AsciiDoc file must search for its resources in the same folder (for example, included files). Internally, for each AsciiDoc source, sets baseDir to the same path as the source file. Defaults to false


defaults to html5


defaults to null (which trigger’s Asciidoctor’s default of article)


defaults to erb, the version used in JRuby


defaults to true


list of directories of compatible templates to be used instead of the default built-in templates, empty by default.


template engine to use for the custom converter templates, disabled by default (null)


enables the built-in cache used by the template converter when reading the source of template files. Only relevant if the :template_dirs option is specified, defaults to true.


adds file and line number information to each parsed block (lineno and source_location attributes), defaults to false


tells the parser to capture images and links in the reference table available via the references property on the document AST object (experimental), defaults to false


a Map<String,Object> of Asciidoctor attributes to pass for conversion, defaults to null. Refer to the catalog of document attributes in the Asciidoctor user manual for a complete list.


In addition to attributes set in this section, Maven properties are also passed as attribute (replacing . by - in the name). These include those defined in the <properties> section of the project, parent projects and the user’s settings.xml.

  <my-site.version>2.3.0</my-site.version> (1)
1 Will be passed as my-site-version to the converter.

Note that when defining a build with multiple executions, shared attributes can be set in the global <configuration> section of the plugin.

Boolean attributes only require to be enabled or set. These, can be set with a empty tag or a boolean value. To unset an attribute, use value false.


embeds the CSS file and images into the output, defaults to false


enables to specify the location to one or more gem installation directories (same as GEM_PATH environment var), empty by default


a List<String> to specify additional Ruby libraries not packaged in AsciidoctorJ, empty by default


List of extensions to include during the conversion process (see AsciidoctorJ’s Extension API for information about the available options). For each extension, the implementation class must be specified in the className parameter, the blockName is only required when configuring a BlockProcessor, BlockMacroProcessor or InlineMacroProcessor.

extensions configuration example
        <dependency> (1)
1 Extensions must be included in the plugin’s execution classpath, not in the project’s.
Extensions can also be integrated through the SPI interface implementation. This method does not require any configuration in the pom.xml, see Automatically loading extensions for details.

enables Asciidoctor verbose messages, defaults to false. Enable it, for example, if you want to validate internal cross references and capture the messages with the logHandler option.


enables processing options for Asciidoctor messages (e.g. errors on missing included files), to either hide messages or setup build fail conditions based on them. Options are:

  • outputToConsole: Boolean, defaults to true. Redirects all Asciidoctor messages to Maven’s console logger as INFO during conversion.

  • failIf: build fail conditions, disabled by default. Allows setting one or many conditions that when met, abort the Maven build with BUILD FAILURE status.

    Note that the plugin matches that all conditions are met together. Unless you are controlling a very specific case, setting one condition should be enough.
    Also, messages matching fail conditions will be sent to Maven’s logger as ERROR. So, when enabling outputToConsole, some messages will appear duplicated as both INFO and ERROR.

    Currently, two conditions can be defined:

    • severity: severity of the Asciidoctor message, in order: INFO,WARN,ERROR,FATAL,UNKNOWN. Build will fail if a message is found of severity equal or higher.

    • containsText: text to search inside messages. Build will fail if the text is found.
      For example, set include to fail on any issue related to included files regardless the severity level.

      example: fail on any message
          <outputToConsole>false</outputToConsole> (1)
              <severity>DEBUG</severity> (2)
      1 Do not show messages as INFO in Maven output.
      2 Build will fail on any message of severity DEBUG or higher, that includes all. All matching messages will appear as ERROR in Maven output.
      Since version 1.5.8 of AsciidoctorJ set enableVerbose to true option to validate internal cross references, this is being improved to avoid false positives- See #2722 if your are interested in the details.

Error handling

If failIf is set and errors are present after start, these will be reported but the plugin will continue running. If errors are found during initialization, plugin won’t start.