-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
108 lines (91 loc) · 2.85 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import com.github.gradle.node.npm.task.NpxTask
import io.pebbletemplates.pebble.PebbleEngine
import io.pebbletemplates.pebble.loader.FileLoader
import java.io.FileWriter
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("io.pebbletemplates:pebble:3.2.2")
}
}
plugins {
kotlin("jvm") version "2.0.21"
id("org.jmailen.kotlinter") version "4.4.1"
id("com.github.node-gradle.node") version "7.1.0"
id("com.github.johnrengelman.shadow") version "8.1.1"
application
}
group = "uk.co.rafearnold"
application.mainClass = "uk.co.rafearnold.themind.MainKt"
repositories {
mavenCentral()
}
dependencies {
implementation(platform("org.http4k:http4k-bom:5.32.4.0"))
implementation("org.http4k:http4k-core")
implementation("org.http4k:http4k-server-jetty")
implementation("org.http4k:http4k-template-core")
implementation("org.http4k:http4k-format-jackson")
implementation("io.pebbletemplates:pebble:3.2.2")
implementation("org.sqids:sqids:0.1.0")
implementation("ch.qos.logback:logback-classic:1.5.11")
testImplementation(kotlin("test"))
testImplementation("org.junit.jupiter:junit-jupiter-params")
testImplementation("com.microsoft.playwright:playwright:1.48.0")
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(20)
}
tasks.run.invoke {
environment("HOT_RESOURCE_RELOADING", true)
}
tasks.check {
dependsOn("installKotlinterPrePushHook")
}
tasks.processResources {
dependsOn("buildCss")
exclude("input/")
exclude("template-variants/")
}
task("buildCss", NpxTask::class) {
dependsOn("buildTemplateVariants")
command = "tailwindcss"
args = listOf(
"-i", "./src/main/resources/input/index.css",
"-o", "./src/main/resources/assets/index.min.css",
"-m",
)
}
/**
* Some of the Tailwind CSS classes in the application's templates are generated
* [dynamically](https://tailwindcss.com/docs/content-configuration#dynamic-class-names) at
* runtime, so Tailwind would not detect that they are required when its build command is executed.
* This task generates the variants of the templates that contain the CSS classes that Tailwind
* needs to know about, thus ensuring that they will be included in the output CSS file.
*/
task("buildTemplateVariants") {
doLast {
val engine =
PebbleEngine.Builder().loader(FileLoader().apply { prefix = "src/main/resources" }).build()
val outputDir = "src/main/resources/template-variants"
File(outputDir).mkdirs()
repeat(2) {
FileWriter("$outputDir/ws-game-$it.html").use { writer ->
val context =
mapOf(
"model" to mapOf(
"otherPlayers" to listOf(mapOf("cardCount" to 11 + it)),
"cards" to (1..11 + it).toList(),
"playedCards" to (1..99 + it).toList(),
)
)
engine.getTemplate("ws-game.html").evaluate(writer, context)
}
}
}
}