Skip to content

Instantly share code, notes, and snippets.

@m0j0hn
Last active June 22, 2017 00:25
Show Gist options
  • Select an option

  • Save m0j0hn/b7a03c532add64c3ec1ea36622a66d8e to your computer and use it in GitHub Desktop.

Select an option

Save m0j0hn/b7a03c532add64c3ec1ea36622a66d8e to your computer and use it in GitHub Desktop.

Enable specifying which asciidoctor-gradle-plugin backend(s) to run using gradle asciidoc -Pbackends=pdf,xhtml5.

asciidoctor {
  // Other configuration goes here

  backends = {
    // Enable -Pbackends='pdf,xhtml5' to specify backend(s) to use
    def BACKENDS = ['pdf','xhtml5'] // Default backends we use
    if(project.hasProperty('backends')){
      def backendsList = project.property('backends').split(',')
      backendsList.each { backend ->
        if (! BACKENDS.contains(backend)) {
          throw new InvalidUserDataException("${backend} is not a supported backend.\nUsage: gradle asciidoc -Pbackends=\'${BACKENDS.join(',')}\'")
        }
      }
      return backendsList
    } else {
      return BACKENDS // Default
    }
  }()

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment