Skip to content

Commit 8ecd8a1

Browse files
authored
Kotlin DSL - 'site' (#1938) (#1954)
1 parent 4c68374 commit 8ecd8a1

File tree

2 files changed

+62
-43
lines changed

2 files changed

+62
-43
lines changed

site/build.gradle

-43
This file was deleted.

site/build.gradle.kts

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

0 commit comments

Comments
 (0)