1 import groovy.lang.*
2
3 /*
4 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
5 */
6
7 val buildDocsDir = "$buildDir/docs"
8 val jekyllDockerImage = "jekyll/jekyll:${version("jekyll")}"
9
<lambda>null10 val copyDocs by tasks.registering(Copy::class) {
11 val dokkaTasks = rootProject.getTasksByName("dokka", true)
12
13 from(dokkaTasks.map { "${it.project.buildDir}/dokka" }) {
14 include("**/*.md")
15 include("**/package-list")
16 }
17 from("docs")
18 into(buildDocsDir)
19 filter { it.replace("/index.md\"", "/index.html\"") }
20
21 dependsOn(dokkaTasks)
22 }
23
<lambda>null24 val copyExampleFrontendJs by tasks.registering(Copy::class) {
25 val srcBuildDir = project(":example-frontend-js").buildDir
26 from("$srcBuildDir/dist")
27 into("$buildDocsDir/example-frontend-js")
28
29 dependsOn(":example-frontend-js:browserDistribution")
30 }
31
<lambda>null32 tasks.register<Exec>("site") {
33 description = "Generate github pages"
34
35 inputs.files(fileTree(buildDocsDir))
36 outputs.dir("$buildDir/dist")
37 workingDir = file(buildDocsDir)
38
39 commandLine(
40 "docker", "run", "--rm", "--volume=$buildDir:/srv/jekyll",
41 "-t", jekyllDockerImage,
42 "/bin/bash", "-c", "cd docs; jekyll build"
43 )
44
45 dependsOn(copyDocs)
46 dependsOn(copyExampleFrontendJs)
47 }
48
49 // A useful task for local debugging -- serves a site locally
<lambda>null50 tasks.register<Exec>("serve") {
51 commandLine(
52 "docker", "run", "--rm", "--volume=$buildDir:/srv/jekyll",
53 "-p", "8080:8080",
54 "-t", jekyllDockerImage,
55 "/bin/bash", "-c", "cd docs; jekyll serve --host 0.0.0.0 --port 8080"
56 )
57
58 dependsOn(copyDocs)
59 dependsOn(copyExampleFrontendJs)
60 }
61
<lambda>null62 tasks.register<Delete>("clean") {
63 delete(buildDir)
64 }
65
66