Skip to content

Commit

Permalink
Kotlin DSL - 'site' (#1938) (#1954)
Browse files Browse the repository at this point in the history
  • Loading branch information
turansky authored Apr 27, 2020
1 parent 4c68374 commit 8ecd8a1
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 43 deletions.
43 changes: 0 additions & 43 deletions site/build.gradle

This file was deleted.

62 changes: 62 additions & 0 deletions site/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

val buildDocsDir = "$buildDir/docs"
val jekyllDockerImage = "jekyll/jekyll:${version("jekyll")}"

val copyDocs = tasks.register<Copy>("copyDocs") {
val dokkaTasks = rootProject.getTasksByName("dokka", true)

from(dokkaTasks.map { "${it.project.buildDir}/dokka" }) {
include("**/*.md")
include("**/package-list")
}
from("docs")
into(buildDocsDir)

dependsOn(dokkaTasks)
}

val copyExampleFrontendJs = tasks.register<Copy>("copyExampleFrontendJs") {
val srcBuildDir = project(":example-frontend-js").buildDir
from("$srcBuildDir/dist")
into("$buildDocsDir/example-frontend-js")

dependsOn(":example-frontend-js:bundle")
}

tasks.register<Exec>("site") {
description = "Generate github pages"

inputs.files(fileTree(buildDocsDir))
outputs.dir("$buildDir/dist")
workingDir = file(buildDocsDir)

commandLine(
"docker", "run", "--rm", "--volume=$buildDir:/srv/jekyll",
"-t", jekyllDockerImage,
"/bin/bash", "-c", "cd docs; jekyll build"
)

dependsOn(copyDocs)
dependsOn(copyExampleFrontendJs)
}

// A useful task for local debugging -- serves a site locally
tasks.register<Exec>("serve") {
commandLine(
"docker", "run", "--rm", "--volume=$buildDir:/srv/jekyll",
"-p", "8080:8080",
"-t", jekyllDockerImage,
"/bin/bash", "-c", "cd docs; jekyll serve --host 0.0.0.0 --port 8080"
)

dependsOn(copyDocs)
dependsOn(copyExampleFrontendJs)
}

tasks.register<Delete>("clean") {
delete(buildDir)
}

0 comments on commit 8ecd8a1

Please sign in to comment.