1/*
2 * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
5def buildDocsDir = "$buildDir/docs"
6
7task copyDocs(type: Copy, dependsOn: rootProject.getTasksByName("dokka", true)) {
8    from (rootProject.getTasksByName("dokka", true).collect { "$it.project.buildDir/dokka" }) {
9        include "**/*.md"
10        include "**/package-list"
11    }
12    from "docs"
13    into buildDocsDir
14}
15
16task copyExampleFrontendJs(type: Copy, dependsOn: ':example-frontend-js:bundle') {
17    def srcBuildDir = project(':example-frontend-js').buildDir
18    from "$srcBuildDir/dist"
19    into "$buildDocsDir/example-frontend-js"
20}
21
22task site(type: Exec, description: 'Generate github pages', dependsOn: [copyDocs, copyExampleFrontendJs]) {
23    inputs.files(fileTree(buildDocsDir))
24    outputs.dir("$buildDir/dist")
25    workingDir file(buildDocsDir)
26    commandLine 'bundle', 'exec', 'jekyll', 'build'
27}
28
29task clean(type: Delete) {
30    delete buildDir
31}
32
33