Skip to content

Instantly share code, notes, and snippets.

@jagedn
Created September 30, 2016 17:18
Show Gist options
  • Save jagedn/20193374d999a51c3eb04e16ae6a1678 to your computer and use it in GitHub Desktop.
Save jagedn/20193374d999a51c3eb04e16ae6a1678 to your computer and use it in GitHub Desktop.
Generate HTML + Pdf with Asciidoctor Gradle plugin in the same build
buildscript {
dependencies {
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.11'
}
}
plugins {
id 'org.asciidoctor.convert' version '1.5.3'
}
apply plugin: 'java'
apply plugin: 'org.asciidoctor.convert'
version = '1.0.0-SNAPSHOT'
asciidoctorj {
version = '1.5.4'
}
task buildHtml(type:org.asciidoctor.gradle.AsciidoctorTask){
backends 'html5'
attributes \
'build-gradle': file('build.gradle'),
'sourcedir': project.sourceSets.main.java.srcDirs[0],
'endpoint-url': 'http://www.example.org',
'source-highlighter': 'coderay',
'imagesdir': './images',
'toc': 'left',
'icons': 'font',
'setanchors': '',
'idprefix': '',
'idseparator': '-',
'docinfo1': ''
sources{
include 'index.adoc'
}
}
task buildPdf(type:org.asciidoctor.gradle.AsciidoctorTask, dependsOn:'buildHtml'){
backends 'pdf'
attributes \
'build-gradle': file('pdf.gradle'),
'sourcedir': project.sourceSets.main.java.srcDirs[0],
'endpoint-url': 'http://www.example.org',
'source-highlighter': 'coderay',
'imagesdir': './images',
'toc': 'left',
'icons': 'font',
'setanchors': '',
'idprefix': '',
'idseparator': '-',
'docinfo1': '',
'pdf-stylesdir': 'theme',
'pdf-style': 'custom',
'doctype': 'book'
sources{
include '**.adoc'
exclude 'index.adoc'
}
}
buildHtml.doLast {
ant.move(file: 'build/asciidoc/html5', tofile: 'build/asciidoc/')
}
defaultTasks 'buildPdf'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment