buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.github.ben-manes:gradle-versions-plugin:0.13.0'
        classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.6.0'
        classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.3'
        classpath 'org.ajoberstar:gradle-git:1.6.0-rc.1'
    }
}

apply plugin: 'org.asciidoctor.convert'
apply plugin: 'org.ajoberstar.github-pages'
apply plugin: 'com.github.ben-manes.versions'

asciidoctorj {
    version = '1.5.5'
}

asciidoctor {
    backends 'pdf','html5'
    outputDir = file("$buildDir/docs")
    sources {
        include 'index.asc'
        include 'index_zh.asc'
    }
    resources {
        from ('src/docs/asciidoc') {
            include '**/*.png'
            include '**/*.jpg'
            include '**/*.jpeg'
        }
    }
    options doctype: 'book'
    attributes \
            'source-highlighter': 'prettify',
            'toc': 'left',
            'toc-title': 'Table of Contents',
            'pdf-fontsdir': 'fonts',
            'pdf-stylesdir': 'theme',
            'pdf-style': 'fxdocs'
}

defaultTasks 'asciidoctor'

task run(dependsOn:asciidoctor)

githubPages {
  repoUri = 'https://github.com/FXDocs/docs.git'
  pages {
    from(file('build/docs/html5')) {
      include 'index.html'
      include '**/*.png'
      include '**/*.jpg'
      include '**/*.jpeg'
      into '.'
    }
    from(file('build/docs/pdf')) {
      include 'index.pdf'
      rename ('index.pdf', 'book.pdf')
      into '.'
    }
  }
}