Process Asciidoc with Gradle task

3.2k Views Asked by At

I want to convert some AsciiDoc .adoc file into HTML and use Gradle for that.

I am new to Gradle. I have found https://github.com/asciidoctor/asciidoctor-gradle-plugin and below is build.gradle that is about to do that, but with my level of Gradle I don't know what to do next

// https://github.com/asciidoctor/asciidoctor-gradle-plugin

buildscript {
    repositories {
        maven {
            name 'Bintray Asciidoctor repo'
            url  'http://dl.bintray.com/content/aalmiray/asciidoctor'
        }
        jcenter()
    }

    dependencies {
        classpath 'org.asciidoctor:asciidoctor-gradle-plugin:0.7.0'
    }
}

apply plugin: 'asciidoctor'

// append below the line: apply plugin: 'asciidoctor'

asciidoctor {
    outputDir = new File("$buildDir/docs")
    options = [
        eruby: 'erubis',
        attributes: [
            'source-highlighter': 'coderay',
            toc: '',
            idprefix: '',
            idseparator: '-'
        ]
    ]
    //+
    //sourceDir = new File(".")
}
2

There are 2 best solutions below

0
Sean Gilligan On

First, make sure you have Gradle installed.

Then, make sure you have files with filenames ending in .adoc, .asciidoc, .asc, or .ad. They should be in the src/asciidoc subdirectory of your project.

Then, run Gradle from a command line with the command:

gradle asciidoctor

0
kaskelotti On

I got my setup working with this tutorial. You don't have to explicitly set the JCenter repository as it can be used with jcenter() as you already have.

I don't know what's up with the asciidoctor plugin, but I had to use version 0.5.0 as 0.7.0 failed on internal error and 0.6.0 failed on some Ruby problems.