Skip to content

Instantly share code, notes, and snippets.

@mojavelinux
Last active March 2, 2017 18:00

Revisions

  1. mojavelinux revised this gist Feb 12, 2017. No changes.
  2. mojavelinux revised this gist Feb 12, 2017. No changes.
  3. mojavelinux revised this gist Feb 12, 2017. No changes.
  4. mojavelinux revised this gist Feb 12, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build.gradle
    Original file line number Diff line number Diff line change
    @@ -47,7 +47,7 @@ tasks.withType(AsciidoctorPdfTask) {
    gemPath jrubyPrepare.outputDir
    requires 'asciidoctor-pdf'
    backends 'pdf'
    sourceDir '.'
    sourceDir projectDir
    resources {}
    outputDir buildDir
    separateOutputDirs false
  5. mojavelinux created this gist Feb 12, 2017.
    56 changes: 56 additions & 0 deletions build.gradle
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@
    buildscript {
    dependencies {
    classpath 'org.asciidoctor:asciidoctorj:1.5.4.1'
    }
    }

    plugins {
    id 'org.asciidoctor.convert' version '1.5.3'
    id 'com.github.jruby-gradle.base' version '1.3.3'
    }

    dependencies {
    gems('rubygems:asciidoctor-pdf:1.5.0.alpha.14') {
    exclude module: 'asciidoctor'
    exclude module: 'thread_safe'
    }
    }

    asciidoctorj.version '1.5.4.1'
    jruby.execVersion '9.1.7.0'
    jrubyPrepare.outputDir file(".bundle/gems/jruby/${jruby.execVersion}")

    ext.extractVersion = { String filename ->
    org.asciidoctor.Asciidoctor.Factory.create().readDocumentHeader(file(filename)).attributes['revnumber'] ?: 'latest'
    }

    class AsciidoctorPdfTask extends org.asciidoctor.gradle.AsciidoctorTask {}

    task documentA(type: AsciidoctorPdfTask, group: 'Documentation', description: 'Generates the PDF for document A.') {
    def sourceFile = 'document-a.adoc'
    doFirst {
    options.to_file = "${sourceFile.take(sourceFile.lastIndexOf('.'))}-v${extractVersion(sourceFile)}.pdf"
    }
    sources { include sourceFile }
    }

    task documentB(type: AsciidoctorPdfTask, group: 'Documentation', description: 'Generates the PDF for document B.') {
    def sourceFile = 'document-b.adoc'
    doFirst {
    options.to_file = "${sourceFile.take(sourceFile.lastIndexOf('.'))}-v${extractVersion(sourceFile)}.pdf"
    }
    sources { include sourceFile }
    }

    tasks.withType(AsciidoctorPdfTask) {
    dependsOn jrubyPrepare
    gemPath jrubyPrepare.outputDir
    requires 'asciidoctor-pdf'
    backends 'pdf'
    sourceDir '.'
    resources {}
    outputDir buildDir
    separateOutputDirs false
    }

    tasks.remove asciidoctor